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 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 615 | // This is a positive test. No failures are expected. |
| 616 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 617 | VkResult err; |
| 618 | bool pass; |
| 619 | |
| 620 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 621 | "the buffer, create an image, and bind the same memory to " |
| 622 | "it"); |
| 623 | |
| 624 | m_errorMonitor->ExpectSuccess(); |
| 625 | |
| 626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 627 | |
| 628 | VkBuffer buffer; |
| 629 | VkImage image; |
| 630 | VkDeviceMemory mem; |
| 631 | VkMemoryRequirements mem_reqs; |
| 632 | |
| 633 | VkBufferCreateInfo buf_info = {}; |
| 634 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 635 | buf_info.pNext = NULL; |
| 636 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 637 | buf_info.size = 256; |
| 638 | buf_info.queueFamilyIndexCount = 0; |
| 639 | buf_info.pQueueFamilyIndices = NULL; |
| 640 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 641 | buf_info.flags = 0; |
| 642 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 643 | ASSERT_VK_SUCCESS(err); |
| 644 | |
| 645 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 646 | |
| 647 | VkMemoryAllocateInfo alloc_info = {}; |
| 648 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 649 | alloc_info.pNext = NULL; |
| 650 | alloc_info.memoryTypeIndex = 0; |
| 651 | |
| 652 | // Ensure memory is big enough for both bindings |
| 653 | alloc_info.allocationSize = 0x10000; |
| 654 | |
| 655 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 656 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 657 | if (!pass) { |
| 658 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 659 | return; |
| 660 | } |
| 661 | |
| 662 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 663 | ASSERT_VK_SUCCESS(err); |
| 664 | |
| 665 | uint8_t *pData; |
| 666 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 667 | (void **)&pData); |
| 668 | ASSERT_VK_SUCCESS(err); |
| 669 | |
| 670 | memset(pData, 0xCADECADE, mem_reqs.size); |
| 671 | |
| 672 | vkUnmapMemory(m_device->device(), mem); |
| 673 | |
| 674 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 675 | ASSERT_VK_SUCCESS(err); |
| 676 | |
| 677 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 678 | // memory. In fact, it was never used by the GPU. |
| 679 | // Just be be sure, wait for idle. |
| 680 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 681 | vkDeviceWaitIdle(m_device->device()); |
| 682 | |
| 683 | VkImageCreateInfo image_create_info = {}; |
| 684 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 685 | image_create_info.pNext = NULL; |
| 686 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 687 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 688 | image_create_info.extent.width = 64; |
| 689 | image_create_info.extent.height = 64; |
| 690 | image_create_info.extent.depth = 1; |
| 691 | image_create_info.mipLevels = 1; |
| 692 | image_create_info.arrayLayers = 1; |
| 693 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 694 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 695 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 696 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 697 | image_create_info.queueFamilyIndexCount = 0; |
| 698 | image_create_info.pQueueFamilyIndices = NULL; |
| 699 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 700 | image_create_info.flags = 0; |
| 701 | |
| 702 | VkMemoryAllocateInfo mem_alloc = {}; |
| 703 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 704 | mem_alloc.pNext = NULL; |
| 705 | mem_alloc.allocationSize = 0; |
| 706 | mem_alloc.memoryTypeIndex = 0; |
| 707 | |
| 708 | /* Create a mappable image. It will be the texture if linear images are ok |
| 709 | * to be textures or it will be the staging image if they are not. |
| 710 | */ |
| 711 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 712 | ASSERT_VK_SUCCESS(err); |
| 713 | |
| 714 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 715 | |
| 716 | mem_alloc.allocationSize = mem_reqs.size; |
| 717 | |
| 718 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 719 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 720 | if (!pass) { |
| 721 | vkDestroyImage(m_device->device(), image, NULL); |
| 722 | return; |
| 723 | } |
| 724 | |
| 725 | // VALDIATION FAILURE: |
| 726 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 727 | ASSERT_VK_SUCCESS(err); |
| 728 | |
| 729 | m_errorMonitor->VerifyNotFound(); |
| 730 | |
| 731 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 732 | vkDestroyImage(m_device->device(), image, NULL); |
| 733 | } |
| 734 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 735 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 736 | VkResult err; |
| 737 | bool pass; |
| 738 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 739 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 740 | // following declaration (which is temporarily being moved below): |
| 741 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 742 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 743 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 744 | uint32_t swapchain_image_count = 0; |
| 745 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 746 | uint32_t image_index = 0; |
| 747 | // VkPresentInfoKHR present_info = {}; |
| 748 | |
| 749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 750 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 751 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 752 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 753 | // Use the functions from the VK_KHR_android_surface extension without |
| 754 | // enabling that extension: |
| 755 | |
| 756 | // Create a surface: |
| 757 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 758 | #if 0 |
| 759 | #endif |
| 760 | m_errorMonitor->SetDesiredFailureMsg( |
| 761 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 762 | "extension was not enabled for this"); |
| 763 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 764 | &surface); |
| 765 | pass = (err != VK_SUCCESS); |
| 766 | ASSERT_TRUE(pass); |
| 767 | m_errorMonitor->VerifyFound(); |
| 768 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 769 | |
| 770 | |
| 771 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 772 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 773 | // that extension: |
| 774 | |
| 775 | // Create a surface: |
| 776 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 777 | #if 0 |
| 778 | #endif |
| 779 | m_errorMonitor->SetDesiredFailureMsg( |
| 780 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 781 | "extension was not enabled for this"); |
| 782 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 783 | pass = (err != VK_SUCCESS); |
| 784 | ASSERT_TRUE(pass); |
| 785 | m_errorMonitor->VerifyFound(); |
| 786 | |
| 787 | // Tell whether an mir_connection supports presentation: |
| 788 | MirConnection *mir_connection = NULL; |
| 789 | m_errorMonitor->SetDesiredFailureMsg( |
| 790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 791 | "extension was not enabled for this"); |
| 792 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 793 | visual_id); |
| 794 | m_errorMonitor->VerifyFound(); |
| 795 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 796 | |
| 797 | |
| 798 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 799 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 800 | // enabling that extension: |
| 801 | |
| 802 | // Create a surface: |
| 803 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 804 | #if 0 |
| 805 | #endif |
| 806 | m_errorMonitor->SetDesiredFailureMsg( |
| 807 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 808 | "extension was not enabled for this"); |
| 809 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 810 | &surface); |
| 811 | pass = (err != VK_SUCCESS); |
| 812 | ASSERT_TRUE(pass); |
| 813 | m_errorMonitor->VerifyFound(); |
| 814 | |
| 815 | // Tell whether an wayland_display supports presentation: |
| 816 | struct wl_display wayland_display = {}; |
| 817 | m_errorMonitor->SetDesiredFailureMsg( |
| 818 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 819 | "extension was not enabled for this"); |
| 820 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 821 | &wayland_display); |
| 822 | m_errorMonitor->VerifyFound(); |
| 823 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 824 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 825 | |
| 826 | |
| 827 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 828 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 829 | // TO NON-LINUX PLATFORMS: |
| 830 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 831 | // Use the functions from the VK_KHR_win32_surface extension without |
| 832 | // enabling that extension: |
| 833 | |
| 834 | // Create a surface: |
| 835 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 836 | #if 0 |
| 837 | #endif |
| 838 | m_errorMonitor->SetDesiredFailureMsg( |
| 839 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 840 | "extension was not enabled for this"); |
| 841 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 842 | &surface); |
| 843 | pass = (err != VK_SUCCESS); |
| 844 | ASSERT_TRUE(pass); |
| 845 | m_errorMonitor->VerifyFound(); |
| 846 | |
| 847 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 848 | m_errorMonitor->SetDesiredFailureMsg( |
| 849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 850 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 851 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 852 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 853 | // Set this (for now, until all platforms are supported and tested): |
| 854 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 855 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 856 | |
| 857 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 858 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 859 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 860 | // TO NON-LINUX PLATFORMS: |
| 861 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 862 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 863 | // that extension: |
| 864 | |
| 865 | // Create a surface: |
| 866 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 867 | #if 0 |
| 868 | #endif |
| 869 | m_errorMonitor->SetDesiredFailureMsg( |
| 870 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 871 | "extension was not enabled for this"); |
| 872 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 873 | pass = (err != VK_SUCCESS); |
| 874 | ASSERT_TRUE(pass); |
| 875 | m_errorMonitor->VerifyFound(); |
| 876 | |
| 877 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 878 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 879 | xcb_visualid_t visual_id = 0; |
| 880 | m_errorMonitor->SetDesiredFailureMsg( |
| 881 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 882 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 883 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 884 | visual_id); |
| 885 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 886 | // Set this (for now, until all platforms are supported and tested): |
| 887 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 888 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 889 | |
| 890 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 891 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 892 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 893 | // that extension: |
| 894 | |
| 895 | // Create a surface: |
| 896 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 897 | #if 0 |
| 898 | #endif |
| 899 | m_errorMonitor->SetDesiredFailureMsg( |
| 900 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 901 | "extension was not enabled for this"); |
| 902 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 903 | pass = (err != VK_SUCCESS); |
| 904 | ASSERT_TRUE(pass); |
| 905 | m_errorMonitor->VerifyFound(); |
| 906 | |
| 907 | // Tell whether an Xlib VisualID supports presentation: |
| 908 | Display *dpy = NULL; |
| 909 | VisualID visual = 0; |
| 910 | m_errorMonitor->SetDesiredFailureMsg( |
| 911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 912 | "extension was not enabled for this"); |
| 913 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 914 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 915 | // Set this (for now, until all platforms are supported and tested): |
| 916 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 917 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 918 | |
| 919 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 920 | // Use the functions from the VK_KHR_surface extension without enabling |
| 921 | // that extension: |
| 922 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 923 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 924 | // Destroy a surface: |
| 925 | m_errorMonitor->SetDesiredFailureMsg( |
| 926 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 927 | "extension was not enabled for this"); |
| 928 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 929 | m_errorMonitor->VerifyFound(); |
| 930 | |
| 931 | // Check if surface supports presentation: |
| 932 | VkBool32 supported = false; |
| 933 | m_errorMonitor->SetDesiredFailureMsg( |
| 934 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 935 | "extension was not enabled for this"); |
| 936 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 937 | pass = (err != VK_SUCCESS); |
| 938 | ASSERT_TRUE(pass); |
| 939 | m_errorMonitor->VerifyFound(); |
| 940 | |
| 941 | // Check surface capabilities: |
| 942 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 943 | m_errorMonitor->SetDesiredFailureMsg( |
| 944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 945 | "extension was not enabled for this"); |
| 946 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 947 | &capabilities); |
| 948 | pass = (err != VK_SUCCESS); |
| 949 | ASSERT_TRUE(pass); |
| 950 | m_errorMonitor->VerifyFound(); |
| 951 | |
| 952 | // Check surface formats: |
| 953 | uint32_t format_count = 0; |
| 954 | VkSurfaceFormatKHR *formats = NULL; |
| 955 | m_errorMonitor->SetDesiredFailureMsg( |
| 956 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 957 | "extension was not enabled for this"); |
| 958 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 959 | &format_count, formats); |
| 960 | pass = (err != VK_SUCCESS); |
| 961 | ASSERT_TRUE(pass); |
| 962 | m_errorMonitor->VerifyFound(); |
| 963 | |
| 964 | // Check surface present modes: |
| 965 | uint32_t present_mode_count = 0; |
| 966 | VkSurfaceFormatKHR *present_modes = NULL; |
| 967 | m_errorMonitor->SetDesiredFailureMsg( |
| 968 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 969 | "extension was not enabled for this"); |
| 970 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 971 | &present_mode_count, present_modes); |
| 972 | pass = (err != VK_SUCCESS); |
| 973 | ASSERT_TRUE(pass); |
| 974 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 975 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 976 | |
| 977 | |
| 978 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 979 | // that extension: |
| 980 | |
| 981 | // Create a swapchain: |
| 982 | m_errorMonitor->SetDesiredFailureMsg( |
| 983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 984 | "extension was not enabled for this"); |
| 985 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 986 | swapchain_create_info.pNext = NULL; |
| 987 | #if 0 |
| 988 | swapchain_create_info.flags = 0; |
| 989 | swapchain_create_info.surface = 0; |
| 990 | swapchain_create_info.minImageCount = 0; |
| 991 | swapchain_create_info.imageFormat = 0; |
| 992 | swapchain_create_info.imageColorSpace = 0; |
| 993 | swapchain_create_info.imageExtent.width = 0; |
| 994 | swapchain_create_info.imageExtent.height = 0; |
| 995 | swapchain_create_info.imageArrayLayers = 0; |
| 996 | swapchain_create_info.imageUsage = 0; |
| 997 | swapchain_create_info.imageSharingMode = 0; |
| 998 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 999 | swapchain_create_info.preTransform = 0; |
| 1000 | swapchain_create_info.compositeAlpha = 0; |
| 1001 | swapchain_create_info.presentMode = 0; |
| 1002 | swapchain_create_info.clipped = 0; |
| 1003 | swapchain_create_info.oldSwapchain = NULL; |
| 1004 | #endif |
| 1005 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1006 | NULL, &swapchain); |
| 1007 | pass = (err != VK_SUCCESS); |
| 1008 | ASSERT_TRUE(pass); |
| 1009 | m_errorMonitor->VerifyFound(); |
| 1010 | |
| 1011 | // Get the images from the swapchain: |
| 1012 | m_errorMonitor->SetDesiredFailureMsg( |
| 1013 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1014 | "extension was not enabled for this"); |
| 1015 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1016 | &swapchain_image_count, NULL); |
| 1017 | pass = (err != VK_SUCCESS); |
| 1018 | ASSERT_TRUE(pass); |
| 1019 | m_errorMonitor->VerifyFound(); |
| 1020 | |
| 1021 | // Try to acquire an image: |
| 1022 | m_errorMonitor->SetDesiredFailureMsg( |
| 1023 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1024 | "extension was not enabled for this"); |
| 1025 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1026 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1027 | pass = (err != VK_SUCCESS); |
| 1028 | ASSERT_TRUE(pass); |
| 1029 | m_errorMonitor->VerifyFound(); |
| 1030 | |
| 1031 | // Try to present an image: |
| 1032 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 1033 | // (as opposed to the fake one we created) in order for the layer to |
| 1034 | // lookup the VkDevice used to enable the extension: |
| 1035 | m_errorMonitor->SetDesiredFailureMsg( |
| 1036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1037 | "extension was not enabled for this"); |
| 1038 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 1039 | present_info.pNext = NULL; |
| 1040 | #if 0 |
| 1041 | #endif |
| 1042 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 1043 | pass = (err != VK_SUCCESS); |
| 1044 | ASSERT_TRUE(pass); |
| 1045 | m_errorMonitor->VerifyFound(); |
| 1046 | #endif |
| 1047 | |
| 1048 | // Destroy the swapchain: |
| 1049 | m_errorMonitor->SetDesiredFailureMsg( |
| 1050 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1051 | "extension was not enabled for this"); |
| 1052 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1053 | m_errorMonitor->VerifyFound(); |
| 1054 | } |
| 1055 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1056 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1057 | VkResult err; |
| 1058 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1059 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1060 | m_errorMonitor->SetDesiredFailureMsg( |
| 1061 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1062 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1063 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1064 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1065 | |
| 1066 | // 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] | 1067 | VkImage image; |
| 1068 | VkDeviceMemory mem; |
| 1069 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1070 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1071 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1072 | const int32_t tex_width = 32; |
| 1073 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1074 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1075 | VkImageCreateInfo image_create_info = {}; |
| 1076 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1077 | image_create_info.pNext = NULL; |
| 1078 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1079 | image_create_info.format = tex_format; |
| 1080 | image_create_info.extent.width = tex_width; |
| 1081 | image_create_info.extent.height = tex_height; |
| 1082 | image_create_info.extent.depth = 1; |
| 1083 | image_create_info.mipLevels = 1; |
| 1084 | image_create_info.arrayLayers = 1; |
| 1085 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1086 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1087 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1088 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1089 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1090 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1091 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1092 | mem_alloc.pNext = NULL; |
| 1093 | mem_alloc.allocationSize = 0; |
| 1094 | // Introduce failure, do NOT set memProps to |
| 1095 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1096 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1098 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1099 | ASSERT_VK_SUCCESS(err); |
| 1100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1101 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1102 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1103 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1105 | pass = |
| 1106 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1107 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1108 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1109 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1110 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1111 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1112 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1113 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1114 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1115 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1116 | ASSERT_VK_SUCCESS(err); |
| 1117 | |
| 1118 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1119 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1120 | ASSERT_VK_SUCCESS(err); |
| 1121 | |
| 1122 | // Map memory as if to initialize the image |
| 1123 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1124 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1125 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1126 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1127 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1128 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1129 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1130 | } |
| 1131 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1132 | TEST_F(VkLayerTest, RebindMemory) { |
| 1133 | VkResult err; |
| 1134 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1136 | m_errorMonitor->SetDesiredFailureMsg( |
| 1137 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1138 | "which has already been bound to mem object"); |
| 1139 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1141 | |
| 1142 | // 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] | 1143 | VkImage image; |
| 1144 | VkDeviceMemory mem1; |
| 1145 | VkDeviceMemory mem2; |
| 1146 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1148 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1149 | const int32_t tex_width = 32; |
| 1150 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1151 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1152 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1153 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1154 | image_create_info.pNext = NULL; |
| 1155 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1156 | image_create_info.format = tex_format; |
| 1157 | image_create_info.extent.width = tex_width; |
| 1158 | image_create_info.extent.height = tex_height; |
| 1159 | image_create_info.extent.depth = 1; |
| 1160 | image_create_info.mipLevels = 1; |
| 1161 | image_create_info.arrayLayers = 1; |
| 1162 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1163 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1164 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1165 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1166 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1167 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1168 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1169 | mem_alloc.pNext = NULL; |
| 1170 | mem_alloc.allocationSize = 0; |
| 1171 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1173 | // Introduce failure, do NOT set memProps to |
| 1174 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1175 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1176 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1177 | ASSERT_VK_SUCCESS(err); |
| 1178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1179 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1180 | |
| 1181 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1182 | pass = |
| 1183 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1184 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1185 | |
| 1186 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1187 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1188 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1189 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1190 | ASSERT_VK_SUCCESS(err); |
| 1191 | |
| 1192 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1193 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1194 | ASSERT_VK_SUCCESS(err); |
| 1195 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1196 | // Introduce validation failure, try to bind a different memory object to |
| 1197 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1198 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1199 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1200 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1201 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1202 | vkDestroyImage(m_device->device(), image, NULL); |
| 1203 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1204 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1205 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1207 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1208 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1209 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1210 | m_errorMonitor->SetDesiredFailureMsg( |
| 1211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1212 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1213 | |
| 1214 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1215 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1216 | fenceInfo.pNext = NULL; |
| 1217 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1218 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1220 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1221 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1222 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1223 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1224 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1225 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1226 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1227 | |
| 1228 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1229 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1230 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1231 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1232 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1233 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1234 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1235 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1236 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1237 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1238 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1239 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1240 | |
| 1241 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1242 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1243 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1244 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1245 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1246 | // This is a positive test. We used to expect error in this case but spec now |
| 1247 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1248 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1249 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1250 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1251 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1252 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1253 | fenceInfo.pNext = NULL; |
| 1254 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1256 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1257 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1258 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1259 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1260 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1261 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1262 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1263 | |
| 1264 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1265 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1266 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1267 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1268 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1269 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1270 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1271 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1272 | |
| 1273 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1274 | VkImageObj image(m_device); |
| 1275 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1276 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1277 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1278 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1279 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1280 | VkImageView dsv; |
| 1281 | VkImageViewCreateInfo dsvci = {}; |
| 1282 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1283 | dsvci.image = image.handle(); |
| 1284 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1285 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1286 | dsvci.subresourceRange.layerCount = 1; |
| 1287 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1288 | dsvci.subresourceRange.levelCount = 1; |
| 1289 | dsvci.subresourceRange.aspectMask = |
| 1290 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1291 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1292 | // Create a view with depth / stencil aspect for image with different usage |
| 1293 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1294 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1295 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1296 | |
| 1297 | // Initialize buffer with TRANSFER_DST usage |
| 1298 | vk_testing::Buffer buffer; |
| 1299 | VkMemoryPropertyFlags reqs = 0; |
| 1300 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1301 | VkBufferImageCopy region = {}; |
| 1302 | region.bufferRowLength = 128; |
| 1303 | region.bufferImageHeight = 128; |
| 1304 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1305 | region.imageSubresource.layerCount = 1; |
| 1306 | region.imageExtent.height = 16; |
| 1307 | region.imageExtent.width = 16; |
| 1308 | region.imageExtent.depth = 1; |
| 1309 | |
| 1310 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1311 | "Invalid usage flag for buffer "); |
| 1312 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1313 | // TRANSFER_DST |
| 1314 | BeginCommandBuffer(); |
| 1315 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1316 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1317 | 1, ®ion); |
| 1318 | m_errorMonitor->VerifyFound(); |
| 1319 | |
| 1320 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1321 | "Invalid usage flag for image "); |
| 1322 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1323 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1324 | 1, ®ion); |
| 1325 | m_errorMonitor->VerifyFound(); |
| 1326 | |
| 1327 | vkDestroyImageView(m_device->device(), dsv, NULL); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1328 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1329 | #endif // MEM_TRACKER_TESTS |
| 1330 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1331 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1332 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1333 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1334 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1335 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1336 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1337 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1338 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1340 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1341 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1342 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1343 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1344 | |
| 1345 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1346 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1347 | ds_pool_ci.pNext = NULL; |
| 1348 | ds_pool_ci.maxSets = 1; |
| 1349 | ds_pool_ci.poolSizeCount = 1; |
| 1350 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1351 | |
| 1352 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1353 | err = |
| 1354 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | ASSERT_VK_SUCCESS(err); |
| 1356 | |
| 1357 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1358 | dsl_binding.binding = 0; |
| 1359 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1360 | dsl_binding.descriptorCount = 1; |
| 1361 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1362 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1363 | |
| 1364 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1365 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1366 | ds_layout_ci.pNext = NULL; |
| 1367 | ds_layout_ci.bindingCount = 1; |
| 1368 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1369 | |
| 1370 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1371 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1372 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1373 | ASSERT_VK_SUCCESS(err); |
| 1374 | |
| 1375 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1376 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1377 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1378 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1379 | alloc_info.descriptorPool = ds_pool; |
| 1380 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1381 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1382 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1383 | ASSERT_VK_SUCCESS(err); |
| 1384 | |
| 1385 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1386 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1387 | pipeline_layout_ci.pNext = NULL; |
| 1388 | pipeline_layout_ci.setLayoutCount = 1; |
| 1389 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1390 | |
| 1391 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1392 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1393 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1394 | ASSERT_VK_SUCCESS(err); |
| 1395 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1396 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1397 | |
| 1398 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1399 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1400 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1401 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1402 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1403 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1404 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1405 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1406 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1407 | } |
| 1408 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1409 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1410 | VkResult err; |
| 1411 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1412 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1413 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1414 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1415 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1417 | |
| 1418 | // 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] | 1419 | VkImage image; |
| 1420 | VkDeviceMemory mem; |
| 1421 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1422 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1423 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1424 | const int32_t tex_width = 32; |
| 1425 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1426 | |
| 1427 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1428 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1429 | image_create_info.pNext = NULL; |
| 1430 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1431 | image_create_info.format = tex_format; |
| 1432 | image_create_info.extent.width = tex_width; |
| 1433 | image_create_info.extent.height = tex_height; |
| 1434 | image_create_info.extent.depth = 1; |
| 1435 | image_create_info.mipLevels = 1; |
| 1436 | image_create_info.arrayLayers = 1; |
| 1437 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1438 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1439 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1440 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1441 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1442 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1443 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1444 | mem_alloc.pNext = NULL; |
| 1445 | mem_alloc.allocationSize = 0; |
| 1446 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1447 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1448 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1449 | ASSERT_VK_SUCCESS(err); |
| 1450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1451 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1452 | |
| 1453 | mem_alloc.allocationSize = mem_reqs.size; |
| 1454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1455 | pass = |
| 1456 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1457 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1458 | |
| 1459 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1460 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1461 | ASSERT_VK_SUCCESS(err); |
| 1462 | |
| 1463 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1464 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1465 | |
| 1466 | // Try to bind free memory that has been freed |
| 1467 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1468 | // This may very well return an error. |
| 1469 | (void)err; |
| 1470 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1471 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1472 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1473 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1474 | } |
| 1475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1476 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1477 | VkResult err; |
| 1478 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1479 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1480 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1481 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1482 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1483 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1484 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1485 | // Create an image object, allocate memory, destroy the object and then try |
| 1486 | // to bind it |
| 1487 | VkImage image; |
| 1488 | VkDeviceMemory mem; |
| 1489 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1491 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1492 | const int32_t tex_width = 32; |
| 1493 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1494 | |
| 1495 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1496 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1497 | image_create_info.pNext = NULL; |
| 1498 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1499 | image_create_info.format = tex_format; |
| 1500 | image_create_info.extent.width = tex_width; |
| 1501 | image_create_info.extent.height = tex_height; |
| 1502 | image_create_info.extent.depth = 1; |
| 1503 | image_create_info.mipLevels = 1; |
| 1504 | image_create_info.arrayLayers = 1; |
| 1505 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1506 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1507 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1508 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1509 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1510 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1511 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1512 | mem_alloc.pNext = NULL; |
| 1513 | mem_alloc.allocationSize = 0; |
| 1514 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1515 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1516 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1517 | ASSERT_VK_SUCCESS(err); |
| 1518 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1519 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1520 | |
| 1521 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1522 | pass = |
| 1523 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1524 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1525 | |
| 1526 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1527 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1528 | ASSERT_VK_SUCCESS(err); |
| 1529 | |
| 1530 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1531 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1532 | ASSERT_VK_SUCCESS(err); |
| 1533 | |
| 1534 | // Now Try to bind memory to this destroyed object |
| 1535 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1536 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1537 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1538 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1539 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1540 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1541 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1542 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1543 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1544 | #endif // OBJ_TRACKER_TESTS |
| 1545 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1546 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1547 | |
| 1548 | // This is a positive test. No errors should be generated. |
| 1549 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1550 | |
| 1551 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1552 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1553 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1554 | if ((m_device->queue_props.empty()) || |
| 1555 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1556 | return; |
| 1557 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1558 | m_errorMonitor->ExpectSuccess(); |
| 1559 | |
| 1560 | VkSemaphore semaphore; |
| 1561 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1562 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1563 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1564 | &semaphore); |
| 1565 | |
| 1566 | VkCommandPool command_pool; |
| 1567 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1568 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1569 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1570 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1571 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1572 | &command_pool); |
| 1573 | |
| 1574 | VkCommandBuffer command_buffer[2]; |
| 1575 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1576 | command_buffer_allocate_info.sType = |
| 1577 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1578 | command_buffer_allocate_info.commandPool = command_pool; |
| 1579 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1580 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1581 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1582 | command_buffer); |
| 1583 | |
| 1584 | VkQueue queue = VK_NULL_HANDLE; |
| 1585 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1586 | 1, &queue); |
| 1587 | |
| 1588 | { |
| 1589 | VkCommandBufferBeginInfo begin_info{}; |
| 1590 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1591 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1592 | |
| 1593 | vkCmdPipelineBarrier(command_buffer[0], |
| 1594 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1595 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1596 | 0, nullptr, 0, nullptr); |
| 1597 | |
| 1598 | VkViewport viewport{}; |
| 1599 | viewport.maxDepth = 1.0f; |
| 1600 | viewport.minDepth = 0.0f; |
| 1601 | viewport.width = 512; |
| 1602 | viewport.height = 512; |
| 1603 | viewport.x = 0; |
| 1604 | viewport.y = 0; |
| 1605 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1606 | vkEndCommandBuffer(command_buffer[0]); |
| 1607 | } |
| 1608 | { |
| 1609 | VkCommandBufferBeginInfo begin_info{}; |
| 1610 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1611 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1612 | |
| 1613 | VkViewport viewport{}; |
| 1614 | viewport.maxDepth = 1.0f; |
| 1615 | viewport.minDepth = 0.0f; |
| 1616 | viewport.width = 512; |
| 1617 | viewport.height = 512; |
| 1618 | viewport.x = 0; |
| 1619 | viewport.y = 0; |
| 1620 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1621 | vkEndCommandBuffer(command_buffer[1]); |
| 1622 | } |
| 1623 | { |
| 1624 | VkSubmitInfo submit_info{}; |
| 1625 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1626 | submit_info.commandBufferCount = 1; |
| 1627 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1628 | submit_info.signalSemaphoreCount = 1; |
| 1629 | submit_info.pSignalSemaphores = &semaphore; |
| 1630 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1631 | } |
| 1632 | { |
| 1633 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1634 | VkSubmitInfo submit_info{}; |
| 1635 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1636 | submit_info.commandBufferCount = 1; |
| 1637 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1638 | submit_info.waitSemaphoreCount = 1; |
| 1639 | submit_info.pWaitSemaphores = &semaphore; |
| 1640 | submit_info.pWaitDstStageMask = flags; |
| 1641 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1642 | } |
| 1643 | |
| 1644 | vkQueueWaitIdle(m_device->m_queue); |
| 1645 | |
| 1646 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1647 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1648 | &command_buffer[0]); |
| 1649 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1650 | |
| 1651 | m_errorMonitor->VerifyNotFound(); |
| 1652 | } |
| 1653 | |
| 1654 | // This is a positive test. No errors should be generated. |
| 1655 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1656 | |
| 1657 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1658 | "submitted on separate queues, the second having a fence" |
| 1659 | "followed by a QueueWaitIdle."); |
| 1660 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1661 | if ((m_device->queue_props.empty()) || |
| 1662 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1663 | return; |
| 1664 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1665 | m_errorMonitor->ExpectSuccess(); |
| 1666 | |
| 1667 | VkFence fence; |
| 1668 | VkFenceCreateInfo fence_create_info{}; |
| 1669 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1670 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1671 | |
| 1672 | VkSemaphore semaphore; |
| 1673 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1674 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1675 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1676 | &semaphore); |
| 1677 | |
| 1678 | VkCommandPool command_pool; |
| 1679 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1680 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1681 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1682 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1683 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1684 | &command_pool); |
| 1685 | |
| 1686 | VkCommandBuffer command_buffer[2]; |
| 1687 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1688 | command_buffer_allocate_info.sType = |
| 1689 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1690 | command_buffer_allocate_info.commandPool = command_pool; |
| 1691 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1692 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1693 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1694 | command_buffer); |
| 1695 | |
| 1696 | VkQueue queue = VK_NULL_HANDLE; |
| 1697 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1698 | 1, &queue); |
| 1699 | |
| 1700 | { |
| 1701 | VkCommandBufferBeginInfo begin_info{}; |
| 1702 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1703 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1704 | |
| 1705 | vkCmdPipelineBarrier(command_buffer[0], |
| 1706 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1707 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1708 | 0, nullptr, 0, nullptr); |
| 1709 | |
| 1710 | VkViewport viewport{}; |
| 1711 | viewport.maxDepth = 1.0f; |
| 1712 | viewport.minDepth = 0.0f; |
| 1713 | viewport.width = 512; |
| 1714 | viewport.height = 512; |
| 1715 | viewport.x = 0; |
| 1716 | viewport.y = 0; |
| 1717 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1718 | vkEndCommandBuffer(command_buffer[0]); |
| 1719 | } |
| 1720 | { |
| 1721 | VkCommandBufferBeginInfo begin_info{}; |
| 1722 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1723 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1724 | |
| 1725 | VkViewport viewport{}; |
| 1726 | viewport.maxDepth = 1.0f; |
| 1727 | viewport.minDepth = 0.0f; |
| 1728 | viewport.width = 512; |
| 1729 | viewport.height = 512; |
| 1730 | viewport.x = 0; |
| 1731 | viewport.y = 0; |
| 1732 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1733 | vkEndCommandBuffer(command_buffer[1]); |
| 1734 | } |
| 1735 | { |
| 1736 | VkSubmitInfo submit_info{}; |
| 1737 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1738 | submit_info.commandBufferCount = 1; |
| 1739 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1740 | submit_info.signalSemaphoreCount = 1; |
| 1741 | submit_info.pSignalSemaphores = &semaphore; |
| 1742 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1743 | } |
| 1744 | { |
| 1745 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1746 | VkSubmitInfo submit_info{}; |
| 1747 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1748 | submit_info.commandBufferCount = 1; |
| 1749 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1750 | submit_info.waitSemaphoreCount = 1; |
| 1751 | submit_info.pWaitSemaphores = &semaphore; |
| 1752 | submit_info.pWaitDstStageMask = flags; |
| 1753 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1754 | } |
| 1755 | |
| 1756 | vkQueueWaitIdle(m_device->m_queue); |
| 1757 | |
| 1758 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1759 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1760 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1761 | &command_buffer[0]); |
| 1762 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1763 | |
| 1764 | m_errorMonitor->VerifyNotFound(); |
| 1765 | } |
| 1766 | |
| 1767 | // This is a positive test. No errors should be generated. |
| 1768 | TEST_F(VkLayerTest, |
| 1769 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 1770 | |
| 1771 | TEST_DESCRIPTION( |
| 1772 | "Two command buffers, each in a separate QueueSubmit call " |
| 1773 | "submitted on separate queues, the second having a fence" |
| 1774 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 1775 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1776 | if ((m_device->queue_props.empty()) || |
| 1777 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1778 | return; |
| 1779 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1780 | m_errorMonitor->ExpectSuccess(); |
| 1781 | |
| 1782 | VkFence fence; |
| 1783 | VkFenceCreateInfo fence_create_info{}; |
| 1784 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1785 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1786 | |
| 1787 | VkSemaphore semaphore; |
| 1788 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1789 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1790 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1791 | &semaphore); |
| 1792 | |
| 1793 | VkCommandPool command_pool; |
| 1794 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1795 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1796 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1797 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1798 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1799 | &command_pool); |
| 1800 | |
| 1801 | VkCommandBuffer command_buffer[2]; |
| 1802 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1803 | command_buffer_allocate_info.sType = |
| 1804 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1805 | command_buffer_allocate_info.commandPool = command_pool; |
| 1806 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1807 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1808 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1809 | command_buffer); |
| 1810 | |
| 1811 | VkQueue queue = VK_NULL_HANDLE; |
| 1812 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1813 | 1, &queue); |
| 1814 | |
| 1815 | { |
| 1816 | VkCommandBufferBeginInfo begin_info{}; |
| 1817 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1818 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1819 | |
| 1820 | vkCmdPipelineBarrier(command_buffer[0], |
| 1821 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1822 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1823 | 0, nullptr, 0, nullptr); |
| 1824 | |
| 1825 | VkViewport viewport{}; |
| 1826 | viewport.maxDepth = 1.0f; |
| 1827 | viewport.minDepth = 0.0f; |
| 1828 | viewport.width = 512; |
| 1829 | viewport.height = 512; |
| 1830 | viewport.x = 0; |
| 1831 | viewport.y = 0; |
| 1832 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1833 | vkEndCommandBuffer(command_buffer[0]); |
| 1834 | } |
| 1835 | { |
| 1836 | VkCommandBufferBeginInfo begin_info{}; |
| 1837 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1838 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1839 | |
| 1840 | VkViewport viewport{}; |
| 1841 | viewport.maxDepth = 1.0f; |
| 1842 | viewport.minDepth = 0.0f; |
| 1843 | viewport.width = 512; |
| 1844 | viewport.height = 512; |
| 1845 | viewport.x = 0; |
| 1846 | viewport.y = 0; |
| 1847 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1848 | vkEndCommandBuffer(command_buffer[1]); |
| 1849 | } |
| 1850 | { |
| 1851 | VkSubmitInfo submit_info{}; |
| 1852 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1853 | submit_info.commandBufferCount = 1; |
| 1854 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1855 | submit_info.signalSemaphoreCount = 1; |
| 1856 | submit_info.pSignalSemaphores = &semaphore; |
| 1857 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1858 | } |
| 1859 | { |
| 1860 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1861 | VkSubmitInfo submit_info{}; |
| 1862 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1863 | submit_info.commandBufferCount = 1; |
| 1864 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1865 | submit_info.waitSemaphoreCount = 1; |
| 1866 | submit_info.pWaitSemaphores = &semaphore; |
| 1867 | submit_info.pWaitDstStageMask = flags; |
| 1868 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1869 | } |
| 1870 | |
| 1871 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1872 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1873 | |
| 1874 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1875 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1876 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1877 | &command_buffer[0]); |
| 1878 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1879 | |
| 1880 | m_errorMonitor->VerifyNotFound(); |
| 1881 | } |
| 1882 | |
| 1883 | // This is a positive test. No errors should be generated. |
| 1884 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 1885 | |
| 1886 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1887 | "submitted on separate queues, the second having a fence, " |
| 1888 | "followed by a WaitForFences call."); |
| 1889 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1890 | if ((m_device->queue_props.empty()) || |
| 1891 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1892 | return; |
| 1893 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1894 | m_errorMonitor->ExpectSuccess(); |
| 1895 | |
| 1896 | VkFence fence; |
| 1897 | VkFenceCreateInfo fence_create_info{}; |
| 1898 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1899 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1900 | |
| 1901 | VkSemaphore semaphore; |
| 1902 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1903 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1904 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1905 | &semaphore); |
| 1906 | |
| 1907 | VkCommandPool command_pool; |
| 1908 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1909 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1910 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1911 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1912 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1913 | &command_pool); |
| 1914 | |
| 1915 | VkCommandBuffer command_buffer[2]; |
| 1916 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1917 | command_buffer_allocate_info.sType = |
| 1918 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1919 | command_buffer_allocate_info.commandPool = command_pool; |
| 1920 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1921 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1922 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1923 | command_buffer); |
| 1924 | |
| 1925 | VkQueue queue = VK_NULL_HANDLE; |
| 1926 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1927 | 1, &queue); |
| 1928 | |
| 1929 | |
| 1930 | { |
| 1931 | VkCommandBufferBeginInfo begin_info{}; |
| 1932 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1933 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1934 | |
| 1935 | vkCmdPipelineBarrier(command_buffer[0], |
| 1936 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1937 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1938 | 0, nullptr, 0, nullptr); |
| 1939 | |
| 1940 | VkViewport viewport{}; |
| 1941 | viewport.maxDepth = 1.0f; |
| 1942 | viewport.minDepth = 0.0f; |
| 1943 | viewport.width = 512; |
| 1944 | viewport.height = 512; |
| 1945 | viewport.x = 0; |
| 1946 | viewport.y = 0; |
| 1947 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1948 | vkEndCommandBuffer(command_buffer[0]); |
| 1949 | } |
| 1950 | { |
| 1951 | VkCommandBufferBeginInfo begin_info{}; |
| 1952 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1953 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1954 | |
| 1955 | VkViewport viewport{}; |
| 1956 | viewport.maxDepth = 1.0f; |
| 1957 | viewport.minDepth = 0.0f; |
| 1958 | viewport.width = 512; |
| 1959 | viewport.height = 512; |
| 1960 | viewport.x = 0; |
| 1961 | viewport.y = 0; |
| 1962 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1963 | vkEndCommandBuffer(command_buffer[1]); |
| 1964 | } |
| 1965 | { |
| 1966 | VkSubmitInfo submit_info{}; |
| 1967 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1968 | submit_info.commandBufferCount = 1; |
| 1969 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1970 | submit_info.signalSemaphoreCount = 1; |
| 1971 | submit_info.pSignalSemaphores = &semaphore; |
| 1972 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1973 | } |
| 1974 | { |
| 1975 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1976 | VkSubmitInfo submit_info{}; |
| 1977 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1978 | submit_info.commandBufferCount = 1; |
| 1979 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1980 | submit_info.waitSemaphoreCount = 1; |
| 1981 | submit_info.pWaitSemaphores = &semaphore; |
| 1982 | submit_info.pWaitDstStageMask = flags; |
| 1983 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1984 | } |
| 1985 | |
| 1986 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1987 | |
| 1988 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1989 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1990 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1991 | &command_buffer[0]); |
| 1992 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1993 | |
| 1994 | m_errorMonitor->VerifyNotFound(); |
| 1995 | } |
| 1996 | |
| 1997 | // This is a positive test. No errors should be generated. |
| 1998 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 1999 | |
| 2000 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2001 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2002 | "second having a fence, " |
| 2003 | "followed by a WaitForFences call."); |
| 2004 | |
| 2005 | m_errorMonitor->ExpectSuccess(); |
| 2006 | |
| 2007 | VkFence fence; |
| 2008 | VkFenceCreateInfo fence_create_info{}; |
| 2009 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2010 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2011 | |
| 2012 | VkSemaphore semaphore; |
| 2013 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2014 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2015 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2016 | &semaphore); |
| 2017 | |
| 2018 | VkCommandPool command_pool; |
| 2019 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2020 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2021 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2022 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2023 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2024 | &command_pool); |
| 2025 | |
| 2026 | VkCommandBuffer command_buffer[2]; |
| 2027 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2028 | command_buffer_allocate_info.sType = |
| 2029 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2030 | command_buffer_allocate_info.commandPool = command_pool; |
| 2031 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2032 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2033 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2034 | command_buffer); |
| 2035 | |
| 2036 | { |
| 2037 | VkCommandBufferBeginInfo begin_info{}; |
| 2038 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2039 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2040 | |
| 2041 | vkCmdPipelineBarrier(command_buffer[0], |
| 2042 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2043 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2044 | 0, nullptr, 0, nullptr); |
| 2045 | |
| 2046 | VkViewport viewport{}; |
| 2047 | viewport.maxDepth = 1.0f; |
| 2048 | viewport.minDepth = 0.0f; |
| 2049 | viewport.width = 512; |
| 2050 | viewport.height = 512; |
| 2051 | viewport.x = 0; |
| 2052 | viewport.y = 0; |
| 2053 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2054 | vkEndCommandBuffer(command_buffer[0]); |
| 2055 | } |
| 2056 | { |
| 2057 | VkCommandBufferBeginInfo begin_info{}; |
| 2058 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2059 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2060 | |
| 2061 | VkViewport viewport{}; |
| 2062 | viewport.maxDepth = 1.0f; |
| 2063 | viewport.minDepth = 0.0f; |
| 2064 | viewport.width = 512; |
| 2065 | viewport.height = 512; |
| 2066 | viewport.x = 0; |
| 2067 | viewport.y = 0; |
| 2068 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2069 | vkEndCommandBuffer(command_buffer[1]); |
| 2070 | } |
| 2071 | { |
| 2072 | VkSubmitInfo submit_info{}; |
| 2073 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2074 | submit_info.commandBufferCount = 1; |
| 2075 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2076 | submit_info.signalSemaphoreCount = 1; |
| 2077 | submit_info.pSignalSemaphores = &semaphore; |
| 2078 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2079 | } |
| 2080 | { |
| 2081 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2082 | VkSubmitInfo submit_info{}; |
| 2083 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2084 | submit_info.commandBufferCount = 1; |
| 2085 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2086 | submit_info.waitSemaphoreCount = 1; |
| 2087 | submit_info.pWaitSemaphores = &semaphore; |
| 2088 | submit_info.pWaitDstStageMask = flags; |
| 2089 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2090 | } |
| 2091 | |
| 2092 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2093 | |
| 2094 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2095 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2096 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2097 | &command_buffer[0]); |
| 2098 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2099 | |
| 2100 | m_errorMonitor->VerifyNotFound(); |
| 2101 | } |
| 2102 | |
| 2103 | // This is a positive test. No errors should be generated. |
| 2104 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2105 | |
| 2106 | TEST_DESCRIPTION( |
| 2107 | "Two command buffers, each in a separate QueueSubmit call " |
| 2108 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2109 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2110 | |
| 2111 | m_errorMonitor->ExpectSuccess(); |
| 2112 | |
| 2113 | VkFence fence; |
| 2114 | VkFenceCreateInfo fence_create_info{}; |
| 2115 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2116 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2117 | |
| 2118 | VkCommandPool command_pool; |
| 2119 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2120 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2121 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2122 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2123 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2124 | &command_pool); |
| 2125 | |
| 2126 | VkCommandBuffer command_buffer[2]; |
| 2127 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2128 | command_buffer_allocate_info.sType = |
| 2129 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2130 | command_buffer_allocate_info.commandPool = command_pool; |
| 2131 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2132 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2133 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2134 | command_buffer); |
| 2135 | |
| 2136 | { |
| 2137 | VkCommandBufferBeginInfo begin_info{}; |
| 2138 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2139 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2140 | |
| 2141 | vkCmdPipelineBarrier(command_buffer[0], |
| 2142 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2143 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2144 | 0, nullptr, 0, nullptr); |
| 2145 | |
| 2146 | VkViewport viewport{}; |
| 2147 | viewport.maxDepth = 1.0f; |
| 2148 | viewport.minDepth = 0.0f; |
| 2149 | viewport.width = 512; |
| 2150 | viewport.height = 512; |
| 2151 | viewport.x = 0; |
| 2152 | viewport.y = 0; |
| 2153 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2154 | vkEndCommandBuffer(command_buffer[0]); |
| 2155 | } |
| 2156 | { |
| 2157 | VkCommandBufferBeginInfo begin_info{}; |
| 2158 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2159 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2160 | |
| 2161 | VkViewport viewport{}; |
| 2162 | viewport.maxDepth = 1.0f; |
| 2163 | viewport.minDepth = 0.0f; |
| 2164 | viewport.width = 512; |
| 2165 | viewport.height = 512; |
| 2166 | viewport.x = 0; |
| 2167 | viewport.y = 0; |
| 2168 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2169 | vkEndCommandBuffer(command_buffer[1]); |
| 2170 | } |
| 2171 | { |
| 2172 | VkSubmitInfo submit_info{}; |
| 2173 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2174 | submit_info.commandBufferCount = 1; |
| 2175 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2176 | submit_info.signalSemaphoreCount = 0; |
| 2177 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2178 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2179 | } |
| 2180 | { |
| 2181 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2182 | VkSubmitInfo submit_info{}; |
| 2183 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2184 | submit_info.commandBufferCount = 1; |
| 2185 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2186 | submit_info.waitSemaphoreCount = 0; |
| 2187 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2188 | submit_info.pWaitDstStageMask = flags; |
| 2189 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2190 | } |
| 2191 | |
| 2192 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2193 | |
| 2194 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2195 | |
| 2196 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2197 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2198 | &command_buffer[0]); |
| 2199 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2200 | |
| 2201 | m_errorMonitor->VerifyNotFound(); |
| 2202 | } |
| 2203 | |
| 2204 | // This is a positive test. No errors should be generated. |
| 2205 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2206 | |
| 2207 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2208 | "on the same queue, the second having a fence, followed " |
| 2209 | "by a WaitForFences call."); |
| 2210 | |
| 2211 | m_errorMonitor->ExpectSuccess(); |
| 2212 | |
| 2213 | VkFence fence; |
| 2214 | VkFenceCreateInfo fence_create_info{}; |
| 2215 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2216 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2217 | |
| 2218 | VkCommandPool command_pool; |
| 2219 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2220 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2221 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2222 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2223 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2224 | &command_pool); |
| 2225 | |
| 2226 | VkCommandBuffer command_buffer[2]; |
| 2227 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2228 | command_buffer_allocate_info.sType = |
| 2229 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2230 | command_buffer_allocate_info.commandPool = command_pool; |
| 2231 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2232 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2233 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2234 | command_buffer); |
| 2235 | |
| 2236 | { |
| 2237 | VkCommandBufferBeginInfo begin_info{}; |
| 2238 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2239 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2240 | |
| 2241 | vkCmdPipelineBarrier(command_buffer[0], |
| 2242 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2243 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2244 | 0, nullptr, 0, nullptr); |
| 2245 | |
| 2246 | VkViewport viewport{}; |
| 2247 | viewport.maxDepth = 1.0f; |
| 2248 | viewport.minDepth = 0.0f; |
| 2249 | viewport.width = 512; |
| 2250 | viewport.height = 512; |
| 2251 | viewport.x = 0; |
| 2252 | viewport.y = 0; |
| 2253 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2254 | vkEndCommandBuffer(command_buffer[0]); |
| 2255 | } |
| 2256 | { |
| 2257 | VkCommandBufferBeginInfo begin_info{}; |
| 2258 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2259 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2260 | |
| 2261 | VkViewport viewport{}; |
| 2262 | viewport.maxDepth = 1.0f; |
| 2263 | viewport.minDepth = 0.0f; |
| 2264 | viewport.width = 512; |
| 2265 | viewport.height = 512; |
| 2266 | viewport.x = 0; |
| 2267 | viewport.y = 0; |
| 2268 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2269 | vkEndCommandBuffer(command_buffer[1]); |
| 2270 | } |
| 2271 | { |
| 2272 | VkSubmitInfo submit_info{}; |
| 2273 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2274 | submit_info.commandBufferCount = 1; |
| 2275 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2276 | submit_info.signalSemaphoreCount = 0; |
| 2277 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2278 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2279 | } |
| 2280 | { |
| 2281 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2282 | VkSubmitInfo submit_info{}; |
| 2283 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2284 | submit_info.commandBufferCount = 1; |
| 2285 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2286 | submit_info.waitSemaphoreCount = 0; |
| 2287 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2288 | submit_info.pWaitDstStageMask = flags; |
| 2289 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2290 | } |
| 2291 | |
| 2292 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2293 | |
| 2294 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2295 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2296 | &command_buffer[0]); |
| 2297 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2298 | |
| 2299 | m_errorMonitor->VerifyNotFound(); |
| 2300 | } |
| 2301 | |
| 2302 | // This is a positive test. No errors should be generated. |
| 2303 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2304 | |
| 2305 | TEST_DESCRIPTION( |
| 2306 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2307 | "QueueSubmit call followed by a WaitForFences call."); |
| 2308 | |
| 2309 | m_errorMonitor->ExpectSuccess(); |
| 2310 | |
| 2311 | VkFence fence; |
| 2312 | VkFenceCreateInfo fence_create_info{}; |
| 2313 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2314 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2315 | |
| 2316 | VkSemaphore semaphore; |
| 2317 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2318 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2319 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2320 | &semaphore); |
| 2321 | |
| 2322 | VkCommandPool command_pool; |
| 2323 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2324 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2325 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2326 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2327 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2328 | &command_pool); |
| 2329 | |
| 2330 | VkCommandBuffer command_buffer[2]; |
| 2331 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2332 | command_buffer_allocate_info.sType = |
| 2333 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2334 | command_buffer_allocate_info.commandPool = command_pool; |
| 2335 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2336 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2337 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2338 | command_buffer); |
| 2339 | |
| 2340 | { |
| 2341 | VkCommandBufferBeginInfo begin_info{}; |
| 2342 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2343 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2344 | |
| 2345 | vkCmdPipelineBarrier(command_buffer[0], |
| 2346 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2347 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2348 | 0, nullptr, 0, nullptr); |
| 2349 | |
| 2350 | VkViewport viewport{}; |
| 2351 | viewport.maxDepth = 1.0f; |
| 2352 | viewport.minDepth = 0.0f; |
| 2353 | viewport.width = 512; |
| 2354 | viewport.height = 512; |
| 2355 | viewport.x = 0; |
| 2356 | viewport.y = 0; |
| 2357 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2358 | vkEndCommandBuffer(command_buffer[0]); |
| 2359 | } |
| 2360 | { |
| 2361 | VkCommandBufferBeginInfo begin_info{}; |
| 2362 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2363 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2364 | |
| 2365 | VkViewport viewport{}; |
| 2366 | viewport.maxDepth = 1.0f; |
| 2367 | viewport.minDepth = 0.0f; |
| 2368 | viewport.width = 512; |
| 2369 | viewport.height = 512; |
| 2370 | viewport.x = 0; |
| 2371 | viewport.y = 0; |
| 2372 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2373 | vkEndCommandBuffer(command_buffer[1]); |
| 2374 | } |
| 2375 | { |
| 2376 | VkSubmitInfo submit_info[2]; |
| 2377 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2378 | |
| 2379 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2380 | submit_info[0].pNext = NULL; |
| 2381 | submit_info[0].commandBufferCount = 1; |
| 2382 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2383 | submit_info[0].signalSemaphoreCount = 1; |
| 2384 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2385 | submit_info[0].waitSemaphoreCount = 0; |
| 2386 | submit_info[0].pWaitSemaphores = NULL; |
| 2387 | submit_info[0].pWaitDstStageMask = 0; |
| 2388 | |
| 2389 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2390 | submit_info[1].pNext = NULL; |
| 2391 | submit_info[1].commandBufferCount = 1; |
| 2392 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2393 | submit_info[1].waitSemaphoreCount = 1; |
| 2394 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2395 | submit_info[1].pWaitDstStageMask = flags; |
| 2396 | submit_info[1].signalSemaphoreCount = 0; |
| 2397 | submit_info[1].pSignalSemaphores = NULL; |
| 2398 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2399 | } |
| 2400 | |
| 2401 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2402 | |
| 2403 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2404 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2405 | &command_buffer[0]); |
| 2406 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2407 | |
| 2408 | m_errorMonitor->VerifyNotFound(); |
| 2409 | } |
| 2410 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2411 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2412 | TEST_DESCRIPTION( |
| 2413 | "Run a series of simple draw calls to validate all the different " |
| 2414 | "failure cases that can occur when dynamic state is required but not " |
| 2415 | "correctly bound." |
| 2416 | "Here are the different dynamic state cases verified by this test:\n" |
| 2417 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2418 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2419 | "Mask\n-Stencil Reference"); |
| 2420 | |
| 2421 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2422 | m_errorMonitor->SetDesiredFailureMsg( |
| 2423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2424 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2425 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2426 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2427 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2428 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2429 | m_errorMonitor->SetDesiredFailureMsg( |
| 2430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2431 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2432 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2433 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2434 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2435 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2436 | m_errorMonitor->SetDesiredFailureMsg( |
| 2437 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2438 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2439 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2440 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2441 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2442 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2443 | m_errorMonitor->SetDesiredFailureMsg( |
| 2444 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2445 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2446 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2447 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2448 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2449 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2450 | m_errorMonitor->SetDesiredFailureMsg( |
| 2451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2452 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2453 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2454 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2455 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2456 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2457 | m_errorMonitor->SetDesiredFailureMsg( |
| 2458 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2459 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2460 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2461 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2462 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2463 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2464 | m_errorMonitor->SetDesiredFailureMsg( |
| 2465 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2466 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2467 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2468 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2469 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2470 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2471 | m_errorMonitor->SetDesiredFailureMsg( |
| 2472 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2473 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2474 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2475 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2476 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2477 | } |
| 2478 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2479 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2480 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2481 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2482 | m_errorMonitor->SetDesiredFailureMsg( |
| 2483 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2484 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2485 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2486 | |
| 2487 | VkFenceCreateInfo fenceInfo = {}; |
| 2488 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2489 | fenceInfo.pNext = NULL; |
| 2490 | fenceInfo.flags = 0; |
| 2491 | |
| 2492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2493 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2496 | // We luck out b/c by default the framework creates CB w/ the |
| 2497 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2498 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2499 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2500 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2501 | EndCommandBuffer(); |
| 2502 | |
| 2503 | testFence.init(*m_device, fenceInfo); |
| 2504 | |
| 2505 | // Bypass framework since it does the waits automatically |
| 2506 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2507 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2508 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2509 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2510 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2511 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2512 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2513 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2514 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2515 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2516 | submit_info.pSignalSemaphores = NULL; |
| 2517 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2518 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2519 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2521 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2522 | // submitted once |
| 2523 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2524 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2525 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2526 | } |
| 2527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2529 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2530 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2531 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2532 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2533 | "Unable to allocate 1 descriptors of " |
| 2534 | "type " |
| 2535 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2536 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2538 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2539 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2540 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2541 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2542 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2543 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2544 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2545 | |
| 2546 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2547 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2548 | ds_pool_ci.pNext = NULL; |
| 2549 | ds_pool_ci.flags = 0; |
| 2550 | ds_pool_ci.maxSets = 1; |
| 2551 | ds_pool_ci.poolSizeCount = 1; |
| 2552 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2553 | |
| 2554 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2555 | err = |
| 2556 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2557 | ASSERT_VK_SUCCESS(err); |
| 2558 | |
| 2559 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2560 | dsl_binding.binding = 0; |
| 2561 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2562 | dsl_binding.descriptorCount = 1; |
| 2563 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2564 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2565 | |
| 2566 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2567 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2568 | ds_layout_ci.pNext = NULL; |
| 2569 | ds_layout_ci.bindingCount = 1; |
| 2570 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2571 | |
| 2572 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2573 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2574 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2575 | ASSERT_VK_SUCCESS(err); |
| 2576 | |
| 2577 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2578 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2579 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2580 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2581 | alloc_info.descriptorPool = ds_pool; |
| 2582 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2583 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2584 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2585 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2586 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2587 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2588 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2589 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2590 | } |
| 2591 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2592 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2593 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2595 | m_errorMonitor->SetDesiredFailureMsg( |
| 2596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2597 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2598 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2599 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2600 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2601 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2602 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2603 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2604 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2605 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2606 | |
| 2607 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2608 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2609 | ds_pool_ci.pNext = NULL; |
| 2610 | ds_pool_ci.maxSets = 1; |
| 2611 | ds_pool_ci.poolSizeCount = 1; |
| 2612 | ds_pool_ci.flags = 0; |
| 2613 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2614 | // app can only call vkResetDescriptorPool on this pool.; |
| 2615 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2616 | |
| 2617 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2618 | err = |
| 2619 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2620 | ASSERT_VK_SUCCESS(err); |
| 2621 | |
| 2622 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2623 | dsl_binding.binding = 0; |
| 2624 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2625 | dsl_binding.descriptorCount = 1; |
| 2626 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2627 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2628 | |
| 2629 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2630 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2631 | ds_layout_ci.pNext = NULL; |
| 2632 | ds_layout_ci.bindingCount = 1; |
| 2633 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2634 | |
| 2635 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2636 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2637 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2638 | ASSERT_VK_SUCCESS(err); |
| 2639 | |
| 2640 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2641 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2642 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2643 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2644 | alloc_info.descriptorPool = ds_pool; |
| 2645 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2647 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2648 | ASSERT_VK_SUCCESS(err); |
| 2649 | |
| 2650 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2651 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2652 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2653 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2654 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2655 | } |
| 2656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2658 | // Attempt to clear Descriptor Pool with bad object. |
| 2659 | // ObjectTracker should catch this. |
| 2660 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2661 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 2662 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 2663 | vkResetDescriptorPool(device(), badPool, 0); |
| 2664 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2665 | } |
| 2666 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2667 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2668 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2669 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2670 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2671 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 2672 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 2673 | VkResult err; |
| 2674 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2675 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2676 | |
| 2677 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2678 | |
| 2679 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2680 | layout_bindings[0].binding = 0; |
| 2681 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2682 | layout_bindings[0].descriptorCount = 1; |
| 2683 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2684 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2685 | |
| 2686 | VkDescriptorSetLayout descriptor_set_layout; |
| 2687 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2688 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2689 | dslci.pNext = NULL; |
| 2690 | dslci.bindingCount = 1; |
| 2691 | dslci.pBindings = layout_bindings; |
| 2692 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2693 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2694 | |
| 2695 | VkPipelineLayout pipeline_layout; |
| 2696 | VkPipelineLayoutCreateInfo plci = {}; |
| 2697 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2698 | plci.pNext = NULL; |
| 2699 | plci.setLayoutCount = 1; |
| 2700 | plci.pSetLayouts = &descriptor_set_layout; |
| 2701 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2702 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2703 | |
| 2704 | BeginCommandBuffer(); |
| 2705 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2706 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 2707 | m_errorMonitor->VerifyFound(); |
| 2708 | EndCommandBuffer(); |
| 2709 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 2710 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2711 | } |
| 2712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2713 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2714 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 2715 | // ObjectTracker should catch this. |
| 2716 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 2717 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2718 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 2719 | |
| 2720 | VkPipelineLayout pipeline_layout; |
| 2721 | VkPipelineLayoutCreateInfo plci = {}; |
| 2722 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2723 | plci.pNext = NULL; |
| 2724 | plci.setLayoutCount = 1; |
| 2725 | plci.pSetLayouts = &bad_layout; |
| 2726 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 2727 | |
| 2728 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2729 | } |
| 2730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2732 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 2733 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2734 | // Create a valid cmd buffer |
| 2735 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2736 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 2737 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2738 | "Invalid VkPipeline Object 0xbaad6001"); |
| 2739 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2740 | BeginCommandBuffer(); |
| 2741 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2742 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 2743 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 2744 | |
| 2745 | // Now issue a draw call with no pipeline bound |
| 2746 | m_errorMonitor->SetDesiredFailureMsg( |
| 2747 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2748 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2750 | BeginCommandBuffer(); |
| 2751 | Draw(1, 0, 0, 0); |
| 2752 | m_errorMonitor->VerifyFound(); |
| 2753 | // Finally same check once more but with Dispatch/Compute |
| 2754 | m_errorMonitor->SetDesiredFailureMsg( |
| 2755 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2756 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2758 | BeginCommandBuffer(); |
| 2759 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 2760 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2761 | } |
| 2762 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2763 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 2764 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 2765 | // CommandBuffer |
| 2766 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2767 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2768 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2770 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2771 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2772 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2773 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2774 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2775 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2776 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2777 | |
| 2778 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2779 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2780 | ds_pool_ci.pNext = NULL; |
| 2781 | ds_pool_ci.maxSets = 1; |
| 2782 | ds_pool_ci.poolSizeCount = 1; |
| 2783 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2784 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2785 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | err = |
| 2787 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2788 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2789 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2790 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2791 | dsl_binding.binding = 0; |
| 2792 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2793 | dsl_binding.descriptorCount = 1; |
| 2794 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2795 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2796 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2797 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2799 | ds_layout_ci.pNext = NULL; |
| 2800 | ds_layout_ci.bindingCount = 1; |
| 2801 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2802 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2803 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2804 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2805 | ASSERT_VK_SUCCESS(err); |
| 2806 | |
| 2807 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2808 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2809 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2810 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2811 | alloc_info.descriptorPool = ds_pool; |
| 2812 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2813 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2814 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2815 | ASSERT_VK_SUCCESS(err); |
| 2816 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2817 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2818 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2819 | pipeline_layout_ci.pNext = NULL; |
| 2820 | pipeline_layout_ci.setLayoutCount = 1; |
| 2821 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2822 | |
| 2823 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2824 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2825 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2826 | ASSERT_VK_SUCCESS(err); |
| 2827 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2828 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2829 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2830 | // 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] | 2831 | // on more devices |
| 2832 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2833 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2834 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2835 | VkPipelineObj pipe(m_device); |
| 2836 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2837 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 2838 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2839 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2840 | |
| 2841 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2842 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2843 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2844 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2845 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2846 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2847 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2848 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2849 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2850 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2851 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2852 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2853 | } |
| 2854 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2855 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2856 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2857 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2858 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2859 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 2860 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 2861 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2862 | |
| 2863 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2864 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2866 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2867 | |
| 2868 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2869 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2870 | ds_pool_ci.pNext = NULL; |
| 2871 | ds_pool_ci.maxSets = 1; |
| 2872 | ds_pool_ci.poolSizeCount = 1; |
| 2873 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2874 | |
| 2875 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2876 | err = |
| 2877 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2878 | ASSERT_VK_SUCCESS(err); |
| 2879 | |
| 2880 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2881 | dsl_binding.binding = 0; |
| 2882 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2883 | dsl_binding.descriptorCount = 1; |
| 2884 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2885 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2886 | |
| 2887 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2889 | ds_layout_ci.pNext = NULL; |
| 2890 | ds_layout_ci.bindingCount = 1; |
| 2891 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2892 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2893 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2894 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2895 | ASSERT_VK_SUCCESS(err); |
| 2896 | |
| 2897 | VkDescriptorSet descriptorSet; |
| 2898 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2899 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2900 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2901 | alloc_info.descriptorPool = ds_pool; |
| 2902 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2904 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
| 2906 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2907 | VkBufferView view = |
| 2908 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2909 | VkWriteDescriptorSet descriptor_write; |
| 2910 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2911 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2912 | descriptor_write.dstSet = descriptorSet; |
| 2913 | descriptor_write.dstBinding = 0; |
| 2914 | descriptor_write.descriptorCount = 1; |
| 2915 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2916 | descriptor_write.pTexelBufferView = &view; |
| 2917 | |
| 2918 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2919 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2920 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2921 | |
| 2922 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2923 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2924 | } |
| 2925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2926 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 2927 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 2928 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2929 | // 1. No dynamicOffset supplied |
| 2930 | // 2. Too many dynamicOffsets supplied |
| 2931 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2932 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2933 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2934 | " requires 1 dynamicOffsets, but only " |
| 2935 | "0 dynamicOffsets are left in " |
| 2936 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2937 | |
| 2938 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2939 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2940 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2941 | |
| 2942 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2943 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 2944 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2945 | |
| 2946 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2947 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2948 | ds_pool_ci.pNext = NULL; |
| 2949 | ds_pool_ci.maxSets = 1; |
| 2950 | ds_pool_ci.poolSizeCount = 1; |
| 2951 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2952 | |
| 2953 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2954 | err = |
| 2955 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2956 | ASSERT_VK_SUCCESS(err); |
| 2957 | |
| 2958 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2959 | dsl_binding.binding = 0; |
| 2960 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 2961 | dsl_binding.descriptorCount = 1; |
| 2962 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2963 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2964 | |
| 2965 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2966 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2967 | ds_layout_ci.pNext = NULL; |
| 2968 | ds_layout_ci.bindingCount = 1; |
| 2969 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2970 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2971 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2972 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2973 | ASSERT_VK_SUCCESS(err); |
| 2974 | |
| 2975 | VkDescriptorSet descriptorSet; |
| 2976 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2977 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2978 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2979 | alloc_info.descriptorPool = ds_pool; |
| 2980 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2981 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2982 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2983 | ASSERT_VK_SUCCESS(err); |
| 2984 | |
| 2985 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2986 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2987 | pipeline_layout_ci.pNext = NULL; |
| 2988 | pipeline_layout_ci.setLayoutCount = 1; |
| 2989 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2990 | |
| 2991 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2992 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2993 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2994 | ASSERT_VK_SUCCESS(err); |
| 2995 | |
| 2996 | // Create a buffer to update the descriptor with |
| 2997 | uint32_t qfi = 0; |
| 2998 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2999 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3000 | buffCI.size = 1024; |
| 3001 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3002 | buffCI.queueFamilyIndexCount = 1; |
| 3003 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3004 | |
| 3005 | VkBuffer dyub; |
| 3006 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3007 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3008 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3009 | // error |
| 3010 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3011 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3012 | mem_alloc.pNext = NULL; |
| 3013 | mem_alloc.allocationSize = 1024; |
| 3014 | mem_alloc.memoryTypeIndex = 1; |
| 3015 | VkDeviceMemory mem; |
| 3016 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3017 | ASSERT_VK_SUCCESS(err); |
| 3018 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3019 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3020 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3021 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3022 | buffInfo.buffer = dyub; |
| 3023 | buffInfo.offset = 0; |
| 3024 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3025 | |
| 3026 | VkWriteDescriptorSet descriptor_write; |
| 3027 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3028 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3029 | descriptor_write.dstSet = descriptorSet; |
| 3030 | descriptor_write.dstBinding = 0; |
| 3031 | descriptor_write.descriptorCount = 1; |
| 3032 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3033 | descriptor_write.pBufferInfo = &buffInfo; |
| 3034 | |
| 3035 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3036 | |
| 3037 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3038 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3039 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3040 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3041 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3042 | uint32_t pDynOff[2] = {512, 756}; |
| 3043 | // 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] | 3044 | m_errorMonitor->SetDesiredFailureMsg( |
| 3045 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3046 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3047 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3048 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3049 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3050 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3051 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3052 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3053 | " dynamic offset 512 combined with " |
| 3054 | "offset 0 and range 1024 that " |
| 3055 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3056 | // Create PSO to be used for draw-time errors below |
| 3057 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3058 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3059 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3060 | "out gl_PerVertex { \n" |
| 3061 | " vec4 gl_Position;\n" |
| 3062 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3063 | "void main(){\n" |
| 3064 | " gl_Position = vec4(1);\n" |
| 3065 | "}\n"; |
| 3066 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3067 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3068 | "\n" |
| 3069 | "layout(location=0) out vec4 x;\n" |
| 3070 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3071 | "void main(){\n" |
| 3072 | " x = vec4(bar.y);\n" |
| 3073 | "}\n"; |
| 3074 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3075 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3076 | VkPipelineObj pipe(m_device); |
| 3077 | pipe.AddShader(&vs); |
| 3078 | pipe.AddShader(&fs); |
| 3079 | pipe.AddColorAttachment(); |
| 3080 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3081 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3082 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3083 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3084 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3085 | // /w range 1024 & size 1024 |
| 3086 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3087 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3088 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3089 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3090 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3091 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3092 | vkFreeMemory(m_device->device(), mem, NULL); |
| 3093 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3094 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3095 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3096 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3097 | } |
| 3098 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3099 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3100 | // Hit push constant error cases: |
| 3101 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3102 | // 2. Incorrectly set push constant size to 0 |
| 3103 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3104 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3105 | VkResult err; |
| 3106 | m_errorMonitor->SetDesiredFailureMsg( |
| 3107 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3108 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3109 | |
| 3110 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3111 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3112 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3113 | |
| 3114 | VkPushConstantRange pc_range = {}; |
| 3115 | pc_range.size = 0xFFFFFFFFu; |
| 3116 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3117 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3118 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3119 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3120 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3121 | |
| 3122 | VkPipelineLayout pipeline_layout; |
| 3123 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3124 | &pipeline_layout); |
| 3125 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3126 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3127 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3128 | pc_range.size = 0; |
| 3129 | m_errorMonitor->SetDesiredFailureMsg( |
| 3130 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3131 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3132 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3133 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3134 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3135 | pc_range.size = 1; |
| 3136 | m_errorMonitor->SetDesiredFailureMsg( |
| 3137 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3138 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3139 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3140 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3141 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3142 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3143 | m_errorMonitor->SetDesiredFailureMsg( |
| 3144 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3145 | "vkCmdPushConstants() call has push constants with offset "); |
| 3146 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3147 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3148 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3149 | &pipeline_layout); |
| 3150 | ASSERT_VK_SUCCESS(err); |
| 3151 | BeginCommandBuffer(); |
| 3152 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3153 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3154 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3155 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3156 | } |
| 3157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3158 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3159 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3160 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3161 | |
| 3162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3163 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3164 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3165 | |
| 3166 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3167 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3168 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3169 | ds_type_count[0].descriptorCount = 10; |
| 3170 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3171 | ds_type_count[1].descriptorCount = 2; |
| 3172 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3173 | ds_type_count[2].descriptorCount = 2; |
| 3174 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3175 | ds_type_count[3].descriptorCount = 5; |
| 3176 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3177 | // type |
| 3178 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3179 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3180 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3181 | |
| 3182 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3183 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3184 | ds_pool_ci.pNext = NULL; |
| 3185 | ds_pool_ci.maxSets = 5; |
| 3186 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3187 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3188 | |
| 3189 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3190 | err = |
| 3191 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3192 | ASSERT_VK_SUCCESS(err); |
| 3193 | |
| 3194 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3195 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3196 | dsl_binding[0].binding = 0; |
| 3197 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3198 | dsl_binding[0].descriptorCount = 5; |
| 3199 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3200 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3201 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3202 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3203 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3204 | dsl_fs_stage_only.binding = 0; |
| 3205 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3206 | dsl_fs_stage_only.descriptorCount = 5; |
| 3207 | dsl_fs_stage_only.stageFlags = |
| 3208 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3209 | // bind time |
| 3210 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3211 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3212 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3213 | ds_layout_ci.pNext = NULL; |
| 3214 | ds_layout_ci.bindingCount = 1; |
| 3215 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3216 | static const uint32_t NUM_LAYOUTS = 4; |
| 3217 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3218 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3219 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3220 | // layout for error case |
| 3221 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3222 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3223 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3224 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3225 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3226 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3227 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3228 | dsl_binding[0].binding = 0; |
| 3229 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3230 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3231 | dsl_binding[1].binding = 1; |
| 3232 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3233 | dsl_binding[1].descriptorCount = 2; |
| 3234 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3235 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3236 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3237 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3238 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3239 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3240 | ASSERT_VK_SUCCESS(err); |
| 3241 | dsl_binding[0].binding = 0; |
| 3242 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3243 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3244 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3245 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3246 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3247 | ASSERT_VK_SUCCESS(err); |
| 3248 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3249 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3250 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3251 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3252 | ASSERT_VK_SUCCESS(err); |
| 3253 | |
| 3254 | static const uint32_t NUM_SETS = 4; |
| 3255 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3256 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3257 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3258 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3259 | alloc_info.descriptorPool = ds_pool; |
| 3260 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3261 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3262 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3263 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3264 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3265 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3266 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3267 | err = |
| 3268 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3269 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3270 | |
| 3271 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3272 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3273 | pipeline_layout_ci.pNext = NULL; |
| 3274 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3275 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3276 | |
| 3277 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3278 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3279 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3280 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3281 | // Create pipelineLayout with only one setLayout |
| 3282 | pipeline_layout_ci.setLayoutCount = 1; |
| 3283 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3284 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3285 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3286 | ASSERT_VK_SUCCESS(err); |
| 3287 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3288 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3289 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3290 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3291 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3292 | ASSERT_VK_SUCCESS(err); |
| 3293 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3294 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3295 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3296 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3297 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3298 | ASSERT_VK_SUCCESS(err); |
| 3299 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3300 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3301 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3302 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3303 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3304 | ASSERT_VK_SUCCESS(err); |
| 3305 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3306 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3307 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3308 | pl_bad_s0[1] = ds_layout[1]; |
| 3309 | pipeline_layout_ci.setLayoutCount = 2; |
| 3310 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3311 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3312 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3313 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3314 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3315 | |
| 3316 | // Create a buffer to update the descriptor with |
| 3317 | uint32_t qfi = 0; |
| 3318 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3319 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3320 | buffCI.size = 1024; |
| 3321 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3322 | buffCI.queueFamilyIndexCount = 1; |
| 3323 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3324 | |
| 3325 | VkBuffer dyub; |
| 3326 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3327 | ASSERT_VK_SUCCESS(err); |
| 3328 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3329 | static const uint32_t NUM_BUFFS = 5; |
| 3330 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3331 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3332 | buffInfo[i].buffer = dyub; |
| 3333 | buffInfo[i].offset = 0; |
| 3334 | buffInfo[i].range = 1024; |
| 3335 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3336 | VkImage image; |
| 3337 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3338 | const int32_t tex_width = 32; |
| 3339 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3340 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3341 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3342 | image_create_info.pNext = NULL; |
| 3343 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3344 | image_create_info.format = tex_format; |
| 3345 | image_create_info.extent.width = tex_width; |
| 3346 | image_create_info.extent.height = tex_height; |
| 3347 | image_create_info.extent.depth = 1; |
| 3348 | image_create_info.mipLevels = 1; |
| 3349 | image_create_info.arrayLayers = 1; |
| 3350 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3351 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3352 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3353 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3354 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3355 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3357 | VkMemoryRequirements memReqs; |
| 3358 | VkDeviceMemory imageMem; |
| 3359 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3360 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3361 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3362 | memAlloc.pNext = NULL; |
| 3363 | memAlloc.allocationSize = 0; |
| 3364 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3365 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3366 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3367 | pass = |
| 3368 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3369 | ASSERT_TRUE(pass); |
| 3370 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3371 | ASSERT_VK_SUCCESS(err); |
| 3372 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3373 | ASSERT_VK_SUCCESS(err); |
| 3374 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3375 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3376 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3377 | image_view_create_info.image = image; |
| 3378 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3379 | image_view_create_info.format = tex_format; |
| 3380 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3381 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3382 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3383 | image_view_create_info.subresourceRange.aspectMask = |
| 3384 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3385 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3386 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3387 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3388 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3389 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3390 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3391 | imageInfo[0].imageView = view; |
| 3392 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3393 | imageInfo[1].imageView = view; |
| 3394 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3395 | imageInfo[2].imageView = view; |
| 3396 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3397 | imageInfo[3].imageView = view; |
| 3398 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3399 | |
| 3400 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3401 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3402 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3403 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3404 | descriptor_write[0].dstBinding = 0; |
| 3405 | descriptor_write[0].descriptorCount = 5; |
| 3406 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3407 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3408 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3409 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3410 | descriptor_write[1].dstBinding = 0; |
| 3411 | descriptor_write[1].descriptorCount = 2; |
| 3412 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3413 | descriptor_write[1].pImageInfo = imageInfo; |
| 3414 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3415 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3416 | descriptor_write[2].dstBinding = 1; |
| 3417 | descriptor_write[2].descriptorCount = 2; |
| 3418 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3419 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3420 | |
| 3421 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3422 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3423 | // Create PSO to be used for draw-time errors below |
| 3424 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3425 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3426 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3427 | "out gl_PerVertex {\n" |
| 3428 | " vec4 gl_Position;\n" |
| 3429 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3430 | "void main(){\n" |
| 3431 | " gl_Position = vec4(1);\n" |
| 3432 | "}\n"; |
| 3433 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3434 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3435 | "\n" |
| 3436 | "layout(location=0) out vec4 x;\n" |
| 3437 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3438 | "void main(){\n" |
| 3439 | " x = vec4(bar.y);\n" |
| 3440 | "}\n"; |
| 3441 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3442 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3443 | VkPipelineObj pipe(m_device); |
| 3444 | pipe.AddShader(&vs); |
| 3445 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3446 | pipe.AddColorAttachment(); |
| 3447 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3448 | |
| 3449 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3451 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3452 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3453 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3454 | // of PSO |
| 3455 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3456 | // cmd_pipeline.c |
| 3457 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3458 | // cmd_bind_graphics_pipeline() |
| 3459 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3460 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3461 | // First cause various verify_layout_compatibility() fails |
| 3462 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3463 | // verify_set_layout_compatibility fail cases: |
| 3464 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3465 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3466 | " due to: invalid VkPipelineLayout "); |
| 3467 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3468 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3469 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3470 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3471 | m_errorMonitor->VerifyFound(); |
| 3472 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3473 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3474 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3475 | " attempting to bind set to index 1"); |
| 3476 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3477 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3478 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3479 | m_errorMonitor->VerifyFound(); |
| 3480 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3481 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3482 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3483 | // descriptors |
| 3484 | m_errorMonitor->SetDesiredFailureMsg( |
| 3485 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3486 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3487 | vkCmdBindDescriptorSets( |
| 3488 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3489 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3490 | m_errorMonitor->VerifyFound(); |
| 3491 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3492 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3493 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3494 | m_errorMonitor->SetDesiredFailureMsg( |
| 3495 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3496 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3497 | vkCmdBindDescriptorSets( |
| 3498 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3499 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3500 | m_errorMonitor->VerifyFound(); |
| 3501 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3502 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3503 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3504 | m_errorMonitor->SetDesiredFailureMsg( |
| 3505 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3506 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3507 | vkCmdBindDescriptorSets( |
| 3508 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3509 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3510 | m_errorMonitor->VerifyFound(); |
| 3511 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3512 | // Cause INFO messages due to disturbing previously bound Sets |
| 3513 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3514 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3515 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3516 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3517 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3518 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3519 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3520 | " previously bound as set #0 was disturbed "); |
| 3521 | vkCmdBindDescriptorSets( |
| 3522 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3523 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3524 | m_errorMonitor->VerifyFound(); |
| 3525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3527 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3528 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3529 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3530 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3531 | " newly bound as set #0 so set #1 and " |
| 3532 | "any subsequent sets were disturbed "); |
| 3533 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3534 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3535 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3536 | m_errorMonitor->VerifyFound(); |
| 3537 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3538 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3539 | // 1. Error due to not binding required set (we actually use same code as |
| 3540 | // above to disturb set0) |
| 3541 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3542 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3543 | 2, &descriptorSet[0], 0, NULL); |
| 3544 | vkCmdBindDescriptorSets( |
| 3545 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3546 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3547 | m_errorMonitor->SetDesiredFailureMsg( |
| 3548 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3549 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3550 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3551 | m_errorMonitor->VerifyFound(); |
| 3552 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3553 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3554 | // 2. Error due to bound set not being compatible with PSO's |
| 3555 | // VkPipelineLayout (diff stageFlags in this case) |
| 3556 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3557 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3558 | 2, &descriptorSet[0], 0, NULL); |
| 3559 | m_errorMonitor->SetDesiredFailureMsg( |
| 3560 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3561 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3562 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3563 | m_errorMonitor->VerifyFound(); |
| 3564 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3565 | // Remaining clean-up |
| 3566 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3567 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3568 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3569 | } |
| 3570 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 3571 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 3572 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3573 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3574 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3575 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3576 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3577 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3579 | m_errorMonitor->SetDesiredFailureMsg( |
| 3580 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3581 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3582 | |
| 3583 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3584 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3585 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3586 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3587 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3588 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3589 | } |
| 3590 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3591 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3592 | VkResult err; |
| 3593 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3595 | m_errorMonitor->SetDesiredFailureMsg( |
| 3596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3597 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3598 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3599 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3600 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3601 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3602 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3603 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3604 | cmd.commandPool = m_commandPool; |
| 3605 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3606 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3607 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3608 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3609 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3610 | |
| 3611 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3612 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3613 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3614 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3615 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3617 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3618 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3619 | |
| 3620 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3621 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3623 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3624 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3625 | } |
| 3626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3627 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3628 | // Cause error due to Begin while recording CB |
| 3629 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3630 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3631 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3632 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3633 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3634 | |
| 3635 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3636 | |
| 3637 | // Calls AllocateCommandBuffers |
| 3638 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3640 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3641 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3642 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3643 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3644 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3645 | cmd_buf_info.pNext = NULL; |
| 3646 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3647 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3648 | |
| 3649 | // Begin CB to transition to recording state |
| 3650 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3651 | // Can't re-begin. This should trigger error |
| 3652 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3653 | m_errorMonitor->VerifyFound(); |
| 3654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3655 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3656 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3657 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3658 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3659 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3660 | m_errorMonitor->VerifyFound(); |
| 3661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3662 | m_errorMonitor->SetDesiredFailureMsg( |
| 3663 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3664 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3665 | // Transition CB to RECORDED state |
| 3666 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3667 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3668 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3669 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3670 | } |
| 3671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3672 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3673 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3674 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3676 | m_errorMonitor->SetDesiredFailureMsg( |
| 3677 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3678 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3679 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3680 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3682 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3683 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3684 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3685 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3686 | |
| 3687 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3689 | ds_pool_ci.pNext = NULL; |
| 3690 | ds_pool_ci.maxSets = 1; |
| 3691 | ds_pool_ci.poolSizeCount = 1; |
| 3692 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3693 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3694 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3695 | err = |
| 3696 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
| 3698 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3699 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3700 | dsl_binding.binding = 0; |
| 3701 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3702 | dsl_binding.descriptorCount = 1; |
| 3703 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3704 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3705 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3706 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3707 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3708 | ds_layout_ci.pNext = NULL; |
| 3709 | ds_layout_ci.bindingCount = 1; |
| 3710 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3711 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3712 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3713 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3714 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3715 | ASSERT_VK_SUCCESS(err); |
| 3716 | |
| 3717 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3718 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3719 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3720 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3721 | alloc_info.descriptorPool = ds_pool; |
| 3722 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3723 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3724 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3725 | ASSERT_VK_SUCCESS(err); |
| 3726 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3727 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3728 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3729 | pipeline_layout_ci.setLayoutCount = 1; |
| 3730 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3731 | |
| 3732 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3733 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3734 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3735 | ASSERT_VK_SUCCESS(err); |
| 3736 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3737 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3738 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3739 | |
| 3740 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3741 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3742 | vp_state_ci.scissorCount = 1; |
| 3743 | vp_state_ci.pScissors = ≻ |
| 3744 | vp_state_ci.viewportCount = 1; |
| 3745 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3746 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3747 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3748 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3749 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3750 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3751 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3752 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3753 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3754 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3755 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3756 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3757 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3758 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3759 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3760 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3761 | gp_ci.layout = pipeline_layout; |
| 3762 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3763 | |
| 3764 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3765 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3766 | pc_ci.initialDataSize = 0; |
| 3767 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3768 | |
| 3769 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3770 | VkPipelineCache pipelineCache; |
| 3771 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3772 | err = |
| 3773 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3774 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3775 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3776 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3777 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3778 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3779 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3780 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3781 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3782 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3783 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3784 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3785 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 3786 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 3787 | { |
| 3788 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3789 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3790 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3791 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3792 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 3793 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3794 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3795 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3796 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3797 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3798 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3799 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3800 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3801 | |
| 3802 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3803 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3804 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3805 | ds_pool_ci.poolSizeCount = 1; |
| 3806 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3807 | |
| 3808 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3809 | err = vkCreateDescriptorPool(m_device->device(), |
| 3810 | 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] | 3811 | ASSERT_VK_SUCCESS(err); |
| 3812 | |
| 3813 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3814 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3815 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3816 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3817 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3818 | dsl_binding.pImmutableSamplers = NULL; |
| 3819 | |
| 3820 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3821 | ds_layout_ci.sType = |
| 3822 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3823 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3824 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3825 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3826 | |
| 3827 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3828 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3829 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3830 | ASSERT_VK_SUCCESS(err); |
| 3831 | |
| 3832 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 3834 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3835 | ASSERT_VK_SUCCESS(err); |
| 3836 | |
| 3837 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3838 | pipeline_layout_ci.sType = |
| 3839 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3840 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3841 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3842 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3843 | |
| 3844 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3845 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3846 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3847 | ASSERT_VK_SUCCESS(err); |
| 3848 | |
| 3849 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 3850 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3851 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3852 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 3853 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3854 | // 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] | 3855 | VkShaderObj |
| 3856 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 3857 | this); |
| 3858 | VkShaderObj |
| 3859 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 3860 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3862 | shaderStages[0].sType = |
| 3863 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3864 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3865 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3866 | shaderStages[1].sType = |
| 3867 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3868 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3869 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3870 | shaderStages[2].sType = |
| 3871 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3872 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3873 | shaderStages[2].shader = te.handle(); |
| 3874 | |
| 3875 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3876 | iaCI.sType = |
| 3877 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3878 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3879 | |
| 3880 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 3881 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 3882 | tsCI.patchControlPoints = 0; // This will cause an error |
| 3883 | |
| 3884 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3885 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3886 | gp_ci.pNext = NULL; |
| 3887 | gp_ci.stageCount = 3; |
| 3888 | gp_ci.pStages = shaderStages; |
| 3889 | gp_ci.pVertexInputState = NULL; |
| 3890 | gp_ci.pInputAssemblyState = &iaCI; |
| 3891 | gp_ci.pTessellationState = &tsCI; |
| 3892 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3893 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3894 | gp_ci.pMultisampleState = NULL; |
| 3895 | gp_ci.pDepthStencilState = NULL; |
| 3896 | gp_ci.pColorBlendState = NULL; |
| 3897 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3898 | gp_ci.layout = pipeline_layout; |
| 3899 | gp_ci.renderPass = renderPass(); |
| 3900 | |
| 3901 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3902 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3903 | pc_ci.pNext = NULL; |
| 3904 | pc_ci.initialSize = 0; |
| 3905 | pc_ci.initialData = 0; |
| 3906 | pc_ci.maxSize = 0; |
| 3907 | |
| 3908 | VkPipeline pipeline; |
| 3909 | VkPipelineCache pipelineCache; |
| 3910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3911 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 3912 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3913 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3914 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3915 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3916 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3917 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3918 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3919 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3920 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3921 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3922 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3923 | } |
| 3924 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3925 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3926 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3927 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3928 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3929 | m_errorMonitor->SetDesiredFailureMsg( |
| 3930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3931 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 3932 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3933 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3934 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3935 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3936 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3938 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3939 | |
| 3940 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3941 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3942 | ds_pool_ci.maxSets = 1; |
| 3943 | ds_pool_ci.poolSizeCount = 1; |
| 3944 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3945 | |
| 3946 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3947 | err = |
| 3948 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3949 | ASSERT_VK_SUCCESS(err); |
| 3950 | |
| 3951 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3952 | dsl_binding.binding = 0; |
| 3953 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3954 | dsl_binding.descriptorCount = 1; |
| 3955 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3956 | |
| 3957 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3958 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3959 | ds_layout_ci.bindingCount = 1; |
| 3960 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3961 | |
| 3962 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3963 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3964 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3965 | ASSERT_VK_SUCCESS(err); |
| 3966 | |
| 3967 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3968 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3969 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3970 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3971 | alloc_info.descriptorPool = ds_pool; |
| 3972 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3973 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3974 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3975 | ASSERT_VK_SUCCESS(err); |
| 3976 | |
| 3977 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3978 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3979 | pipeline_layout_ci.setLayoutCount = 1; |
| 3980 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3981 | |
| 3982 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3983 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3984 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3985 | ASSERT_VK_SUCCESS(err); |
| 3986 | |
| 3987 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3988 | |
| 3989 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3990 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3991 | vp_state_ci.scissorCount = 0; |
| 3992 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 3993 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3994 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3995 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3996 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3997 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3998 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3999 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4000 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4001 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4002 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4003 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4004 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4007 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4008 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4009 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4010 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4011 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4012 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4013 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4014 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4015 | |
| 4016 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4018 | gp_ci.stageCount = 2; |
| 4019 | gp_ci.pStages = shaderStages; |
| 4020 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4021 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4022 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4023 | gp_ci.layout = pipeline_layout; |
| 4024 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4025 | |
| 4026 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4027 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4028 | |
| 4029 | VkPipeline pipeline; |
| 4030 | VkPipelineCache pipelineCache; |
| 4031 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4032 | err = |
| 4033 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4034 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4035 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4036 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4037 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4038 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4039 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4040 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4041 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4042 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4043 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4044 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4045 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4046 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4047 | // 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] | 4048 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4049 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4050 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4051 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4052 | m_errorMonitor->SetDesiredFailureMsg( |
| 4053 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4054 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4055 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4056 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4057 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4058 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4059 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4060 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4061 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4062 | |
| 4063 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4064 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4065 | ds_pool_ci.maxSets = 1; |
| 4066 | ds_pool_ci.poolSizeCount = 1; |
| 4067 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4068 | |
| 4069 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | err = |
| 4071 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4072 | ASSERT_VK_SUCCESS(err); |
| 4073 | |
| 4074 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | dsl_binding.binding = 0; |
| 4076 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4077 | dsl_binding.descriptorCount = 1; |
| 4078 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4079 | |
| 4080 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4081 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4082 | ds_layout_ci.bindingCount = 1; |
| 4083 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4084 | |
| 4085 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4086 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4087 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4088 | ASSERT_VK_SUCCESS(err); |
| 4089 | |
| 4090 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4091 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4092 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4093 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4094 | alloc_info.descriptorPool = ds_pool; |
| 4095 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4096 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4097 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4098 | ASSERT_VK_SUCCESS(err); |
| 4099 | |
| 4100 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4101 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4102 | pipeline_layout_ci.setLayoutCount = 1; |
| 4103 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4104 | |
| 4105 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4106 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4107 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4108 | ASSERT_VK_SUCCESS(err); |
| 4109 | |
| 4110 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4111 | // Set scissor as dynamic to avoid second error |
| 4112 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4113 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4114 | dyn_state_ci.dynamicStateCount = 1; |
| 4115 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4116 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4117 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4120 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4121 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4122 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4123 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4124 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4125 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4126 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4127 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4128 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4129 | |
| 4130 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4131 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4132 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4133 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4134 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4135 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4136 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4137 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4138 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4139 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4141 | gp_ci.stageCount = 2; |
| 4142 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4143 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4144 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4145 | // should cause validation error |
| 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(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4164 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4165 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4166 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4167 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4168 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4169 | } |
| 4170 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4171 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4172 | // count |
| 4173 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4174 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4176 | m_errorMonitor->SetDesiredFailureMsg( |
| 4177 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4178 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4179 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4181 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4182 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4183 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4184 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4185 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4186 | |
| 4187 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4188 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4189 | ds_pool_ci.maxSets = 1; |
| 4190 | ds_pool_ci.poolSizeCount = 1; |
| 4191 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4192 | |
| 4193 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4194 | err = |
| 4195 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4196 | ASSERT_VK_SUCCESS(err); |
| 4197 | |
| 4198 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4199 | dsl_binding.binding = 0; |
| 4200 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4201 | dsl_binding.descriptorCount = 1; |
| 4202 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4203 | |
| 4204 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4205 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4206 | ds_layout_ci.bindingCount = 1; |
| 4207 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4208 | |
| 4209 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4210 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4211 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4212 | ASSERT_VK_SUCCESS(err); |
| 4213 | |
| 4214 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4215 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4216 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4217 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4218 | alloc_info.descriptorPool = ds_pool; |
| 4219 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4220 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4221 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4222 | ASSERT_VK_SUCCESS(err); |
| 4223 | |
| 4224 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4226 | pipeline_layout_ci.setLayoutCount = 1; |
| 4227 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4228 | |
| 4229 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4230 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4231 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4232 | ASSERT_VK_SUCCESS(err); |
| 4233 | |
| 4234 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4235 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4236 | vp_state_ci.viewportCount = 1; |
| 4237 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4238 | vp_state_ci.scissorCount = 1; |
| 4239 | vp_state_ci.pScissors = |
| 4240 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4241 | |
| 4242 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4243 | // Set scissor as dynamic to avoid that error |
| 4244 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4245 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4246 | dyn_state_ci.dynamicStateCount = 1; |
| 4247 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4248 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4249 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4250 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4252 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4253 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4254 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4255 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4256 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4257 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4258 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4259 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4260 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4261 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4262 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4263 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4264 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4265 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4266 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4267 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4268 | |
| 4269 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4270 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4271 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4272 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4273 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4274 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4275 | rs_ci.pNext = nullptr; |
| 4276 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4277 | VkPipelineColorBlendAttachmentState att = {}; |
| 4278 | att.blendEnable = VK_FALSE; |
| 4279 | att.colorWriteMask = 0xf; |
| 4280 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4281 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4282 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4283 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4284 | cb_ci.attachmentCount = 1; |
| 4285 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4286 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4287 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4288 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4289 | gp_ci.stageCount = 2; |
| 4290 | gp_ci.pStages = shaderStages; |
| 4291 | gp_ci.pVertexInputState = &vi_ci; |
| 4292 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4293 | gp_ci.pViewportState = &vp_state_ci; |
| 4294 | gp_ci.pRasterizationState = &rs_ci; |
| 4295 | gp_ci.pColorBlendState = &cb_ci; |
| 4296 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4297 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4298 | gp_ci.layout = pipeline_layout; |
| 4299 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4300 | |
| 4301 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4302 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4303 | |
| 4304 | VkPipeline pipeline; |
| 4305 | VkPipelineCache pipelineCache; |
| 4306 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4307 | err = |
| 4308 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4309 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4310 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4311 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4312 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4313 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4314 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4315 | // 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] | 4316 | // First need to successfully create the PSO from above by setting |
| 4317 | // pViewports |
| 4318 | m_errorMonitor->SetDesiredFailureMsg( |
| 4319 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4320 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4321 | "scissorCount is 1. These counts must match."); |
| 4322 | |
| 4323 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4324 | vp_state_ci.pViewports = &vp; |
| 4325 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4326 | &gp_ci, NULL, &pipeline); |
| 4327 | ASSERT_VK_SUCCESS(err); |
| 4328 | BeginCommandBuffer(); |
| 4329 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4330 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4331 | VkRect2D scissors[2] = {}; // don't care about data |
| 4332 | // Count of 2 doesn't match PSO count of 1 |
| 4333 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4334 | Draw(1, 0, 0, 0); |
| 4335 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4336 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | |
| 4338 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4339 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4340 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4341 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4342 | } |
| 4343 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4344 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4345 | // viewportCount |
| 4346 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4347 | VkResult err; |
| 4348 | |
| 4349 | m_errorMonitor->SetDesiredFailureMsg( |
| 4350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4351 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4352 | |
| 4353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4354 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4355 | |
| 4356 | VkDescriptorPoolSize ds_type_count = {}; |
| 4357 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4358 | ds_type_count.descriptorCount = 1; |
| 4359 | |
| 4360 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4361 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4362 | ds_pool_ci.maxSets = 1; |
| 4363 | ds_pool_ci.poolSizeCount = 1; |
| 4364 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4365 | |
| 4366 | VkDescriptorPool ds_pool; |
| 4367 | err = |
| 4368 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4369 | ASSERT_VK_SUCCESS(err); |
| 4370 | |
| 4371 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4372 | dsl_binding.binding = 0; |
| 4373 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4374 | dsl_binding.descriptorCount = 1; |
| 4375 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4376 | |
| 4377 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4378 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4379 | ds_layout_ci.bindingCount = 1; |
| 4380 | ds_layout_ci.pBindings = &dsl_binding; |
| 4381 | |
| 4382 | VkDescriptorSetLayout ds_layout; |
| 4383 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4384 | &ds_layout); |
| 4385 | ASSERT_VK_SUCCESS(err); |
| 4386 | |
| 4387 | VkDescriptorSet descriptorSet; |
| 4388 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4389 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4390 | alloc_info.descriptorSetCount = 1; |
| 4391 | alloc_info.descriptorPool = ds_pool; |
| 4392 | alloc_info.pSetLayouts = &ds_layout; |
| 4393 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4394 | &descriptorSet); |
| 4395 | ASSERT_VK_SUCCESS(err); |
| 4396 | |
| 4397 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4398 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4399 | pipeline_layout_ci.setLayoutCount = 1; |
| 4400 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4401 | |
| 4402 | VkPipelineLayout pipeline_layout; |
| 4403 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4404 | &pipeline_layout); |
| 4405 | ASSERT_VK_SUCCESS(err); |
| 4406 | |
| 4407 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4408 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4409 | vp_state_ci.scissorCount = 1; |
| 4410 | vp_state_ci.pScissors = |
| 4411 | NULL; // Null scissor w/ count of 1 should cause error |
| 4412 | vp_state_ci.viewportCount = 1; |
| 4413 | vp_state_ci.pViewports = |
| 4414 | NULL; // vp is dynamic (below) so this won't cause error |
| 4415 | |
| 4416 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4417 | // Set scissor as dynamic to avoid that error |
| 4418 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4419 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4420 | dyn_state_ci.dynamicStateCount = 1; |
| 4421 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4422 | |
| 4423 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4424 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4425 | |
| 4426 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4427 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4428 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4429 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4430 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | // but add it to be able to run on more devices |
| 4432 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4433 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4434 | |
| 4435 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4436 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4437 | vi_ci.pNext = nullptr; |
| 4438 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4439 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4440 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4441 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4442 | |
| 4443 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4444 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4445 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4446 | |
| 4447 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4448 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4449 | rs_ci.pNext = nullptr; |
| 4450 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4451 | VkPipelineColorBlendAttachmentState att = {}; |
| 4452 | att.blendEnable = VK_FALSE; |
| 4453 | att.colorWriteMask = 0xf; |
| 4454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4456 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4457 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4458 | cb_ci.attachmentCount = 1; |
| 4459 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4460 | |
| 4461 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4462 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4463 | gp_ci.stageCount = 2; |
| 4464 | gp_ci.pStages = shaderStages; |
| 4465 | gp_ci.pVertexInputState = &vi_ci; |
| 4466 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4467 | gp_ci.pViewportState = &vp_state_ci; |
| 4468 | gp_ci.pRasterizationState = &rs_ci; |
| 4469 | gp_ci.pColorBlendState = &cb_ci; |
| 4470 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4471 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4472 | gp_ci.layout = pipeline_layout; |
| 4473 | gp_ci.renderPass = renderPass(); |
| 4474 | |
| 4475 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4476 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4477 | |
| 4478 | VkPipeline pipeline; |
| 4479 | VkPipelineCache pipelineCache; |
| 4480 | |
| 4481 | err = |
| 4482 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4483 | ASSERT_VK_SUCCESS(err); |
| 4484 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4485 | &gp_ci, NULL, &pipeline); |
| 4486 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4487 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4488 | |
| 4489 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4490 | // First need to successfully create the PSO from above by setting |
| 4491 | // pViewports |
| 4492 | m_errorMonitor->SetDesiredFailureMsg( |
| 4493 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4494 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4495 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4496 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4497 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4498 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4499 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4500 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4501 | ASSERT_VK_SUCCESS(err); |
| 4502 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4503 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4504 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4505 | VkViewport viewports[2] = {}; // don't care about data |
| 4506 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4507 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4508 | Draw(1, 0, 0, 0); |
| 4509 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4510 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4511 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4512 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4513 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4514 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4515 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4516 | } |
| 4517 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4518 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4519 | VkResult err; |
| 4520 | |
| 4521 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4522 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4523 | |
| 4524 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4525 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4526 | |
| 4527 | VkDescriptorPoolSize ds_type_count = {}; |
| 4528 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4529 | ds_type_count.descriptorCount = 1; |
| 4530 | |
| 4531 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4532 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4533 | ds_pool_ci.maxSets = 1; |
| 4534 | ds_pool_ci.poolSizeCount = 1; |
| 4535 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4536 | |
| 4537 | VkDescriptorPool ds_pool; |
| 4538 | err = |
| 4539 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4540 | ASSERT_VK_SUCCESS(err); |
| 4541 | |
| 4542 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4543 | dsl_binding.binding = 0; |
| 4544 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4545 | dsl_binding.descriptorCount = 1; |
| 4546 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4547 | |
| 4548 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4549 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4550 | ds_layout_ci.bindingCount = 1; |
| 4551 | ds_layout_ci.pBindings = &dsl_binding; |
| 4552 | |
| 4553 | VkDescriptorSetLayout ds_layout; |
| 4554 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4555 | &ds_layout); |
| 4556 | ASSERT_VK_SUCCESS(err); |
| 4557 | |
| 4558 | VkDescriptorSet descriptorSet; |
| 4559 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4560 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4561 | alloc_info.descriptorSetCount = 1; |
| 4562 | alloc_info.descriptorPool = ds_pool; |
| 4563 | alloc_info.pSetLayouts = &ds_layout; |
| 4564 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4565 | &descriptorSet); |
| 4566 | ASSERT_VK_SUCCESS(err); |
| 4567 | |
| 4568 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4569 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4570 | pipeline_layout_ci.setLayoutCount = 1; |
| 4571 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4572 | |
| 4573 | VkPipelineLayout pipeline_layout; |
| 4574 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4575 | &pipeline_layout); |
| 4576 | ASSERT_VK_SUCCESS(err); |
| 4577 | |
| 4578 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4579 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4580 | vp_state_ci.scissorCount = 1; |
| 4581 | vp_state_ci.pScissors = NULL; |
| 4582 | vp_state_ci.viewportCount = 1; |
| 4583 | vp_state_ci.pViewports = NULL; |
| 4584 | |
| 4585 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4586 | VK_DYNAMIC_STATE_SCISSOR, |
| 4587 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4588 | // Set scissor as dynamic to avoid that error |
| 4589 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4590 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4591 | dyn_state_ci.dynamicStateCount = 2; |
| 4592 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4593 | |
| 4594 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4595 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4596 | |
| 4597 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4598 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4599 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4600 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4601 | this); // TODO - We shouldn't need a fragment shader |
| 4602 | // but add it to be able to run on more devices |
| 4603 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4604 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4605 | |
| 4606 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4607 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4608 | vi_ci.pNext = nullptr; |
| 4609 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4610 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4611 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4612 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4613 | |
| 4614 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4615 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4616 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4617 | |
| 4618 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4619 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4620 | rs_ci.pNext = nullptr; |
| 4621 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4622 | // Check too low (line width of -1.0f). |
| 4623 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4624 | |
| 4625 | VkPipelineColorBlendAttachmentState att = {}; |
| 4626 | att.blendEnable = VK_FALSE; |
| 4627 | att.colorWriteMask = 0xf; |
| 4628 | |
| 4629 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4630 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4631 | cb_ci.pNext = nullptr; |
| 4632 | cb_ci.attachmentCount = 1; |
| 4633 | cb_ci.pAttachments = &att; |
| 4634 | |
| 4635 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4636 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4637 | gp_ci.stageCount = 2; |
| 4638 | gp_ci.pStages = shaderStages; |
| 4639 | gp_ci.pVertexInputState = &vi_ci; |
| 4640 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4641 | gp_ci.pViewportState = &vp_state_ci; |
| 4642 | gp_ci.pRasterizationState = &rs_ci; |
| 4643 | gp_ci.pColorBlendState = &cb_ci; |
| 4644 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4645 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4646 | gp_ci.layout = pipeline_layout; |
| 4647 | gp_ci.renderPass = renderPass(); |
| 4648 | |
| 4649 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4650 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4651 | |
| 4652 | VkPipeline pipeline; |
| 4653 | VkPipelineCache pipelineCache; |
| 4654 | |
| 4655 | err = |
| 4656 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4657 | ASSERT_VK_SUCCESS(err); |
| 4658 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4659 | &gp_ci, NULL, &pipeline); |
| 4660 | |
| 4661 | m_errorMonitor->VerifyFound(); |
| 4662 | |
| 4663 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4664 | "Attempt to set lineWidth to 65536"); |
| 4665 | |
| 4666 | // Check too high (line width of 65536.0f). |
| 4667 | rs_ci.lineWidth = 65536.0f; |
| 4668 | |
| 4669 | err = |
| 4670 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4671 | ASSERT_VK_SUCCESS(err); |
| 4672 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4673 | &gp_ci, NULL, &pipeline); |
| 4674 | |
| 4675 | m_errorMonitor->VerifyFound(); |
| 4676 | |
| 4677 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4678 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4679 | |
| 4680 | dyn_state_ci.dynamicStateCount = 3; |
| 4681 | |
| 4682 | rs_ci.lineWidth = 1.0f; |
| 4683 | |
| 4684 | err = |
| 4685 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4686 | ASSERT_VK_SUCCESS(err); |
| 4687 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4688 | &gp_ci, NULL, &pipeline); |
| 4689 | BeginCommandBuffer(); |
| 4690 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4691 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4692 | |
| 4693 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4694 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4695 | m_errorMonitor->VerifyFound(); |
| 4696 | |
| 4697 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4698 | "Attempt to set lineWidth to 65536"); |
| 4699 | |
| 4700 | // Check too high with dynamic setting. |
| 4701 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 4702 | m_errorMonitor->VerifyFound(); |
| 4703 | EndCommandBuffer(); |
| 4704 | |
| 4705 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4706 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4707 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4708 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4709 | } |
| 4710 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4711 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4712 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | m_errorMonitor->SetDesiredFailureMsg( |
| 4714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4715 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4716 | |
| 4717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4719 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4720 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4721 | // Don't care about RenderPass handle b/c error should be flagged before |
| 4722 | // that |
| 4723 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 4724 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4725 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4726 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4727 | } |
| 4728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4729 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4730 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4731 | m_errorMonitor->SetDesiredFailureMsg( |
| 4732 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4733 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4734 | |
| 4735 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4736 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4737 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4738 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4739 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 4740 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4741 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4742 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 4743 | rp_begin.pNext = NULL; |
| 4744 | rp_begin.renderPass = renderPass(); |
| 4745 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4747 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 4748 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4749 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4750 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4751 | } |
| 4752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4753 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4754 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | m_errorMonitor->SetDesiredFailureMsg( |
| 4756 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4757 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4758 | |
| 4759 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4760 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4761 | |
| 4762 | // Renderpass is started here |
| 4763 | BeginCommandBuffer(); |
| 4764 | |
| 4765 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4766 | vk_testing::Buffer dstBuffer; |
| 4767 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4768 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4769 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4770 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4771 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4772 | } |
| 4773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4774 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4775 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4776 | m_errorMonitor->SetDesiredFailureMsg( |
| 4777 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4778 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4779 | |
| 4780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4781 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4782 | |
| 4783 | // Renderpass is started here |
| 4784 | BeginCommandBuffer(); |
| 4785 | |
| 4786 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4787 | vk_testing::Buffer dstBuffer; |
| 4788 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4789 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4790 | VkDeviceSize dstOffset = 0; |
| 4791 | VkDeviceSize dataSize = 1024; |
| 4792 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4794 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 4795 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4796 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4797 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4798 | } |
| 4799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4800 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4801 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4802 | m_errorMonitor->SetDesiredFailureMsg( |
| 4803 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4804 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4805 | |
| 4806 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4807 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4808 | |
| 4809 | // Renderpass is started here |
| 4810 | BeginCommandBuffer(); |
| 4811 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 4812 | VkClearColorValue clear_color; |
| 4813 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4814 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4815 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4816 | const int32_t tex_width = 32; |
| 4817 | const int32_t tex_height = 32; |
| 4818 | VkImageCreateInfo image_create_info = {}; |
| 4819 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4820 | image_create_info.pNext = NULL; |
| 4821 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4822 | image_create_info.format = tex_format; |
| 4823 | image_create_info.extent.width = tex_width; |
| 4824 | image_create_info.extent.height = tex_height; |
| 4825 | image_create_info.extent.depth = 1; |
| 4826 | image_create_info.mipLevels = 1; |
| 4827 | image_create_info.arrayLayers = 1; |
| 4828 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4829 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4830 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4831 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4832 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4833 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4834 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4835 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4836 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4837 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4839 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4840 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4841 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4842 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4843 | } |
| 4844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4845 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4846 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4847 | m_errorMonitor->SetDesiredFailureMsg( |
| 4848 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4849 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4850 | |
| 4851 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4852 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4853 | |
| 4854 | // Renderpass is started here |
| 4855 | BeginCommandBuffer(); |
| 4856 | |
| 4857 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 4858 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4859 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 4860 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4861 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 4862 | image_create_info.extent.width = 64; |
| 4863 | image_create_info.extent.height = 64; |
| 4864 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4865 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4866 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4867 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4868 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4869 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4871 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4872 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | vkCmdClearDepthStencilImage( |
| 4875 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4876 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 4877 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4878 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4879 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4880 | } |
| 4881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4882 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4883 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4884 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4885 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4886 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4887 | "vkCmdClearAttachments: This call " |
| 4888 | "must be issued inside an active " |
| 4889 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4890 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4891 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4892 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4893 | |
| 4894 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4895 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4896 | ASSERT_VK_SUCCESS(err); |
| 4897 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4898 | VkClearAttachment color_attachment; |
| 4899 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4900 | color_attachment.clearValue.color.float32[0] = 0; |
| 4901 | color_attachment.clearValue.color.float32[1] = 0; |
| 4902 | color_attachment.clearValue.color.float32[2] = 0; |
| 4903 | color_attachment.clearValue.color.float32[3] = 0; |
| 4904 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4905 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 4906 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4907 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4908 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4909 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4910 | } |
| 4911 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 4912 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 4913 | // Try to add a buffer memory barrier with no buffer. |
| 4914 | m_errorMonitor->SetDesiredFailureMsg( |
| 4915 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4916 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 4917 | |
| 4918 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4919 | BeginCommandBuffer(); |
| 4920 | |
| 4921 | VkBufferMemoryBarrier buf_barrier = {}; |
| 4922 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 4923 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4924 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4925 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4926 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4927 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 4928 | buf_barrier.offset = 0; |
| 4929 | buf_barrier.size = VK_WHOLE_SIZE; |
| 4930 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4931 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 4932 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 4933 | |
| 4934 | m_errorMonitor->VerifyFound(); |
| 4935 | } |
| 4936 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 4937 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 4938 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 4939 | |
| 4940 | m_errorMonitor->SetDesiredFailureMsg( |
| 4941 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 4942 | |
| 4943 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4944 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4945 | |
| 4946 | VkMemoryBarrier mem_barrier = {}; |
| 4947 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 4948 | mem_barrier.pNext = NULL; |
| 4949 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4950 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4951 | BeginCommandBuffer(); |
| 4952 | // BeginCommandBuffer() starts a render pass |
| 4953 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4954 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4955 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 4956 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 4957 | m_errorMonitor->VerifyFound(); |
| 4958 | |
| 4959 | m_errorMonitor->SetDesiredFailureMsg( |
| 4960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4961 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 4962 | VkImageObj image(m_device); |
| 4963 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 4964 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 4965 | ASSERT_TRUE(image.initialized()); |
| 4966 | VkImageMemoryBarrier img_barrier = {}; |
| 4967 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 4968 | img_barrier.pNext = NULL; |
| 4969 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4970 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4971 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4972 | // New layout can't be UNDEFINED |
| 4973 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 4974 | img_barrier.image = image.handle(); |
| 4975 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4976 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4977 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4978 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 4979 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 4980 | img_barrier.subresourceRange.layerCount = 1; |
| 4981 | img_barrier.subresourceRange.levelCount = 1; |
| 4982 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4983 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4984 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4985 | nullptr, 1, &img_barrier); |
| 4986 | m_errorMonitor->VerifyFound(); |
| 4987 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4988 | |
| 4989 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4990 | "Subresource must have the sum of the " |
| 4991 | "baseArrayLayer"); |
| 4992 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 4993 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 4994 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4995 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4996 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4997 | nullptr, 1, &img_barrier); |
| 4998 | m_errorMonitor->VerifyFound(); |
| 4999 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5000 | |
| 5001 | m_errorMonitor->SetDesiredFailureMsg( |
| 5002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5003 | "Subresource must have the sum of the baseMipLevel"); |
| 5004 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5005 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5006 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5007 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5008 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5009 | nullptr, 1, &img_barrier); |
| 5010 | m_errorMonitor->VerifyFound(); |
| 5011 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5012 | |
| 5013 | m_errorMonitor->SetDesiredFailureMsg( |
| 5014 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5015 | "Buffer Barriers cannot be used during a render pass"); |
| 5016 | vk_testing::Buffer buffer; |
| 5017 | buffer.init(*m_device, 256); |
| 5018 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5019 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5020 | buf_barrier.pNext = NULL; |
| 5021 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5022 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5023 | buf_barrier.buffer = buffer.handle(); |
| 5024 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5025 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5026 | buf_barrier.offset = 0; |
| 5027 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5028 | // Can't send buffer barrier during a render pass |
| 5029 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5030 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5031 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5032 | &buf_barrier, 0, nullptr); |
| 5033 | m_errorMonitor->VerifyFound(); |
| 5034 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5035 | |
| 5036 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5037 | "which is not less than total size"); |
| 5038 | buf_barrier.offset = 257; |
| 5039 | // Offset greater than total size |
| 5040 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5041 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5042 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5043 | &buf_barrier, 0, nullptr); |
| 5044 | m_errorMonitor->VerifyFound(); |
| 5045 | buf_barrier.offset = 0; |
| 5046 | |
| 5047 | m_errorMonitor->SetDesiredFailureMsg( |
| 5048 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5049 | buf_barrier.size = 257; |
| 5050 | // Size greater than total size |
| 5051 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5052 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5053 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5054 | &buf_barrier, 0, nullptr); |
| 5055 | m_errorMonitor->VerifyFound(); |
| 5056 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5057 | |
| 5058 | m_errorMonitor->SetDesiredFailureMsg( |
| 5059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5060 | "Image is a depth and stencil format and thus must " |
| 5061 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5062 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5063 | VkDepthStencilObj ds_image(m_device); |
| 5064 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5065 | ASSERT_TRUE(ds_image.initialized()); |
| 5066 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5067 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5068 | img_barrier.image = ds_image.handle(); |
| 5069 | // Leave aspectMask at COLOR on purpose |
| 5070 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5071 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5072 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5073 | nullptr, 1, &img_barrier); |
| 5074 | m_errorMonitor->VerifyFound(); |
| 5075 | } |
| 5076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5077 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5078 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5079 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5081 | m_errorMonitor->SetDesiredFailureMsg( |
| 5082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5083 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5084 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5086 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5087 | uint32_t qfi = 0; |
| 5088 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5089 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5090 | buffCI.size = 1024; |
| 5091 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5092 | buffCI.queueFamilyIndexCount = 1; |
| 5093 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5094 | |
| 5095 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5096 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5097 | ASSERT_VK_SUCCESS(err); |
| 5098 | |
| 5099 | BeginCommandBuffer(); |
| 5100 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5101 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5102 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5103 | // 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] | 5104 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5105 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5106 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5107 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5108 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5109 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5110 | } |
| 5111 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5112 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5113 | // Create an out-of-range queueFamilyIndex |
| 5114 | m_errorMonitor->SetDesiredFailureMsg( |
| 5115 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5116 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5117 | |
| 5118 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5119 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5120 | VkBufferCreateInfo buffCI = {}; |
| 5121 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5122 | buffCI.size = 1024; |
| 5123 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5124 | buffCI.queueFamilyIndexCount = 1; |
| 5125 | // Introduce failure by specifying invalid queue_family_index |
| 5126 | uint32_t qfi = 777; |
| 5127 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5128 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5129 | |
| 5130 | VkBuffer ib; |
| 5131 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5132 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5133 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5134 | } |
| 5135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5136 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5137 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5138 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5140 | m_errorMonitor->SetDesiredFailureMsg( |
| 5141 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5142 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5143 | |
| 5144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5145 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5146 | |
| 5147 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5148 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5149 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5150 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5152 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5153 | } |
| 5154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5156 | // 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] | 5157 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5160 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5161 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5162 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5163 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5165 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5166 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5167 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5168 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5169 | |
| 5170 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5171 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5172 | ds_pool_ci.pNext = NULL; |
| 5173 | ds_pool_ci.maxSets = 1; |
| 5174 | ds_pool_ci.poolSizeCount = 1; |
| 5175 | ds_pool_ci.pPoolSizes = &ds_type_count; |
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 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5178 | err = |
| 5179 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5180 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5181 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5182 | dsl_binding.binding = 0; |
| 5183 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5184 | dsl_binding.descriptorCount = 1; |
| 5185 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5186 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5187 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5188 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5189 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5190 | ds_layout_ci.pNext = NULL; |
| 5191 | ds_layout_ci.bindingCount = 1; |
| 5192 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5193 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5194 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5195 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5196 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5197 | ASSERT_VK_SUCCESS(err); |
| 5198 | |
| 5199 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5200 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5201 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5202 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5203 | alloc_info.descriptorPool = ds_pool; |
| 5204 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5205 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5206 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5207 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5208 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame^] | 5209 | VkSamplerCreateInfo sampler_ci = {}; |
| 5210 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5211 | sampler_ci.pNext = NULL; |
| 5212 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5213 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5214 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5215 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5216 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5217 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5218 | sampler_ci.mipLodBias = 1.0; |
| 5219 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5220 | sampler_ci.maxAnisotropy = 1; |
| 5221 | sampler_ci.compareEnable = VK_FALSE; |
| 5222 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5223 | sampler_ci.minLod = 1.0; |
| 5224 | sampler_ci.maxLod = 1.0; |
| 5225 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5226 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5227 | VkSampler sampler; |
| 5228 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5229 | ASSERT_VK_SUCCESS(err); |
| 5230 | |
| 5231 | VkDescriptorImageInfo info = {}; |
| 5232 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5233 | |
| 5234 | VkWriteDescriptorSet descriptor_write; |
| 5235 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5236 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5237 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5238 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5239 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5240 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5241 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5242 | |
| 5243 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5244 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5245 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5246 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5247 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5248 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5249 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5250 | } |
| 5251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5252 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5253 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5254 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5257 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5258 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5259 | "starting at binding offset of 0 combined with update array element " |
| 5260 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5261 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5262 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5263 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5264 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5265 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5266 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5267 | |
| 5268 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5269 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5270 | ds_pool_ci.pNext = NULL; |
| 5271 | ds_pool_ci.maxSets = 1; |
| 5272 | ds_pool_ci.poolSizeCount = 1; |
| 5273 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5274 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5275 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5276 | err = |
| 5277 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5278 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5279 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5280 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5281 | dsl_binding.binding = 0; |
| 5282 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5283 | dsl_binding.descriptorCount = 1; |
| 5284 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5285 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5286 | |
| 5287 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5288 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5289 | ds_layout_ci.pNext = NULL; |
| 5290 | ds_layout_ci.bindingCount = 1; |
| 5291 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5292 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5293 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5294 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5295 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5296 | ASSERT_VK_SUCCESS(err); |
| 5297 | |
| 5298 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5299 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5300 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5301 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5302 | alloc_info.descriptorPool = ds_pool; |
| 5303 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5304 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5305 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5306 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5307 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame^] | 5308 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5309 | VkDescriptorBufferInfo buff_info = {}; |
| 5310 | buff_info.buffer = |
| 5311 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5312 | buff_info.offset = 0; |
| 5313 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5314 | |
| 5315 | VkWriteDescriptorSet descriptor_write; |
| 5316 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5317 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5318 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5319 | descriptor_write.dstArrayElement = |
| 5320 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5321 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5322 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5323 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5324 | |
| 5325 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5326 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5327 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5328 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5329 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5330 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5331 | } |
| 5332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5333 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5334 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5335 | // index 2 |
| 5336 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5337 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5338 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5339 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5340 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5341 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5342 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5343 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5344 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5345 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5346 | |
| 5347 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5348 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5349 | ds_pool_ci.pNext = NULL; |
| 5350 | ds_pool_ci.maxSets = 1; |
| 5351 | ds_pool_ci.poolSizeCount = 1; |
| 5352 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5353 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5354 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5355 | err = |
| 5356 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5357 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5358 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5359 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5360 | dsl_binding.binding = 0; |
| 5361 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5362 | dsl_binding.descriptorCount = 1; |
| 5363 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5364 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5365 | |
| 5366 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5367 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5368 | ds_layout_ci.pNext = NULL; |
| 5369 | ds_layout_ci.bindingCount = 1; |
| 5370 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5371 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5372 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5373 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5374 | ASSERT_VK_SUCCESS(err); |
| 5375 | |
| 5376 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5377 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5378 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5379 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5380 | alloc_info.descriptorPool = ds_pool; |
| 5381 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5382 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5383 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5384 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5385 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5386 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5387 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5388 | sampler_ci.pNext = NULL; |
| 5389 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5390 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5391 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5392 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5393 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5394 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5395 | sampler_ci.mipLodBias = 1.0; |
| 5396 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5397 | sampler_ci.maxAnisotropy = 1; |
| 5398 | sampler_ci.compareEnable = VK_FALSE; |
| 5399 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5400 | sampler_ci.minLod = 1.0; |
| 5401 | sampler_ci.maxLod = 1.0; |
| 5402 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5403 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5404 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5405 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5406 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5407 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5408 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5409 | VkDescriptorImageInfo info = {}; |
| 5410 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5411 | |
| 5412 | VkWriteDescriptorSet descriptor_write; |
| 5413 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5414 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5415 | descriptor_write.dstSet = descriptorSet; |
| 5416 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5417 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5418 | // 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] | 5419 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5420 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5421 | |
| 5422 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5423 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5424 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5425 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5426 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5427 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5428 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5429 | } |
| 5430 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5431 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5432 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5433 | // types |
| 5434 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5435 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5436 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5437 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5440 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5441 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5442 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5443 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5444 | |
| 5445 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5447 | ds_pool_ci.pNext = NULL; |
| 5448 | ds_pool_ci.maxSets = 1; |
| 5449 | ds_pool_ci.poolSizeCount = 1; |
| 5450 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5451 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5452 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5453 | err = |
| 5454 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5455 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5456 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5457 | dsl_binding.binding = 0; |
| 5458 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5459 | dsl_binding.descriptorCount = 1; |
| 5460 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5461 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5462 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5463 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5464 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5465 | ds_layout_ci.pNext = NULL; |
| 5466 | ds_layout_ci.bindingCount = 1; |
| 5467 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5468 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5469 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5471 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5472 | ASSERT_VK_SUCCESS(err); |
| 5473 | |
| 5474 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5475 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5476 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5477 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5478 | alloc_info.descriptorPool = ds_pool; |
| 5479 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5480 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5481 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5482 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5483 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5484 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5485 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5486 | sampler_ci.pNext = NULL; |
| 5487 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5488 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5489 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5490 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5491 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5492 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5493 | sampler_ci.mipLodBias = 1.0; |
| 5494 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5495 | sampler_ci.maxAnisotropy = 1; |
| 5496 | sampler_ci.compareEnable = VK_FALSE; |
| 5497 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5498 | sampler_ci.minLod = 1.0; |
| 5499 | sampler_ci.maxLod = 1.0; |
| 5500 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5501 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5502 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5503 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5504 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5505 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5506 | VkDescriptorImageInfo info = {}; |
| 5507 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5508 | |
| 5509 | VkWriteDescriptorSet descriptor_write; |
| 5510 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5511 | descriptor_write.sType = |
| 5512 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5513 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5514 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5515 | // 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] | 5516 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5517 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5518 | |
| 5519 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5520 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5521 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5522 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5523 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5524 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5525 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5526 | } |
| 5527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5528 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5529 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5530 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5532 | m_errorMonitor->SetDesiredFailureMsg( |
| 5533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5534 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5535 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5536 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5537 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5538 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5539 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5540 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5541 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5542 | |
| 5543 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5544 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5545 | ds_pool_ci.pNext = NULL; |
| 5546 | ds_pool_ci.maxSets = 1; |
| 5547 | ds_pool_ci.poolSizeCount = 1; |
| 5548 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5549 | |
| 5550 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5551 | err = |
| 5552 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5553 | ASSERT_VK_SUCCESS(err); |
| 5554 | |
| 5555 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5556 | dsl_binding.binding = 0; |
| 5557 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5558 | dsl_binding.descriptorCount = 1; |
| 5559 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5560 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5561 | |
| 5562 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5563 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5564 | ds_layout_ci.pNext = NULL; |
| 5565 | ds_layout_ci.bindingCount = 1; |
| 5566 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5567 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5568 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5569 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5570 | ASSERT_VK_SUCCESS(err); |
| 5571 | |
| 5572 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5573 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5574 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5575 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5576 | alloc_info.descriptorPool = ds_pool; |
| 5577 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5578 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5579 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5580 | ASSERT_VK_SUCCESS(err); |
| 5581 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5582 | VkSampler sampler = |
| 5583 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5584 | |
| 5585 | VkDescriptorImageInfo descriptor_info; |
| 5586 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5587 | descriptor_info.sampler = sampler; |
| 5588 | |
| 5589 | VkWriteDescriptorSet descriptor_write; |
| 5590 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5591 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5592 | descriptor_write.dstSet = descriptorSet; |
| 5593 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5594 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5595 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5596 | descriptor_write.pImageInfo = &descriptor_info; |
| 5597 | |
| 5598 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5599 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5600 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5601 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5602 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5603 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5604 | } |
| 5605 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5606 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5607 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5608 | // imageView |
| 5609 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5610 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5611 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5612 | "Attempted write update to combined " |
| 5613 | "image sampler descriptor failed due " |
| 5614 | "to: Invalid VkImageView: 0xbaadbeef"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5615 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5617 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5618 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5619 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5620 | |
| 5621 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5622 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5623 | ds_pool_ci.pNext = NULL; |
| 5624 | ds_pool_ci.maxSets = 1; |
| 5625 | ds_pool_ci.poolSizeCount = 1; |
| 5626 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5627 | |
| 5628 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5629 | err = |
| 5630 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5631 | ASSERT_VK_SUCCESS(err); |
| 5632 | |
| 5633 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | dsl_binding.binding = 0; |
| 5635 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5636 | dsl_binding.descriptorCount = 1; |
| 5637 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5638 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5639 | |
| 5640 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5641 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5642 | ds_layout_ci.pNext = NULL; |
| 5643 | ds_layout_ci.bindingCount = 1; |
| 5644 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5645 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5646 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5647 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5648 | ASSERT_VK_SUCCESS(err); |
| 5649 | |
| 5650 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5651 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5652 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5653 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5654 | alloc_info.descriptorPool = ds_pool; |
| 5655 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5656 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5657 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5658 | ASSERT_VK_SUCCESS(err); |
| 5659 | |
| 5660 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5661 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5662 | sampler_ci.pNext = NULL; |
| 5663 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5664 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5665 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5666 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5667 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5668 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5669 | sampler_ci.mipLodBias = 1.0; |
| 5670 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5671 | sampler_ci.maxAnisotropy = 1; |
| 5672 | sampler_ci.compareEnable = VK_FALSE; |
| 5673 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5674 | sampler_ci.minLod = 1.0; |
| 5675 | sampler_ci.maxLod = 1.0; |
| 5676 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5677 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5678 | |
| 5679 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5680 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5681 | ASSERT_VK_SUCCESS(err); |
| 5682 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5683 | VkImageView view = |
| 5684 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5685 | |
| 5686 | VkDescriptorImageInfo descriptor_info; |
| 5687 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5688 | descriptor_info.sampler = sampler; |
| 5689 | descriptor_info.imageView = view; |
| 5690 | |
| 5691 | VkWriteDescriptorSet descriptor_write; |
| 5692 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5693 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5694 | descriptor_write.dstSet = descriptorSet; |
| 5695 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5696 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5697 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5698 | descriptor_write.pImageInfo = &descriptor_info; |
| 5699 | |
| 5700 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5701 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5702 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5703 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5704 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5705 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5706 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5707 | } |
| 5708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5709 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 5710 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 5711 | // into the other |
| 5712 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5713 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5714 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5715 | " binding #1 with type " |
| 5716 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 5717 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5718 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5719 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5720 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5721 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5722 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5723 | ds_type_count[0].descriptorCount = 1; |
| 5724 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5725 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5726 | |
| 5727 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5728 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5729 | ds_pool_ci.pNext = NULL; |
| 5730 | ds_pool_ci.maxSets = 1; |
| 5731 | ds_pool_ci.poolSizeCount = 2; |
| 5732 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5733 | |
| 5734 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | err = |
| 5736 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5737 | ASSERT_VK_SUCCESS(err); |
| 5738 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5739 | dsl_binding[0].binding = 0; |
| 5740 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5741 | dsl_binding[0].descriptorCount = 1; |
| 5742 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5743 | dsl_binding[0].pImmutableSamplers = NULL; |
| 5744 | dsl_binding[1].binding = 1; |
| 5745 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5746 | dsl_binding[1].descriptorCount = 1; |
| 5747 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5748 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5749 | |
| 5750 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5751 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5752 | ds_layout_ci.pNext = NULL; |
| 5753 | ds_layout_ci.bindingCount = 2; |
| 5754 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5755 | |
| 5756 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5757 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5758 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5759 | ASSERT_VK_SUCCESS(err); |
| 5760 | |
| 5761 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5762 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5763 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5764 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5765 | alloc_info.descriptorPool = ds_pool; |
| 5766 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5767 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5768 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5769 | ASSERT_VK_SUCCESS(err); |
| 5770 | |
| 5771 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5772 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5773 | sampler_ci.pNext = NULL; |
| 5774 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5775 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5776 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5777 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5778 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5779 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5780 | sampler_ci.mipLodBias = 1.0; |
| 5781 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5782 | sampler_ci.maxAnisotropy = 1; |
| 5783 | sampler_ci.compareEnable = VK_FALSE; |
| 5784 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5785 | sampler_ci.minLod = 1.0; |
| 5786 | sampler_ci.maxLod = 1.0; |
| 5787 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5788 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5789 | |
| 5790 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5791 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5792 | ASSERT_VK_SUCCESS(err); |
| 5793 | |
| 5794 | VkDescriptorImageInfo info = {}; |
| 5795 | info.sampler = sampler; |
| 5796 | |
| 5797 | VkWriteDescriptorSet descriptor_write; |
| 5798 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 5799 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5800 | descriptor_write.dstSet = descriptorSet; |
| 5801 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5802 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5803 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5804 | descriptor_write.pImageInfo = &info; |
| 5805 | // This write update should succeed |
| 5806 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5807 | // Now perform a copy update that fails due to type mismatch |
| 5808 | VkCopyDescriptorSet copy_ds_update; |
| 5809 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5810 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5811 | copy_ds_update.srcSet = descriptorSet; |
| 5812 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5813 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5814 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5815 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5816 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5817 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5818 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5819 | // 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] | 5820 | m_errorMonitor->SetDesiredFailureMsg( |
| 5821 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5822 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5823 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5824 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5825 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5826 | copy_ds_update.srcBinding = |
| 5827 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5828 | copy_ds_update.dstSet = descriptorSet; |
| 5829 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5830 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5831 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5832 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5833 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5834 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5835 | // 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] | 5836 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5837 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 5838 | "update array offset of 0 and update of " |
| 5839 | "5 descriptors oversteps total number " |
| 5840 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5841 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5842 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5843 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5844 | copy_ds_update.srcSet = descriptorSet; |
| 5845 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5846 | copy_ds_update.dstSet = descriptorSet; |
| 5847 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5848 | copy_ds_update.descriptorCount = |
| 5849 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5850 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5851 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5852 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5853 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5854 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5855 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5856 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5857 | } |
| 5858 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 5860 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 5861 | // sampleCount |
| 5862 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5863 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5864 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5865 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5866 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5867 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5868 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5869 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5870 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5871 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5872 | |
| 5873 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5874 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5875 | ds_pool_ci.pNext = NULL; |
| 5876 | ds_pool_ci.maxSets = 1; |
| 5877 | ds_pool_ci.poolSizeCount = 1; |
| 5878 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5879 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5880 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | err = |
| 5882 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5883 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5884 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5885 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5886 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5887 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5888 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5889 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5890 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5891 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5892 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5893 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5894 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5895 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5896 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5897 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5898 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5900 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5901 | ASSERT_VK_SUCCESS(err); |
| 5902 | |
| 5903 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5904 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5905 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5906 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5907 | alloc_info.descriptorPool = ds_pool; |
| 5908 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5909 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5910 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5911 | ASSERT_VK_SUCCESS(err); |
| 5912 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5913 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5914 | pipe_ms_state_ci.sType = |
| 5915 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 5916 | pipe_ms_state_ci.pNext = NULL; |
| 5917 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 5918 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 5919 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 5920 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5921 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5922 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5923 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5924 | pipeline_layout_ci.pNext = NULL; |
| 5925 | pipeline_layout_ci.setLayoutCount = 1; |
| 5926 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5927 | |
| 5928 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5929 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5930 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5931 | ASSERT_VK_SUCCESS(err); |
| 5932 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5933 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5934 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5935 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5936 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5937 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5939 | VkPipelineObj pipe(m_device); |
| 5940 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5941 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5942 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5943 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 5944 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5945 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5946 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5947 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5948 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5949 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5950 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5951 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5952 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5953 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5954 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5955 | } |
Tobin Ehlis | 0f10db5 | 2016-04-04 10:00:21 -0600 | [diff] [blame] | 5956 | #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] | 5957 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 5958 | // Create Pipeline where the number of blend attachments doesn't match the |
| 5959 | // number of color attachments. In this case, we don't add any color |
| 5960 | // blend attachments even though we have a color attachment. |
| 5961 | VkResult err; |
| 5962 | |
| 5963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5964 | "Mismatch between blend state attachment"); |
| 5965 | |
| 5966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5968 | VkDescriptorPoolSize ds_type_count = {}; |
| 5969 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5970 | ds_type_count.descriptorCount = 1; |
| 5971 | |
| 5972 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5973 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5974 | ds_pool_ci.pNext = NULL; |
| 5975 | ds_pool_ci.maxSets = 1; |
| 5976 | ds_pool_ci.poolSizeCount = 1; |
| 5977 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5978 | |
| 5979 | VkDescriptorPool ds_pool; |
| 5980 | err = |
| 5981 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5982 | ASSERT_VK_SUCCESS(err); |
| 5983 | |
| 5984 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5985 | dsl_binding.binding = 0; |
| 5986 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5987 | dsl_binding.descriptorCount = 1; |
| 5988 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5989 | dsl_binding.pImmutableSamplers = NULL; |
| 5990 | |
| 5991 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5992 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5993 | ds_layout_ci.pNext = NULL; |
| 5994 | ds_layout_ci.bindingCount = 1; |
| 5995 | ds_layout_ci.pBindings = &dsl_binding; |
| 5996 | |
| 5997 | VkDescriptorSetLayout ds_layout; |
| 5998 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5999 | &ds_layout); |
| 6000 | ASSERT_VK_SUCCESS(err); |
| 6001 | |
| 6002 | VkDescriptorSet descriptorSet; |
| 6003 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6004 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6005 | alloc_info.descriptorSetCount = 1; |
| 6006 | alloc_info.descriptorPool = ds_pool; |
| 6007 | alloc_info.pSetLayouts = &ds_layout; |
| 6008 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6009 | &descriptorSet); |
| 6010 | ASSERT_VK_SUCCESS(err); |
| 6011 | |
| 6012 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6013 | pipe_ms_state_ci.sType = |
| 6014 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6015 | pipe_ms_state_ci.pNext = NULL; |
| 6016 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6017 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6018 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6019 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6020 | |
| 6021 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6022 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6023 | pipeline_layout_ci.pNext = NULL; |
| 6024 | pipeline_layout_ci.setLayoutCount = 1; |
| 6025 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6026 | |
| 6027 | VkPipelineLayout pipeline_layout; |
| 6028 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6029 | &pipeline_layout); |
| 6030 | ASSERT_VK_SUCCESS(err); |
| 6031 | |
| 6032 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6033 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6034 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6035 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6036 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6037 | // but add it to be able to run on more devices |
| 6038 | VkPipelineObj pipe(m_device); |
| 6039 | pipe.AddShader(&vs); |
| 6040 | pipe.AddShader(&fs); |
| 6041 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6042 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6043 | |
| 6044 | BeginCommandBuffer(); |
| 6045 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6046 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6047 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6048 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6049 | |
| 6050 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6051 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6052 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6053 | } |
Tony Barbour | 4e81a20 | 2016-04-04 11:09:40 -0600 | [diff] [blame] | 6054 | #endif //ADD_BACK_IN_WHEN_CHECK_IS_BACK |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6055 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6056 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6057 | // to issuing a Draw |
| 6058 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6059 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6060 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6061 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6062 | "vkCmdClearAttachments() issued on CB object "); |
| 6063 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6064 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6065 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6066 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6067 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6068 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6069 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6070 | |
| 6071 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6072 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6073 | ds_pool_ci.pNext = NULL; |
| 6074 | ds_pool_ci.maxSets = 1; |
| 6075 | ds_pool_ci.poolSizeCount = 1; |
| 6076 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6077 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6078 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | err = |
| 6080 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6081 | ASSERT_VK_SUCCESS(err); |
| 6082 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6083 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6084 | dsl_binding.binding = 0; |
| 6085 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6086 | dsl_binding.descriptorCount = 1; |
| 6087 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6088 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6089 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6090 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6091 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6092 | ds_layout_ci.pNext = NULL; |
| 6093 | ds_layout_ci.bindingCount = 1; |
| 6094 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6095 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6096 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6097 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6098 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6099 | ASSERT_VK_SUCCESS(err); |
| 6100 | |
| 6101 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6102 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6103 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6104 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6105 | alloc_info.descriptorPool = ds_pool; |
| 6106 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6107 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6108 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6109 | ASSERT_VK_SUCCESS(err); |
| 6110 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6111 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6112 | pipe_ms_state_ci.sType = |
| 6113 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6114 | pipe_ms_state_ci.pNext = NULL; |
| 6115 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6116 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6117 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6118 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6119 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6120 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6121 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6122 | pipeline_layout_ci.pNext = NULL; |
| 6123 | pipeline_layout_ci.setLayoutCount = 1; |
| 6124 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6125 | |
| 6126 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6128 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6129 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6130 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6131 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6132 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6133 | // 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] | 6134 | // on more devices |
| 6135 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6136 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6137 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6138 | VkPipelineObj pipe(m_device); |
| 6139 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6140 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6141 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6142 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6143 | |
| 6144 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6146 | // Main thing we care about for this test is that the VkImage obj we're |
| 6147 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6148 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6149 | VkClearAttachment color_attachment; |
| 6150 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6151 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6152 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6153 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6154 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6155 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | VkClearRect clear_rect = { |
| 6157 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6159 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6160 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6161 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6162 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6163 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6164 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6165 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6166 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6167 | } |
| 6168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6170 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6172 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6173 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6174 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6175 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6176 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6177 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6178 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6179 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6180 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6181 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6182 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6183 | |
| 6184 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6185 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6186 | ds_pool_ci.pNext = NULL; |
| 6187 | ds_pool_ci.maxSets = 1; |
| 6188 | ds_pool_ci.poolSizeCount = 1; |
| 6189 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6190 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6191 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6192 | err = |
| 6193 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6194 | ASSERT_VK_SUCCESS(err); |
| 6195 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6196 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6197 | dsl_binding.binding = 0; |
| 6198 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6199 | dsl_binding.descriptorCount = 1; |
| 6200 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6201 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6202 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6203 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6204 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6205 | ds_layout_ci.pNext = NULL; |
| 6206 | ds_layout_ci.bindingCount = 1; |
| 6207 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6208 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6209 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6210 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6211 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6212 | ASSERT_VK_SUCCESS(err); |
| 6213 | |
| 6214 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6215 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6216 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6217 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6218 | alloc_info.descriptorPool = ds_pool; |
| 6219 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6220 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6221 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6222 | ASSERT_VK_SUCCESS(err); |
| 6223 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6224 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6225 | pipe_ms_state_ci.sType = |
| 6226 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6227 | pipe_ms_state_ci.pNext = NULL; |
| 6228 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6229 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6230 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6231 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6232 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6233 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6234 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6235 | pipeline_layout_ci.pNext = NULL; |
| 6236 | pipeline_layout_ci.setLayoutCount = 1; |
| 6237 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6238 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6240 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6241 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6242 | ASSERT_VK_SUCCESS(err); |
| 6243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6244 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6245 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6246 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6247 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6248 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6249 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6250 | VkPipelineObj pipe(m_device); |
| 6251 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6252 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6253 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6254 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6255 | pipe.SetViewport(m_viewports); |
| 6256 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6257 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6258 | |
| 6259 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6260 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6261 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6262 | // Don't care about actual data, just need to get to draw to flag error |
| 6263 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6264 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6265 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6266 | 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] | 6267 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6268 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6269 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6270 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6271 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6272 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6273 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6274 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6275 | #endif // DRAW_STATE_TESTS |
| 6276 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6277 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6278 | #if GTEST_IS_THREADSAFE |
| 6279 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6280 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6281 | VkEvent event; |
| 6282 | bool bailout; |
| 6283 | }; |
| 6284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6285 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6286 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6287 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6288 | for (int i = 0; i < 10000; i++) { |
| 6289 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6290 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6291 | if (data->bailout) { |
| 6292 | break; |
| 6293 | } |
| 6294 | } |
| 6295 | return NULL; |
| 6296 | } |
| 6297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6298 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6299 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6301 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6302 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6303 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6305 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6306 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6307 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6308 | // Calls AllocateCommandBuffers |
| 6309 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6310 | |
| 6311 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6312 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6313 | |
| 6314 | VkEventCreateInfo event_info; |
| 6315 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6316 | VkResult err; |
| 6317 | |
| 6318 | memset(&event_info, 0, sizeof(event_info)); |
| 6319 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6320 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6321 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6322 | ASSERT_VK_SUCCESS(err); |
| 6323 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6324 | err = vkResetEvent(device(), event); |
| 6325 | ASSERT_VK_SUCCESS(err); |
| 6326 | |
| 6327 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6328 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6329 | data.event = event; |
| 6330 | data.bailout = false; |
| 6331 | m_errorMonitor->SetBailout(&data.bailout); |
| 6332 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6333 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6334 | // Add many entries to command buffer from this thread at the same time. |
| 6335 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6336 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6337 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6338 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6339 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6340 | m_errorMonitor->SetBailout(NULL); |
| 6341 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6342 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6343 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6344 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6345 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6346 | #endif // GTEST_IS_THREADSAFE |
| 6347 | #endif // THREADING_TESTS |
| 6348 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6349 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6350 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6351 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6352 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6353 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6354 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6355 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6356 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6357 | VkShaderModule module; |
| 6358 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6359 | struct icd_spv_header spv; |
| 6360 | |
| 6361 | spv.magic = ICD_SPV_MAGIC; |
| 6362 | spv.version = ICD_SPV_VERSION; |
| 6363 | spv.gen_magic = 0; |
| 6364 | |
| 6365 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6366 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6367 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6368 | moduleCreateInfo.codeSize = 4; |
| 6369 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6370 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6371 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6372 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6373 | } |
| 6374 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6375 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6376 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6377 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6378 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6379 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6380 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6381 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6382 | VkShaderModule module; |
| 6383 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6384 | struct icd_spv_header spv; |
| 6385 | |
| 6386 | spv.magic = ~ICD_SPV_MAGIC; |
| 6387 | spv.version = ICD_SPV_VERSION; |
| 6388 | spv.gen_magic = 0; |
| 6389 | |
| 6390 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6391 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6392 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6393 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6394 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6395 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6396 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6397 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6398 | } |
| 6399 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6400 | #if 0 |
| 6401 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6402 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6403 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6404 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6405 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6406 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6407 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6408 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6409 | VkShaderModule module; |
| 6410 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6411 | struct icd_spv_header spv; |
| 6412 | |
| 6413 | spv.magic = ICD_SPV_MAGIC; |
| 6414 | spv.version = ~ICD_SPV_VERSION; |
| 6415 | spv.gen_magic = 0; |
| 6416 | |
| 6417 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6418 | moduleCreateInfo.pNext = NULL; |
| 6419 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6420 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6421 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6422 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6423 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6424 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6425 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6426 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6427 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6429 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6430 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6431 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6432 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6433 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6434 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6435 | |
| 6436 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6437 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6438 | "\n" |
| 6439 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6440 | "out gl_PerVertex {\n" |
| 6441 | " vec4 gl_Position;\n" |
| 6442 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6443 | "void main(){\n" |
| 6444 | " gl_Position = vec4(1);\n" |
| 6445 | " x = 0;\n" |
| 6446 | "}\n"; |
| 6447 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6448 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6449 | "\n" |
| 6450 | "layout(location=0) out vec4 color;\n" |
| 6451 | "void main(){\n" |
| 6452 | " color = vec4(1);\n" |
| 6453 | "}\n"; |
| 6454 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6455 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6456 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6457 | |
| 6458 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6459 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6460 | pipe.AddShader(&vs); |
| 6461 | pipe.AddShader(&fs); |
| 6462 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6463 | VkDescriptorSetObj descriptorSet(m_device); |
| 6464 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6465 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6466 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6467 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6468 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6469 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6470 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6472 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
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 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6475 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +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 | 59cb88d | 2015-05-25 11:13:13 +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 | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6481 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6482 | "out gl_PerVertex {\n" |
| 6483 | " vec4 gl_Position;\n" |
| 6484 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6485 | "void main(){\n" |
| 6486 | " gl_Position = vec4(1);\n" |
| 6487 | "}\n"; |
| 6488 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6489 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6490 | "\n" |
| 6491 | "layout(location=0) in float x;\n" |
| 6492 | "layout(location=0) out vec4 color;\n" |
| 6493 | "void main(){\n" |
| 6494 | " color = vec4(x);\n" |
| 6495 | "}\n"; |
| 6496 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6497 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6498 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6499 | |
| 6500 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6501 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6502 | pipe.AddShader(&vs); |
| 6503 | pipe.AddShader(&fs); |
| 6504 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6505 | VkDescriptorSetObj descriptorSet(m_device); |
| 6506 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6507 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6508 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6509 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6510 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6511 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6512 | } |
| 6513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6514 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6515 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6516 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6517 | |
| 6518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6519 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6520 | |
| 6521 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6522 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6523 | "\n" |
| 6524 | "out gl_PerVertex {\n" |
| 6525 | " vec4 gl_Position;\n" |
| 6526 | "};\n" |
| 6527 | "void main(){\n" |
| 6528 | " gl_Position = vec4(1);\n" |
| 6529 | "}\n"; |
| 6530 | char const *fsSource = |
| 6531 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6532 | "\n" |
| 6533 | "in block { layout(location=0) float x; } ins;\n" |
| 6534 | "layout(location=0) out vec4 color;\n" |
| 6535 | "void main(){\n" |
| 6536 | " color = vec4(ins.x);\n" |
| 6537 | "}\n"; |
| 6538 | |
| 6539 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6540 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6541 | |
| 6542 | VkPipelineObj pipe(m_device); |
| 6543 | pipe.AddColorAttachment(); |
| 6544 | pipe.AddShader(&vs); |
| 6545 | pipe.AddShader(&fs); |
| 6546 | |
| 6547 | VkDescriptorSetObj descriptorSet(m_device); |
| 6548 | descriptorSet.AppendDummy(); |
| 6549 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6550 | |
| 6551 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6552 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6553 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6554 | } |
| 6555 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6556 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6557 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6558 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6559 | "output arr[2] of float32' vs 'ptr to " |
| 6560 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6561 | |
| 6562 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6563 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6564 | |
| 6565 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6566 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6567 | "\n" |
| 6568 | "layout(location=0) out float x[2];\n" |
| 6569 | "out gl_PerVertex {\n" |
| 6570 | " vec4 gl_Position;\n" |
| 6571 | "};\n" |
| 6572 | "void main(){\n" |
| 6573 | " x[0] = 0; x[1] = 0;\n" |
| 6574 | " gl_Position = vec4(1);\n" |
| 6575 | "}\n"; |
| 6576 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6577 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6578 | "\n" |
| 6579 | "layout(location=0) in float x[3];\n" |
| 6580 | "layout(location=0) out vec4 color;\n" |
| 6581 | "void main(){\n" |
| 6582 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 6583 | "}\n"; |
| 6584 | |
| 6585 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6586 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6587 | |
| 6588 | VkPipelineObj pipe(m_device); |
| 6589 | pipe.AddColorAttachment(); |
| 6590 | pipe.AddShader(&vs); |
| 6591 | pipe.AddShader(&fs); |
| 6592 | |
| 6593 | VkDescriptorSetObj descriptorSet(m_device); |
| 6594 | descriptorSet.AppendDummy(); |
| 6595 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6596 | |
| 6597 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6598 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6599 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6600 | } |
| 6601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6602 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6603 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6604 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6605 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6606 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6607 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6608 | |
| 6609 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6610 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6611 | "\n" |
| 6612 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6613 | "out gl_PerVertex {\n" |
| 6614 | " vec4 gl_Position;\n" |
| 6615 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6616 | "void main(){\n" |
| 6617 | " x = 0;\n" |
| 6618 | " gl_Position = vec4(1);\n" |
| 6619 | "}\n"; |
| 6620 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6621 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6622 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6623 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6624 | "layout(location=0) out vec4 color;\n" |
| 6625 | "void main(){\n" |
| 6626 | " color = vec4(x);\n" |
| 6627 | "}\n"; |
| 6628 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6629 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6630 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6631 | |
| 6632 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6633 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6634 | pipe.AddShader(&vs); |
| 6635 | pipe.AddShader(&fs); |
| 6636 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6637 | VkDescriptorSetObj descriptorSet(m_device); |
| 6638 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6639 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6640 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6641 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6642 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6643 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6644 | } |
| 6645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6647 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6648 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6649 | |
| 6650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6651 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6652 | |
| 6653 | char const *vsSource = |
| 6654 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6655 | "\n" |
| 6656 | "out block { layout(location=0) int x; } outs;\n" |
| 6657 | "out gl_PerVertex {\n" |
| 6658 | " vec4 gl_Position;\n" |
| 6659 | "};\n" |
| 6660 | "void main(){\n" |
| 6661 | " outs.x = 0;\n" |
| 6662 | " gl_Position = vec4(1);\n" |
| 6663 | "}\n"; |
| 6664 | char const *fsSource = |
| 6665 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6666 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6667 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6668 | "layout(location=0) out vec4 color;\n" |
| 6669 | "void main(){\n" |
| 6670 | " color = vec4(ins.x);\n" |
| 6671 | "}\n"; |
| 6672 | |
| 6673 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6674 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6675 | |
| 6676 | VkPipelineObj pipe(m_device); |
| 6677 | pipe.AddColorAttachment(); |
| 6678 | pipe.AddShader(&vs); |
| 6679 | pipe.AddShader(&fs); |
| 6680 | |
| 6681 | VkDescriptorSetObj descriptorSet(m_device); |
| 6682 | descriptorSet.AppendDummy(); |
| 6683 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6684 | |
| 6685 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6686 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6687 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6688 | } |
| 6689 | |
| 6690 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 6691 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6692 | "location 0.0 which is not written by vertex shader"); |
| 6693 | |
| 6694 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6695 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6696 | |
| 6697 | char const *vsSource = |
| 6698 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6699 | "\n" |
| 6700 | "out block { layout(location=1) float x; } outs;\n" |
| 6701 | "out gl_PerVertex {\n" |
| 6702 | " vec4 gl_Position;\n" |
| 6703 | "};\n" |
| 6704 | "void main(){\n" |
| 6705 | " outs.x = 0;\n" |
| 6706 | " gl_Position = vec4(1);\n" |
| 6707 | "}\n"; |
| 6708 | char const *fsSource = |
| 6709 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6710 | "\n" |
| 6711 | "in block { layout(location=0) float x; } ins;\n" |
| 6712 | "layout(location=0) out vec4 color;\n" |
| 6713 | "void main(){\n" |
| 6714 | " color = vec4(ins.x);\n" |
| 6715 | "}\n"; |
| 6716 | |
| 6717 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6718 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6719 | |
| 6720 | VkPipelineObj pipe(m_device); |
| 6721 | pipe.AddColorAttachment(); |
| 6722 | pipe.AddShader(&vs); |
| 6723 | pipe.AddShader(&fs); |
| 6724 | |
| 6725 | VkDescriptorSetObj descriptorSet(m_device); |
| 6726 | descriptorSet.AppendDummy(); |
| 6727 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6728 | |
| 6729 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6730 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6731 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6732 | } |
| 6733 | |
| 6734 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 6735 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6736 | "location 0.1 which is not written by vertex shader"); |
| 6737 | |
| 6738 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6739 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6740 | |
| 6741 | char const *vsSource = |
| 6742 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6743 | "\n" |
| 6744 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 6745 | "out gl_PerVertex {\n" |
| 6746 | " vec4 gl_Position;\n" |
| 6747 | "};\n" |
| 6748 | "void main(){\n" |
| 6749 | " outs.x = 0;\n" |
| 6750 | " gl_Position = vec4(1);\n" |
| 6751 | "}\n"; |
| 6752 | char const *fsSource = |
| 6753 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6754 | "\n" |
| 6755 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 6756 | "layout(location=0) out vec4 color;\n" |
| 6757 | "void main(){\n" |
| 6758 | " color = vec4(ins.x);\n" |
| 6759 | "}\n"; |
| 6760 | |
| 6761 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6762 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6763 | |
| 6764 | VkPipelineObj pipe(m_device); |
| 6765 | pipe.AddColorAttachment(); |
| 6766 | pipe.AddShader(&vs); |
| 6767 | pipe.AddShader(&fs); |
| 6768 | |
| 6769 | VkDescriptorSetObj descriptorSet(m_device); |
| 6770 | descriptorSet.AppendDummy(); |
| 6771 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6772 | |
| 6773 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6774 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6775 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6776 | } |
| 6777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6778 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6779 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6780 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6781 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6783 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6784 | |
| 6785 | VkVertexInputBindingDescription input_binding; |
| 6786 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6787 | |
| 6788 | VkVertexInputAttributeDescription input_attrib; |
| 6789 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6790 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6791 | |
| 6792 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6793 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6794 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6795 | "out gl_PerVertex {\n" |
| 6796 | " vec4 gl_Position;\n" |
| 6797 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6798 | "void main(){\n" |
| 6799 | " gl_Position = vec4(1);\n" |
| 6800 | "}\n"; |
| 6801 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6802 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6803 | "\n" |
| 6804 | "layout(location=0) out vec4 color;\n" |
| 6805 | "void main(){\n" |
| 6806 | " color = vec4(1);\n" |
| 6807 | "}\n"; |
| 6808 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6809 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6810 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6811 | |
| 6812 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6813 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6814 | pipe.AddShader(&vs); |
| 6815 | pipe.AddShader(&fs); |
| 6816 | |
| 6817 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6818 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6819 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6820 | VkDescriptorSetObj descriptorSet(m_device); |
| 6821 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6822 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6823 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6824 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6825 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6826 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6827 | } |
| 6828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6829 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6831 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6832 | |
| 6833 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6834 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6835 | |
| 6836 | VkVertexInputBindingDescription input_binding; |
| 6837 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6838 | |
| 6839 | VkVertexInputAttributeDescription input_attrib; |
| 6840 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6841 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6842 | |
| 6843 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6844 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6845 | "\n" |
| 6846 | "layout(location=1) in float x;\n" |
| 6847 | "out gl_PerVertex {\n" |
| 6848 | " vec4 gl_Position;\n" |
| 6849 | "};\n" |
| 6850 | "void main(){\n" |
| 6851 | " gl_Position = vec4(x);\n" |
| 6852 | "}\n"; |
| 6853 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6854 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6855 | "\n" |
| 6856 | "layout(location=0) out vec4 color;\n" |
| 6857 | "void main(){\n" |
| 6858 | " color = vec4(1);\n" |
| 6859 | "}\n"; |
| 6860 | |
| 6861 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6862 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6863 | |
| 6864 | VkPipelineObj pipe(m_device); |
| 6865 | pipe.AddColorAttachment(); |
| 6866 | pipe.AddShader(&vs); |
| 6867 | pipe.AddShader(&fs); |
| 6868 | |
| 6869 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6870 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6871 | |
| 6872 | VkDescriptorSetObj descriptorSet(m_device); |
| 6873 | descriptorSet.AppendDummy(); |
| 6874 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6875 | |
| 6876 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6877 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6878 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6879 | } |
| 6880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6881 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 6882 | m_errorMonitor->SetDesiredFailureMsg( |
| 6883 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6884 | "VS consumes input at location 0 but not provided"); |
| 6885 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6887 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6888 | |
| 6889 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6890 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6891 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6892 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6893 | "out gl_PerVertex {\n" |
| 6894 | " vec4 gl_Position;\n" |
| 6895 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6896 | "void main(){\n" |
| 6897 | " gl_Position = x;\n" |
| 6898 | "}\n"; |
| 6899 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6900 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6901 | "\n" |
| 6902 | "layout(location=0) out vec4 color;\n" |
| 6903 | "void main(){\n" |
| 6904 | " color = vec4(1);\n" |
| 6905 | "}\n"; |
| 6906 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6907 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6908 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6909 | |
| 6910 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6911 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6912 | pipe.AddShader(&vs); |
| 6913 | pipe.AddShader(&fs); |
| 6914 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6915 | VkDescriptorSetObj descriptorSet(m_device); |
| 6916 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6917 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6918 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6919 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6920 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6921 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6922 | } |
| 6923 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6924 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 6925 | m_errorMonitor->SetDesiredFailureMsg( |
| 6926 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6927 | "location 0 does not match VS input type"); |
| 6928 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6930 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6931 | |
| 6932 | VkVertexInputBindingDescription input_binding; |
| 6933 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6934 | |
| 6935 | VkVertexInputAttributeDescription input_attrib; |
| 6936 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6937 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6938 | |
| 6939 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6940 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6941 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6942 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6943 | "out gl_PerVertex {\n" |
| 6944 | " vec4 gl_Position;\n" |
| 6945 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6946 | "void main(){\n" |
| 6947 | " gl_Position = vec4(x);\n" |
| 6948 | "}\n"; |
| 6949 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6950 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6951 | "\n" |
| 6952 | "layout(location=0) out vec4 color;\n" |
| 6953 | "void main(){\n" |
| 6954 | " color = vec4(1);\n" |
| 6955 | "}\n"; |
| 6956 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6957 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6958 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6959 | |
| 6960 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6961 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6962 | pipe.AddShader(&vs); |
| 6963 | pipe.AddShader(&fs); |
| 6964 | |
| 6965 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6966 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6967 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6968 | VkDescriptorSetObj descriptorSet(m_device); |
| 6969 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6970 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6971 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6972 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6973 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6974 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6975 | } |
| 6976 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 6977 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 6978 | m_errorMonitor->SetDesiredFailureMsg( |
| 6979 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6980 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 6981 | |
| 6982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6983 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6984 | |
| 6985 | char const *vsSource = |
| 6986 | "#version 450\n" |
| 6987 | "\n" |
| 6988 | "out gl_PerVertex {\n" |
| 6989 | " vec4 gl_Position;\n" |
| 6990 | "};\n" |
| 6991 | "void main(){\n" |
| 6992 | " gl_Position = vec4(1);\n" |
| 6993 | "}\n"; |
| 6994 | char const *fsSource = |
| 6995 | "#version 450\n" |
| 6996 | "\n" |
| 6997 | "layout(location=0) out vec4 color;\n" |
| 6998 | "void main(){\n" |
| 6999 | " color = vec4(1);\n" |
| 7000 | "}\n"; |
| 7001 | |
| 7002 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7003 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7004 | |
| 7005 | VkPipelineObj pipe(m_device); |
| 7006 | pipe.AddColorAttachment(); |
| 7007 | pipe.AddShader(&vs); |
| 7008 | pipe.AddShader(&vs); |
| 7009 | pipe.AddShader(&fs); |
| 7010 | |
| 7011 | VkDescriptorSetObj descriptorSet(m_device); |
| 7012 | descriptorSet.AppendDummy(); |
| 7013 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7014 | |
| 7015 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7016 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7017 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7018 | } |
| 7019 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7020 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7021 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7022 | |
| 7023 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7024 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7025 | |
| 7026 | VkVertexInputBindingDescription input_binding; |
| 7027 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7028 | |
| 7029 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7030 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7031 | |
| 7032 | for (int i = 0; i < 2; i++) { |
| 7033 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7034 | input_attribs[i].location = i; |
| 7035 | } |
| 7036 | |
| 7037 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7038 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7039 | "\n" |
| 7040 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7041 | "out gl_PerVertex {\n" |
| 7042 | " vec4 gl_Position;\n" |
| 7043 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7044 | "void main(){\n" |
| 7045 | " gl_Position = x[0] + x[1];\n" |
| 7046 | "}\n"; |
| 7047 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7048 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7049 | "\n" |
| 7050 | "layout(location=0) out vec4 color;\n" |
| 7051 | "void main(){\n" |
| 7052 | " color = vec4(1);\n" |
| 7053 | "}\n"; |
| 7054 | |
| 7055 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7056 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7057 | |
| 7058 | VkPipelineObj pipe(m_device); |
| 7059 | pipe.AddColorAttachment(); |
| 7060 | pipe.AddShader(&vs); |
| 7061 | pipe.AddShader(&fs); |
| 7062 | |
| 7063 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7064 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7065 | |
| 7066 | VkDescriptorSetObj descriptorSet(m_device); |
| 7067 | descriptorSet.AppendDummy(); |
| 7068 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7069 | |
| 7070 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7071 | |
| 7072 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7073 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7074 | } |
| 7075 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7076 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7077 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7078 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7079 | |
| 7080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7082 | |
| 7083 | VkVertexInputBindingDescription input_binding; |
| 7084 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7085 | |
| 7086 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7087 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7088 | |
| 7089 | for (int i = 0; i < 2; i++) { |
| 7090 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7091 | input_attribs[i].location = i; |
| 7092 | } |
| 7093 | |
| 7094 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7095 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7096 | "\n" |
| 7097 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7098 | "out gl_PerVertex {\n" |
| 7099 | " vec4 gl_Position;\n" |
| 7100 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7101 | "void main(){\n" |
| 7102 | " gl_Position = x[0] + x[1];\n" |
| 7103 | "}\n"; |
| 7104 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7105 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7106 | "\n" |
| 7107 | "layout(location=0) out vec4 color;\n" |
| 7108 | "void main(){\n" |
| 7109 | " color = vec4(1);\n" |
| 7110 | "}\n"; |
| 7111 | |
| 7112 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7113 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7114 | |
| 7115 | VkPipelineObj pipe(m_device); |
| 7116 | pipe.AddColorAttachment(); |
| 7117 | pipe.AddShader(&vs); |
| 7118 | pipe.AddShader(&fs); |
| 7119 | |
| 7120 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7121 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7122 | |
| 7123 | VkDescriptorSetObj descriptorSet(m_device); |
| 7124 | descriptorSet.AppendDummy(); |
| 7125 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7126 | |
| 7127 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7128 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7129 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7130 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7131 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7132 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7133 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7134 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7135 | |
| 7136 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7137 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7138 | |
| 7139 | char const *vsSource = |
| 7140 | "#version 450\n" |
| 7141 | "out gl_PerVertex {\n" |
| 7142 | " vec4 gl_Position;\n" |
| 7143 | "};\n" |
| 7144 | "void main(){\n" |
| 7145 | " gl_Position = vec4(0);\n" |
| 7146 | "}\n"; |
| 7147 | char const *fsSource = |
| 7148 | "#version 450\n" |
| 7149 | "\n" |
| 7150 | "layout(location=0) out vec4 color;\n" |
| 7151 | "void main(){\n" |
| 7152 | " color = vec4(1);\n" |
| 7153 | "}\n"; |
| 7154 | |
| 7155 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7156 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7157 | |
| 7158 | VkPipelineObj pipe(m_device); |
| 7159 | pipe.AddColorAttachment(); |
| 7160 | pipe.AddShader(&vs); |
| 7161 | pipe.AddShader(&fs); |
| 7162 | |
| 7163 | VkDescriptorSetObj descriptorSet(m_device); |
| 7164 | descriptorSet.AppendDummy(); |
| 7165 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7166 | |
| 7167 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7168 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7169 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7170 | } |
| 7171 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7172 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7173 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7174 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7175 | |
| 7176 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7177 | |
| 7178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7179 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7180 | |
| 7181 | char const *vsSource = |
| 7182 | "#version 450\n" |
| 7183 | "out gl_PerVertex {\n" |
| 7184 | " vec4 gl_Position;\n" |
| 7185 | "};\n" |
| 7186 | "layout(location=0) out vec3 x;\n" |
| 7187 | "layout(location=1) out ivec3 y;\n" |
| 7188 | "layout(location=2) out vec3 z;\n" |
| 7189 | "void main(){\n" |
| 7190 | " gl_Position = vec4(0);\n" |
| 7191 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7192 | "}\n"; |
| 7193 | char const *fsSource = |
| 7194 | "#version 450\n" |
| 7195 | "\n" |
| 7196 | "layout(location=0) out vec4 color;\n" |
| 7197 | "layout(location=0) in float x;\n" |
| 7198 | "layout(location=1) flat in int y;\n" |
| 7199 | "layout(location=2) in vec2 z;\n" |
| 7200 | "void main(){\n" |
| 7201 | " color = vec4(1 + x + y + z.x);\n" |
| 7202 | "}\n"; |
| 7203 | |
| 7204 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7205 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7206 | |
| 7207 | VkPipelineObj pipe(m_device); |
| 7208 | pipe.AddColorAttachment(); |
| 7209 | pipe.AddShader(&vs); |
| 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 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7218 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7219 | } |
| 7220 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7221 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7222 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7223 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7224 | |
| 7225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7226 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7227 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7228 | if (!m_device->phy().features().tessellationShader) { |
| 7229 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7230 | return; |
| 7231 | } |
| 7232 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7233 | char const *vsSource = |
| 7234 | "#version 450\n" |
| 7235 | "void main(){}\n"; |
| 7236 | char const *tcsSource = |
| 7237 | "#version 450\n" |
| 7238 | "layout(location=0) out int x[];\n" |
| 7239 | "layout(vertices=3) out;\n" |
| 7240 | "void main(){\n" |
| 7241 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7242 | " gl_TessLevelInner[0] = 1;\n" |
| 7243 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7244 | "}\n"; |
| 7245 | char const *tesSource = |
| 7246 | "#version 450\n" |
| 7247 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7248 | "layout(location=0) in int x[];\n" |
| 7249 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7250 | "void main(){\n" |
| 7251 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7252 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7253 | "}\n"; |
| 7254 | char const *fsSource = |
| 7255 | "#version 450\n" |
| 7256 | "layout(location=0) out vec4 color;\n" |
| 7257 | "void main(){\n" |
| 7258 | " color = vec4(1);\n" |
| 7259 | "}\n"; |
| 7260 | |
| 7261 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7262 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7263 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7264 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7265 | |
| 7266 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7267 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7268 | nullptr, |
| 7269 | 0, |
| 7270 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7271 | VK_FALSE}; |
| 7272 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7273 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7274 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7275 | nullptr, |
| 7276 | 0, |
| 7277 | 3}; |
| 7278 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7279 | VkPipelineObj pipe(m_device); |
| 7280 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7281 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7282 | pipe.AddColorAttachment(); |
| 7283 | pipe.AddShader(&vs); |
| 7284 | pipe.AddShader(&tcs); |
| 7285 | pipe.AddShader(&tes); |
| 7286 | pipe.AddShader(&fs); |
| 7287 | |
| 7288 | VkDescriptorSetObj descriptorSet(m_device); |
| 7289 | descriptorSet.AppendDummy(); |
| 7290 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7291 | |
| 7292 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7293 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7294 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7295 | } |
| 7296 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7297 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7298 | { |
| 7299 | m_errorMonitor->ExpectSuccess(); |
| 7300 | |
| 7301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7302 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7303 | |
| 7304 | if (!m_device->phy().features().geometryShader) { |
| 7305 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7306 | return; |
| 7307 | } |
| 7308 | |
| 7309 | char const *vsSource = |
| 7310 | "#version 450\n" |
| 7311 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7312 | "void main(){\n" |
| 7313 | " vs_out.x = vec4(1);\n" |
| 7314 | "}\n"; |
| 7315 | char const *gsSource = |
| 7316 | "#version 450\n" |
| 7317 | "layout(triangles) in;\n" |
| 7318 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7319 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7320 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7321 | "void main() {\n" |
| 7322 | " gl_Position = gs_in[0].x;\n" |
| 7323 | " EmitVertex();\n" |
| 7324 | "}\n"; |
| 7325 | char const *fsSource = |
| 7326 | "#version 450\n" |
| 7327 | "layout(location=0) out vec4 color;\n" |
| 7328 | "void main(){\n" |
| 7329 | " color = vec4(1);\n" |
| 7330 | "}\n"; |
| 7331 | |
| 7332 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7333 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7334 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7335 | |
| 7336 | VkPipelineObj pipe(m_device); |
| 7337 | pipe.AddColorAttachment(); |
| 7338 | pipe.AddShader(&vs); |
| 7339 | pipe.AddShader(&gs); |
| 7340 | pipe.AddShader(&fs); |
| 7341 | |
| 7342 | VkDescriptorSetObj descriptorSet(m_device); |
| 7343 | descriptorSet.AppendDummy(); |
| 7344 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7345 | |
| 7346 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7347 | |
| 7348 | m_errorMonitor->VerifyNotFound(); |
| 7349 | } |
| 7350 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7351 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7352 | { |
| 7353 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7354 | "is per-vertex in tessellation control shader stage " |
| 7355 | "but per-patch in tessellation evaluation shader stage"); |
| 7356 | |
| 7357 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7358 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7359 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7360 | if (!m_device->phy().features().tessellationShader) { |
| 7361 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7362 | return; |
| 7363 | } |
| 7364 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7365 | char const *vsSource = |
| 7366 | "#version 450\n" |
| 7367 | "void main(){}\n"; |
| 7368 | char const *tcsSource = |
| 7369 | "#version 450\n" |
| 7370 | "layout(location=0) out int x[];\n" |
| 7371 | "layout(vertices=3) out;\n" |
| 7372 | "void main(){\n" |
| 7373 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7374 | " gl_TessLevelInner[0] = 1;\n" |
| 7375 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7376 | "}\n"; |
| 7377 | char const *tesSource = |
| 7378 | "#version 450\n" |
| 7379 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7380 | "layout(location=0) patch in int x;\n" |
| 7381 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7382 | "void main(){\n" |
| 7383 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7384 | " gl_Position.w = x;\n" |
| 7385 | "}\n"; |
| 7386 | char const *fsSource = |
| 7387 | "#version 450\n" |
| 7388 | "layout(location=0) out vec4 color;\n" |
| 7389 | "void main(){\n" |
| 7390 | " color = vec4(1);\n" |
| 7391 | "}\n"; |
| 7392 | |
| 7393 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7394 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7395 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7396 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7397 | |
| 7398 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7399 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7400 | nullptr, |
| 7401 | 0, |
| 7402 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7403 | VK_FALSE}; |
| 7404 | |
| 7405 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7406 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7407 | nullptr, |
| 7408 | 0, |
| 7409 | 3}; |
| 7410 | |
| 7411 | VkPipelineObj pipe(m_device); |
| 7412 | pipe.SetInputAssembly(&iasci); |
| 7413 | pipe.SetTessellation(&tsci); |
| 7414 | pipe.AddColorAttachment(); |
| 7415 | pipe.AddShader(&vs); |
| 7416 | pipe.AddShader(&tcs); |
| 7417 | pipe.AddShader(&tes); |
| 7418 | pipe.AddShader(&fs); |
| 7419 | |
| 7420 | VkDescriptorSetObj descriptorSet(m_device); |
| 7421 | descriptorSet.AppendDummy(); |
| 7422 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7423 | |
| 7424 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7425 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7426 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7427 | } |
| 7428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7429 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7430 | m_errorMonitor->SetDesiredFailureMsg( |
| 7431 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7432 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7433 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7435 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7436 | |
| 7437 | /* Two binding descriptions for binding 0 */ |
| 7438 | VkVertexInputBindingDescription input_bindings[2]; |
| 7439 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7440 | |
| 7441 | VkVertexInputAttributeDescription input_attrib; |
| 7442 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7443 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7444 | |
| 7445 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7446 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7447 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7448 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7449 | "out gl_PerVertex {\n" |
| 7450 | " vec4 gl_Position;\n" |
| 7451 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7452 | "void main(){\n" |
| 7453 | " gl_Position = vec4(x);\n" |
| 7454 | "}\n"; |
| 7455 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7456 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7457 | "\n" |
| 7458 | "layout(location=0) out vec4 color;\n" |
| 7459 | "void main(){\n" |
| 7460 | " color = vec4(1);\n" |
| 7461 | "}\n"; |
| 7462 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7463 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7464 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7465 | |
| 7466 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7467 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7468 | pipe.AddShader(&vs); |
| 7469 | pipe.AddShader(&fs); |
| 7470 | |
| 7471 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7472 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7473 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7474 | VkDescriptorSetObj descriptorSet(m_device); |
| 7475 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7476 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7477 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7478 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7479 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7480 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7481 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7482 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7483 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7484 | m_errorMonitor->ExpectSuccess(); |
| 7485 | |
| 7486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7488 | |
| 7489 | if (!m_device->phy().features().tessellationShader) { |
| 7490 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7491 | return; |
| 7492 | } |
| 7493 | |
| 7494 | VkVertexInputBindingDescription input_bindings[1]; |
| 7495 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7496 | |
| 7497 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7498 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7499 | input_attribs[0].location = 0; |
| 7500 | input_attribs[0].offset = 0; |
| 7501 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7502 | input_attribs[1].location = 2; |
| 7503 | input_attribs[1].offset = 32; |
| 7504 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7505 | input_attribs[2].location = 4; |
| 7506 | input_attribs[2].offset = 64; |
| 7507 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7508 | input_attribs[3].location = 6; |
| 7509 | input_attribs[3].offset = 96; |
| 7510 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7511 | |
| 7512 | char const *vsSource = |
| 7513 | "#version 450\n" |
| 7514 | "\n" |
| 7515 | "layout(location=0) in dmat4 x;\n" |
| 7516 | "out gl_PerVertex {\n" |
| 7517 | " vec4 gl_Position;\n" |
| 7518 | "};\n" |
| 7519 | "void main(){\n" |
| 7520 | " gl_Position = vec4(x[0][0]);\n" |
| 7521 | "}\n"; |
| 7522 | char const *fsSource = |
| 7523 | "#version 450\n" |
| 7524 | "\n" |
| 7525 | "layout(location=0) out vec4 color;\n" |
| 7526 | "void main(){\n" |
| 7527 | " color = vec4(1);\n" |
| 7528 | "}\n"; |
| 7529 | |
| 7530 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7531 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7532 | |
| 7533 | VkPipelineObj pipe(m_device); |
| 7534 | pipe.AddColorAttachment(); |
| 7535 | pipe.AddShader(&vs); |
| 7536 | pipe.AddShader(&fs); |
| 7537 | |
| 7538 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 7539 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 7540 | |
| 7541 | VkDescriptorSetObj descriptorSet(m_device); |
| 7542 | descriptorSet.AppendDummy(); |
| 7543 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7544 | |
| 7545 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7546 | |
| 7547 | m_errorMonitor->VerifyNotFound(); |
| 7548 | } |
| 7549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7550 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7551 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7552 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7553 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7554 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7555 | |
| 7556 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7557 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7558 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7559 | "out gl_PerVertex {\n" |
| 7560 | " vec4 gl_Position;\n" |
| 7561 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7562 | "void main(){\n" |
| 7563 | " gl_Position = vec4(1);\n" |
| 7564 | "}\n"; |
| 7565 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7566 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7567 | "\n" |
| 7568 | "void main(){\n" |
| 7569 | "}\n"; |
| 7570 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7571 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7572 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7573 | |
| 7574 | VkPipelineObj pipe(m_device); |
| 7575 | pipe.AddShader(&vs); |
| 7576 | pipe.AddShader(&fs); |
| 7577 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7578 | /* set up CB 0, not written */ |
| 7579 | pipe.AddColorAttachment(); |
| 7580 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7581 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7582 | VkDescriptorSetObj descriptorSet(m_device); |
| 7583 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7584 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7585 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7586 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7587 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7588 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7589 | } |
| 7590 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7591 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7592 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7593 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7594 | "FS writes to output location 1 with no matching attachment"); |
| 7595 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7597 | |
| 7598 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7599 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7600 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7601 | "out gl_PerVertex {\n" |
| 7602 | " vec4 gl_Position;\n" |
| 7603 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7604 | "void main(){\n" |
| 7605 | " gl_Position = vec4(1);\n" |
| 7606 | "}\n"; |
| 7607 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7608 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7609 | "\n" |
| 7610 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7611 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7612 | "void main(){\n" |
| 7613 | " x = vec4(1);\n" |
| 7614 | " y = vec4(1);\n" |
| 7615 | "}\n"; |
| 7616 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7617 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7618 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7619 | |
| 7620 | VkPipelineObj pipe(m_device); |
| 7621 | pipe.AddShader(&vs); |
| 7622 | pipe.AddShader(&fs); |
| 7623 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7624 | /* set up CB 0, not written */ |
| 7625 | pipe.AddColorAttachment(); |
| 7626 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7627 | /* FS writes CB 1, but we don't configure it */ |
| 7628 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7629 | VkDescriptorSetObj descriptorSet(m_device); |
| 7630 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7631 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7632 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7633 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7634 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7635 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7636 | } |
| 7637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7638 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7639 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7640 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7641 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7642 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7643 | |
| 7644 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7645 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7646 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7647 | "out gl_PerVertex {\n" |
| 7648 | " vec4 gl_Position;\n" |
| 7649 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7650 | "void main(){\n" |
| 7651 | " gl_Position = vec4(1);\n" |
| 7652 | "}\n"; |
| 7653 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7654 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7655 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7656 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7657 | "void main(){\n" |
| 7658 | " x = ivec4(1);\n" |
| 7659 | "}\n"; |
| 7660 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7661 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7662 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7663 | |
| 7664 | VkPipelineObj pipe(m_device); |
| 7665 | pipe.AddShader(&vs); |
| 7666 | pipe.AddShader(&fs); |
| 7667 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7668 | /* set up CB 0; type is UNORM by default */ |
| 7669 | pipe.AddColorAttachment(); |
| 7670 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7671 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7672 | VkDescriptorSetObj descriptorSet(m_device); |
| 7673 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7674 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7675 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7676 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7677 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7678 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7679 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 7680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7681 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7682 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7683 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7684 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7685 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7686 | |
| 7687 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7688 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7689 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7690 | "out gl_PerVertex {\n" |
| 7691 | " vec4 gl_Position;\n" |
| 7692 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7693 | "void main(){\n" |
| 7694 | " gl_Position = vec4(1);\n" |
| 7695 | "}\n"; |
| 7696 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7697 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7698 | "\n" |
| 7699 | "layout(location=0) out vec4 x;\n" |
| 7700 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 7701 | "void main(){\n" |
| 7702 | " x = vec4(bar.y);\n" |
| 7703 | "}\n"; |
| 7704 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7705 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7706 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7707 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7708 | VkPipelineObj pipe(m_device); |
| 7709 | pipe.AddShader(&vs); |
| 7710 | pipe.AddShader(&fs); |
| 7711 | |
| 7712 | /* set up CB 0; type is UNORM by default */ |
| 7713 | pipe.AddColorAttachment(); |
| 7714 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7715 | |
| 7716 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7717 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7718 | |
| 7719 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7720 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7721 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7722 | } |
| 7723 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7724 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 7725 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7726 | "not declared in layout"); |
| 7727 | |
| 7728 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7729 | |
| 7730 | char const *vsSource = |
| 7731 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7732 | "\n" |
| 7733 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 7734 | "out gl_PerVertex {\n" |
| 7735 | " vec4 gl_Position;\n" |
| 7736 | "};\n" |
| 7737 | "void main(){\n" |
| 7738 | " gl_Position = vec4(consts.x);\n" |
| 7739 | "}\n"; |
| 7740 | char const *fsSource = |
| 7741 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7742 | "\n" |
| 7743 | "layout(location=0) out vec4 x;\n" |
| 7744 | "void main(){\n" |
| 7745 | " x = vec4(1);\n" |
| 7746 | "}\n"; |
| 7747 | |
| 7748 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7749 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7750 | |
| 7751 | VkPipelineObj pipe(m_device); |
| 7752 | pipe.AddShader(&vs); |
| 7753 | pipe.AddShader(&fs); |
| 7754 | |
| 7755 | /* set up CB 0; type is UNORM by default */ |
| 7756 | pipe.AddColorAttachment(); |
| 7757 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7758 | |
| 7759 | VkDescriptorSetObj descriptorSet(m_device); |
| 7760 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7761 | |
| 7762 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7763 | |
| 7764 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7765 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7766 | } |
| 7767 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7768 | #endif // SHADER_CHECKER_TESTS |
| 7769 | |
| 7770 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7771 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7772 | m_errorMonitor->SetDesiredFailureMsg( |
| 7773 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7774 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7775 | |
| 7776 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7777 | |
| 7778 | // Create an image |
| 7779 | VkImage image; |
| 7780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7781 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7782 | const int32_t tex_width = 32; |
| 7783 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7784 | |
| 7785 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7786 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7787 | image_create_info.pNext = NULL; |
| 7788 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7789 | image_create_info.format = tex_format; |
| 7790 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7791 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7792 | image_create_info.extent.depth = 1; |
| 7793 | image_create_info.mipLevels = 1; |
| 7794 | image_create_info.arrayLayers = 1; |
| 7795 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7796 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7797 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7798 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7799 | |
| 7800 | // Introduce error by sending down a bogus width extent |
| 7801 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7802 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7803 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7804 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7805 | } |
| 7806 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7807 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 7808 | m_errorMonitor->SetDesiredFailureMsg( |
| 7809 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7810 | "CreateImage extents is 0 for at least one required dimension"); |
| 7811 | |
| 7812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7813 | |
| 7814 | // Create an image |
| 7815 | VkImage image; |
| 7816 | |
| 7817 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7818 | const int32_t tex_width = 32; |
| 7819 | const int32_t tex_height = 32; |
| 7820 | |
| 7821 | VkImageCreateInfo image_create_info = {}; |
| 7822 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7823 | image_create_info.pNext = NULL; |
| 7824 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7825 | image_create_info.format = tex_format; |
| 7826 | image_create_info.extent.width = tex_width; |
| 7827 | image_create_info.extent.height = tex_height; |
| 7828 | image_create_info.extent.depth = 1; |
| 7829 | image_create_info.mipLevels = 1; |
| 7830 | image_create_info.arrayLayers = 1; |
| 7831 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7832 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7833 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7834 | image_create_info.flags = 0; |
| 7835 | |
| 7836 | // Introduce error by sending down a bogus width extent |
| 7837 | image_create_info.extent.width = 0; |
| 7838 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 7839 | |
| 7840 | m_errorMonitor->VerifyFound(); |
| 7841 | } |
| 7842 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7843 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 7844 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7845 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7847 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7848 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7850 | |
| 7851 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7852 | vk_testing::Buffer buffer; |
| 7853 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7854 | |
| 7855 | BeginCommandBuffer(); |
| 7856 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7857 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7858 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7859 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7860 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7862 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7863 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7864 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7865 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7866 | EndCommandBuffer(); |
| 7867 | } |
| 7868 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7869 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7870 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7871 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7872 | |
| 7873 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7874 | |
| 7875 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7876 | vk_testing::Buffer buffer; |
| 7877 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7878 | |
| 7879 | BeginCommandBuffer(); |
| 7880 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7881 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7882 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7883 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7884 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7885 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7886 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7887 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7888 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7890 | m_errorMonitor->VerifyFound(); |
| 7891 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7892 | EndCommandBuffer(); |
| 7893 | } |
| 7894 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7895 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7896 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7897 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7898 | TEST_F(VkLayerTest, InvalidImageView) { |
| 7899 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7901 | m_errorMonitor->SetDesiredFailureMsg( |
| 7902 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7903 | "vkCreateImageView called with baseMipLevel 10 "); |
| 7904 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7906 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7907 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7908 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7909 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7910 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7911 | const int32_t tex_width = 32; |
| 7912 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7913 | |
| 7914 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7915 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7916 | image_create_info.pNext = NULL; |
| 7917 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7918 | image_create_info.format = tex_format; |
| 7919 | image_create_info.extent.width = tex_width; |
| 7920 | image_create_info.extent.height = tex_height; |
| 7921 | image_create_info.extent.depth = 1; |
| 7922 | image_create_info.mipLevels = 1; |
| 7923 | image_create_info.arrayLayers = 1; |
| 7924 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7925 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7926 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7927 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7928 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7929 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7930 | ASSERT_VK_SUCCESS(err); |
| 7931 | |
| 7932 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7933 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7934 | image_view_create_info.image = image; |
| 7935 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7936 | image_view_create_info.format = tex_format; |
| 7937 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7938 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 7939 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7940 | image_view_create_info.subresourceRange.aspectMask = |
| 7941 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7942 | |
| 7943 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7944 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7945 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7946 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7947 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7948 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7950 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 7951 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7952 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7953 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7954 | "vkCreateImageView: Color image " |
| 7955 | "formats must have ONLY the " |
| 7956 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7957 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7958 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7959 | |
| 7960 | // 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] | 7961 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7962 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7963 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7964 | const int32_t tex_width = 32; |
| 7965 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7966 | |
| 7967 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7968 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7969 | image_create_info.pNext = NULL; |
| 7970 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7971 | image_create_info.format = tex_format; |
| 7972 | image_create_info.extent.width = tex_width; |
| 7973 | image_create_info.extent.height = tex_height; |
| 7974 | image_create_info.extent.depth = 1; |
| 7975 | image_create_info.mipLevels = 1; |
| 7976 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7977 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7978 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7979 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7980 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7981 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7982 | ASSERT_VK_SUCCESS(err); |
| 7983 | |
| 7984 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7985 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7986 | image_view_create_info.image = image; |
| 7987 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7988 | image_view_create_info.format = tex_format; |
| 7989 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7990 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7991 | // Cause an error by setting an invalid image aspect |
| 7992 | image_view_create_info.subresourceRange.aspectMask = |
| 7993 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7994 | |
| 7995 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7996 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7997 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7998 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7999 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8000 | } |
| 8001 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8002 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8003 | VkResult err; |
| 8004 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8005 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8006 | m_errorMonitor->SetDesiredFailureMsg( |
| 8007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8008 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8009 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8010 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8011 | |
| 8012 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8013 | VkImage srcImage; |
| 8014 | VkImage dstImage; |
| 8015 | VkDeviceMemory srcMem; |
| 8016 | VkDeviceMemory destMem; |
| 8017 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8018 | |
| 8019 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8020 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8021 | image_create_info.pNext = NULL; |
| 8022 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8023 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8024 | image_create_info.extent.width = 32; |
| 8025 | image_create_info.extent.height = 32; |
| 8026 | image_create_info.extent.depth = 1; |
| 8027 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8028 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8029 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8030 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8031 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8032 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8033 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8034 | err = |
| 8035 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8036 | ASSERT_VK_SUCCESS(err); |
| 8037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8038 | err = |
| 8039 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8040 | ASSERT_VK_SUCCESS(err); |
| 8041 | |
| 8042 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8043 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8044 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8045 | memAlloc.pNext = NULL; |
| 8046 | memAlloc.allocationSize = 0; |
| 8047 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8048 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8049 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8050 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8051 | pass = |
| 8052 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8053 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8054 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8055 | ASSERT_VK_SUCCESS(err); |
| 8056 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8057 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8058 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8059 | pass = |
| 8060 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8061 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8062 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8063 | ASSERT_VK_SUCCESS(err); |
| 8064 | |
| 8065 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8066 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8067 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8068 | ASSERT_VK_SUCCESS(err); |
| 8069 | |
| 8070 | BeginCommandBuffer(); |
| 8071 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8072 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8073 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8074 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8075 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8076 | copyRegion.srcOffset.x = 0; |
| 8077 | copyRegion.srcOffset.y = 0; |
| 8078 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8079 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8080 | copyRegion.dstSubresource.mipLevel = 0; |
| 8081 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8082 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8083 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8084 | copyRegion.dstOffset.x = 0; |
| 8085 | copyRegion.dstOffset.y = 0; |
| 8086 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8087 | copyRegion.extent.width = 1; |
| 8088 | copyRegion.extent.height = 1; |
| 8089 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8090 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8091 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8092 | EndCommandBuffer(); |
| 8093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8094 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8095 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8096 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8097 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8098 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8099 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8100 | } |
| 8101 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8102 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8103 | VkResult err; |
| 8104 | bool pass; |
| 8105 | |
| 8106 | // Create color images with different format sizes and try to copy between them |
| 8107 | m_errorMonitor->SetDesiredFailureMsg( |
| 8108 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8109 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8110 | |
| 8111 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8112 | |
| 8113 | // Create two images of different types and try to copy between them |
| 8114 | VkImage srcImage; |
| 8115 | VkImage dstImage; |
| 8116 | VkDeviceMemory srcMem; |
| 8117 | VkDeviceMemory destMem; |
| 8118 | VkMemoryRequirements memReqs; |
| 8119 | |
| 8120 | VkImageCreateInfo image_create_info = {}; |
| 8121 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8122 | image_create_info.pNext = NULL; |
| 8123 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8124 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8125 | image_create_info.extent.width = 32; |
| 8126 | image_create_info.extent.height = 32; |
| 8127 | image_create_info.extent.depth = 1; |
| 8128 | image_create_info.mipLevels = 1; |
| 8129 | image_create_info.arrayLayers = 1; |
| 8130 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8131 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8132 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8133 | image_create_info.flags = 0; |
| 8134 | |
| 8135 | err = |
| 8136 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8137 | ASSERT_VK_SUCCESS(err); |
| 8138 | |
| 8139 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8140 | // Introduce failure by creating second image with a different-sized format. |
| 8141 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8142 | |
| 8143 | err = |
| 8144 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8145 | ASSERT_VK_SUCCESS(err); |
| 8146 | |
| 8147 | // Allocate memory |
| 8148 | VkMemoryAllocateInfo memAlloc = {}; |
| 8149 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8150 | memAlloc.pNext = NULL; |
| 8151 | memAlloc.allocationSize = 0; |
| 8152 | memAlloc.memoryTypeIndex = 0; |
| 8153 | |
| 8154 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 8155 | memAlloc.allocationSize = memReqs.size; |
| 8156 | pass = |
| 8157 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8158 | ASSERT_TRUE(pass); |
| 8159 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 8160 | ASSERT_VK_SUCCESS(err); |
| 8161 | |
| 8162 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 8163 | memAlloc.allocationSize = memReqs.size; |
| 8164 | pass = |
| 8165 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8166 | ASSERT_TRUE(pass); |
| 8167 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 8168 | ASSERT_VK_SUCCESS(err); |
| 8169 | |
| 8170 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8171 | ASSERT_VK_SUCCESS(err); |
| 8172 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 8173 | ASSERT_VK_SUCCESS(err); |
| 8174 | |
| 8175 | BeginCommandBuffer(); |
| 8176 | VkImageCopy copyRegion; |
| 8177 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8178 | copyRegion.srcSubresource.mipLevel = 0; |
| 8179 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8180 | copyRegion.srcSubresource.layerCount = 0; |
| 8181 | copyRegion.srcOffset.x = 0; |
| 8182 | copyRegion.srcOffset.y = 0; |
| 8183 | copyRegion.srcOffset.z = 0; |
| 8184 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8185 | copyRegion.dstSubresource.mipLevel = 0; |
| 8186 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8187 | copyRegion.dstSubresource.layerCount = 0; |
| 8188 | copyRegion.dstOffset.x = 0; |
| 8189 | copyRegion.dstOffset.y = 0; |
| 8190 | copyRegion.dstOffset.z = 0; |
| 8191 | copyRegion.extent.width = 1; |
| 8192 | copyRegion.extent.height = 1; |
| 8193 | copyRegion.extent.depth = 1; |
| 8194 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8195 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8196 | EndCommandBuffer(); |
| 8197 | |
| 8198 | m_errorMonitor->VerifyFound(); |
| 8199 | |
| 8200 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 8201 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 8202 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8203 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8204 | } |
| 8205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8206 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 8207 | VkResult err; |
| 8208 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8209 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8210 | // 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] | 8211 | m_errorMonitor->SetDesiredFailureMsg( |
| 8212 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8213 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8214 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8215 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8216 | |
| 8217 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8218 | VkImage srcImage; |
| 8219 | VkImage dstImage; |
| 8220 | VkDeviceMemory srcMem; |
| 8221 | VkDeviceMemory destMem; |
| 8222 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8223 | |
| 8224 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8225 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8226 | image_create_info.pNext = NULL; |
| 8227 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8228 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8229 | image_create_info.extent.width = 32; |
| 8230 | image_create_info.extent.height = 32; |
| 8231 | image_create_info.extent.depth = 1; |
| 8232 | image_create_info.mipLevels = 1; |
| 8233 | image_create_info.arrayLayers = 1; |
| 8234 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8235 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8236 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8237 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8239 | err = |
| 8240 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8241 | ASSERT_VK_SUCCESS(err); |
| 8242 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8243 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8244 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8245 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8246 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8247 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8248 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8249 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8250 | err = |
| 8251 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8252 | ASSERT_VK_SUCCESS(err); |
| 8253 | |
| 8254 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8255 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8257 | memAlloc.pNext = NULL; |
| 8258 | memAlloc.allocationSize = 0; |
| 8259 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8260 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8261 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8262 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8263 | pass = |
| 8264 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8265 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8266 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8267 | ASSERT_VK_SUCCESS(err); |
| 8268 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8269 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8270 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8271 | pass = |
| 8272 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8273 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8274 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8275 | ASSERT_VK_SUCCESS(err); |
| 8276 | |
| 8277 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8278 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8279 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8280 | ASSERT_VK_SUCCESS(err); |
| 8281 | |
| 8282 | BeginCommandBuffer(); |
| 8283 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8284 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8285 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8286 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8287 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8288 | copyRegion.srcOffset.x = 0; |
| 8289 | copyRegion.srcOffset.y = 0; |
| 8290 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8291 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8292 | copyRegion.dstSubresource.mipLevel = 0; |
| 8293 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8294 | copyRegion.dstSubresource.layerCount = 0; |
| 8295 | copyRegion.dstOffset.x = 0; |
| 8296 | copyRegion.dstOffset.y = 0; |
| 8297 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8298 | copyRegion.extent.width = 1; |
| 8299 | copyRegion.extent.height = 1; |
| 8300 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8301 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8302 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8303 | EndCommandBuffer(); |
| 8304 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8305 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8306 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8307 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8308 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8309 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8310 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8311 | } |
| 8312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8313 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 8314 | VkResult err; |
| 8315 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8317 | m_errorMonitor->SetDesiredFailureMsg( |
| 8318 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8319 | "vkCmdResolveImage called with source sample count less than 2."); |
| 8320 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8321 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8322 | |
| 8323 | // 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] | 8324 | VkImage srcImage; |
| 8325 | VkImage dstImage; |
| 8326 | VkDeviceMemory srcMem; |
| 8327 | VkDeviceMemory destMem; |
| 8328 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8329 | |
| 8330 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8331 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8332 | image_create_info.pNext = NULL; |
| 8333 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8334 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8335 | image_create_info.extent.width = 32; |
| 8336 | image_create_info.extent.height = 1; |
| 8337 | image_create_info.extent.depth = 1; |
| 8338 | image_create_info.mipLevels = 1; |
| 8339 | image_create_info.arrayLayers = 1; |
| 8340 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8341 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8342 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8343 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | err = |
| 8346 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8347 | ASSERT_VK_SUCCESS(err); |
| 8348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8350 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8352 | err = |
| 8353 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8354 | ASSERT_VK_SUCCESS(err); |
| 8355 | |
| 8356 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8357 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8358 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8359 | memAlloc.pNext = NULL; |
| 8360 | memAlloc.allocationSize = 0; |
| 8361 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8362 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8363 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8364 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8365 | pass = |
| 8366 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8367 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8368 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8369 | ASSERT_VK_SUCCESS(err); |
| 8370 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8371 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8372 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8373 | pass = |
| 8374 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8375 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8376 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8377 | ASSERT_VK_SUCCESS(err); |
| 8378 | |
| 8379 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8380 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8381 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8382 | ASSERT_VK_SUCCESS(err); |
| 8383 | |
| 8384 | BeginCommandBuffer(); |
| 8385 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8386 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8387 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8388 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8389 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8390 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8391 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8392 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8393 | resolveRegion.srcOffset.x = 0; |
| 8394 | resolveRegion.srcOffset.y = 0; |
| 8395 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8396 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8397 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8398 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8399 | resolveRegion.dstSubresource.layerCount = 0; |
| 8400 | resolveRegion.dstOffset.x = 0; |
| 8401 | resolveRegion.dstOffset.y = 0; |
| 8402 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8403 | resolveRegion.extent.width = 1; |
| 8404 | resolveRegion.extent.height = 1; |
| 8405 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8406 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8407 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8408 | EndCommandBuffer(); |
| 8409 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8410 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8411 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8412 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8413 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8414 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8415 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8416 | } |
| 8417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8418 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 8419 | VkResult err; |
| 8420 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8422 | m_errorMonitor->SetDesiredFailureMsg( |
| 8423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8424 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 8425 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8426 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8427 | |
| 8428 | // 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] | 8429 | VkImage srcImage; |
| 8430 | VkImage dstImage; |
| 8431 | VkDeviceMemory srcMem; |
| 8432 | VkDeviceMemory destMem; |
| 8433 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8434 | |
| 8435 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8436 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8437 | image_create_info.pNext = NULL; |
| 8438 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8439 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8440 | image_create_info.extent.width = 32; |
| 8441 | image_create_info.extent.height = 1; |
| 8442 | image_create_info.extent.depth = 1; |
| 8443 | image_create_info.mipLevels = 1; |
| 8444 | image_create_info.arrayLayers = 1; |
| 8445 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8446 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8447 | // Note: Some implementations expect color attachment usage for any |
| 8448 | // multisample surface |
| 8449 | image_create_info.usage = |
| 8450 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8451 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8453 | err = |
| 8454 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8455 | ASSERT_VK_SUCCESS(err); |
| 8456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8457 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8458 | // Note: Some implementations expect color attachment usage for any |
| 8459 | // multisample surface |
| 8460 | image_create_info.usage = |
| 8461 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8463 | err = |
| 8464 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8465 | ASSERT_VK_SUCCESS(err); |
| 8466 | |
| 8467 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8468 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8469 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8470 | memAlloc.pNext = NULL; |
| 8471 | memAlloc.allocationSize = 0; |
| 8472 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8473 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8474 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8475 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8476 | pass = |
| 8477 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8478 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8479 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8480 | ASSERT_VK_SUCCESS(err); |
| 8481 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8482 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8483 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8484 | pass = |
| 8485 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8486 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8487 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8488 | ASSERT_VK_SUCCESS(err); |
| 8489 | |
| 8490 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8491 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8492 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8493 | ASSERT_VK_SUCCESS(err); |
| 8494 | |
| 8495 | BeginCommandBuffer(); |
| 8496 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8497 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8498 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8499 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8500 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8501 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8502 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8503 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8504 | resolveRegion.srcOffset.x = 0; |
| 8505 | resolveRegion.srcOffset.y = 0; |
| 8506 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8507 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8508 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8509 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8510 | resolveRegion.dstSubresource.layerCount = 0; |
| 8511 | resolveRegion.dstOffset.x = 0; |
| 8512 | resolveRegion.dstOffset.y = 0; |
| 8513 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8514 | resolveRegion.extent.width = 1; |
| 8515 | resolveRegion.extent.height = 1; |
| 8516 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8517 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8518 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8519 | EndCommandBuffer(); |
| 8520 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8521 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8522 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8523 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8524 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8525 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8526 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8527 | } |
| 8528 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8529 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 8530 | VkResult err; |
| 8531 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8533 | m_errorMonitor->SetDesiredFailureMsg( |
| 8534 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8535 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 8536 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8538 | |
| 8539 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8540 | VkImage srcImage; |
| 8541 | VkImage dstImage; |
| 8542 | VkDeviceMemory srcMem; |
| 8543 | VkDeviceMemory destMem; |
| 8544 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8545 | |
| 8546 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8547 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8548 | image_create_info.pNext = NULL; |
| 8549 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8550 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8551 | image_create_info.extent.width = 32; |
| 8552 | image_create_info.extent.height = 1; |
| 8553 | image_create_info.extent.depth = 1; |
| 8554 | image_create_info.mipLevels = 1; |
| 8555 | image_create_info.arrayLayers = 1; |
| 8556 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8557 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8558 | // Note: Some implementations expect color attachment usage for any |
| 8559 | // multisample surface |
| 8560 | image_create_info.usage = |
| 8561 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8562 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8563 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8564 | err = |
| 8565 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8566 | ASSERT_VK_SUCCESS(err); |
| 8567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8568 | // Set format to something other than source image |
| 8569 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 8570 | // Note: Some implementations expect color attachment usage for any |
| 8571 | // multisample surface |
| 8572 | image_create_info.usage = |
| 8573 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8574 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8575 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8576 | err = |
| 8577 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8578 | ASSERT_VK_SUCCESS(err); |
| 8579 | |
| 8580 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8581 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8582 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8583 | memAlloc.pNext = NULL; |
| 8584 | memAlloc.allocationSize = 0; |
| 8585 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8586 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8587 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8588 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8589 | pass = |
| 8590 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8591 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8592 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8593 | ASSERT_VK_SUCCESS(err); |
| 8594 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8595 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8596 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8597 | pass = |
| 8598 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8599 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8600 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8601 | ASSERT_VK_SUCCESS(err); |
| 8602 | |
| 8603 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8604 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8605 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8606 | ASSERT_VK_SUCCESS(err); |
| 8607 | |
| 8608 | BeginCommandBuffer(); |
| 8609 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8610 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8611 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8612 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8613 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8614 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8615 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8616 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8617 | resolveRegion.srcOffset.x = 0; |
| 8618 | resolveRegion.srcOffset.y = 0; |
| 8619 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8620 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8621 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8622 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8623 | resolveRegion.dstSubresource.layerCount = 0; |
| 8624 | resolveRegion.dstOffset.x = 0; |
| 8625 | resolveRegion.dstOffset.y = 0; |
| 8626 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8627 | resolveRegion.extent.width = 1; |
| 8628 | resolveRegion.extent.height = 1; |
| 8629 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8630 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8631 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8632 | EndCommandBuffer(); |
| 8633 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8634 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8635 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8636 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8637 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8638 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8639 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8640 | } |
| 8641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8642 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 8643 | VkResult err; |
| 8644 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8646 | m_errorMonitor->SetDesiredFailureMsg( |
| 8647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8648 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 8649 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8651 | |
| 8652 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8653 | VkImage srcImage; |
| 8654 | VkImage dstImage; |
| 8655 | VkDeviceMemory srcMem; |
| 8656 | VkDeviceMemory destMem; |
| 8657 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8658 | |
| 8659 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8660 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8661 | image_create_info.pNext = NULL; |
| 8662 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8663 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8664 | image_create_info.extent.width = 32; |
| 8665 | image_create_info.extent.height = 1; |
| 8666 | image_create_info.extent.depth = 1; |
| 8667 | image_create_info.mipLevels = 1; |
| 8668 | image_create_info.arrayLayers = 1; |
| 8669 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8670 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8671 | // Note: Some implementations expect color attachment usage for any |
| 8672 | // multisample surface |
| 8673 | image_create_info.usage = |
| 8674 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8675 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8676 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8677 | err = |
| 8678 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8679 | ASSERT_VK_SUCCESS(err); |
| 8680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8681 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8682 | // Note: Some implementations expect color attachment usage for any |
| 8683 | // multisample surface |
| 8684 | image_create_info.usage = |
| 8685 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8686 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8688 | err = |
| 8689 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8690 | ASSERT_VK_SUCCESS(err); |
| 8691 | |
| 8692 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8693 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8694 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8695 | memAlloc.pNext = NULL; |
| 8696 | memAlloc.allocationSize = 0; |
| 8697 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8698 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8699 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8700 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8701 | pass = |
| 8702 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8703 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8704 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8705 | ASSERT_VK_SUCCESS(err); |
| 8706 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8707 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8708 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8709 | pass = |
| 8710 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8711 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8712 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8713 | ASSERT_VK_SUCCESS(err); |
| 8714 | |
| 8715 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8716 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8717 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8718 | ASSERT_VK_SUCCESS(err); |
| 8719 | |
| 8720 | BeginCommandBuffer(); |
| 8721 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8722 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8723 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8724 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8725 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8726 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8727 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8728 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8729 | resolveRegion.srcOffset.x = 0; |
| 8730 | resolveRegion.srcOffset.y = 0; |
| 8731 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8732 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8733 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8734 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8735 | resolveRegion.dstSubresource.layerCount = 0; |
| 8736 | resolveRegion.dstOffset.x = 0; |
| 8737 | resolveRegion.dstOffset.y = 0; |
| 8738 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8739 | resolveRegion.extent.width = 1; |
| 8740 | resolveRegion.extent.height = 1; |
| 8741 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8742 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8743 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8744 | EndCommandBuffer(); |
| 8745 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8746 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8747 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8748 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8749 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8750 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8751 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8752 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8754 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8755 | // 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] | 8756 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 8757 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8758 | // The image format check comes 2nd in validation so we trigger it first, |
| 8759 | // 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] | 8760 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8762 | m_errorMonitor->SetDesiredFailureMsg( |
| 8763 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8764 | "Combination depth/stencil image formats can have only the "); |
| 8765 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8766 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8767 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8768 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8769 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8770 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8771 | |
| 8772 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8773 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8774 | ds_pool_ci.pNext = NULL; |
| 8775 | ds_pool_ci.maxSets = 1; |
| 8776 | ds_pool_ci.poolSizeCount = 1; |
| 8777 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8778 | |
| 8779 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8780 | err = |
| 8781 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8782 | ASSERT_VK_SUCCESS(err); |
| 8783 | |
| 8784 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8785 | dsl_binding.binding = 0; |
| 8786 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8787 | dsl_binding.descriptorCount = 1; |
| 8788 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8789 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8790 | |
| 8791 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8792 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8793 | ds_layout_ci.pNext = NULL; |
| 8794 | ds_layout_ci.bindingCount = 1; |
| 8795 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8796 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8797 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8798 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8799 | ASSERT_VK_SUCCESS(err); |
| 8800 | |
| 8801 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8802 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8803 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8804 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8805 | alloc_info.descriptorPool = ds_pool; |
| 8806 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8807 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8808 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8809 | ASSERT_VK_SUCCESS(err); |
| 8810 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8811 | VkImage image_bad; |
| 8812 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8813 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8814 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8815 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8816 | const int32_t tex_width = 32; |
| 8817 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8818 | |
| 8819 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8820 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8821 | image_create_info.pNext = NULL; |
| 8822 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8823 | image_create_info.format = tex_format_bad; |
| 8824 | image_create_info.extent.width = tex_width; |
| 8825 | image_create_info.extent.height = tex_height; |
| 8826 | image_create_info.extent.depth = 1; |
| 8827 | image_create_info.mipLevels = 1; |
| 8828 | image_create_info.arrayLayers = 1; |
| 8829 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8830 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8831 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 8832 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 8833 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8835 | err = |
| 8836 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8837 | ASSERT_VK_SUCCESS(err); |
| 8838 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8839 | image_create_info.usage = |
| 8840 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8841 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 8842 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8843 | ASSERT_VK_SUCCESS(err); |
| 8844 | |
| 8845 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8846 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8847 | image_view_create_info.image = image_bad; |
| 8848 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8849 | image_view_create_info.format = tex_format_bad; |
| 8850 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 8851 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8852 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8853 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8854 | image_view_create_info.subresourceRange.aspectMask = |
| 8855 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8856 | |
| 8857 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8858 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8859 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8860 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8861 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8862 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8863 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 8864 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8865 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8866 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8867 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8868 | #endif // IMAGE_TESTS |
| 8869 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8870 | int main(int argc, char **argv) { |
| 8871 | int result; |
| 8872 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 8873 | #ifdef ANDROID |
| 8874 | int vulkanSupport = InitVulkan(); |
| 8875 | if (vulkanSupport == 0) |
| 8876 | return 1; |
| 8877 | #endif |
| 8878 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8879 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8880 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8881 | |
| 8882 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 8883 | |
| 8884 | result = RUN_ALL_TESTS(); |
| 8885 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8886 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8887 | return result; |
| 8888 | } |