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( |
| 2860 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2861 | "Attempt to update descriptor with invalid bufferView "); |
| 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); |
| 3008 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3009 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3010 | buffInfo.buffer = dyub; |
| 3011 | buffInfo.offset = 0; |
| 3012 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3013 | |
| 3014 | VkWriteDescriptorSet descriptor_write; |
| 3015 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3016 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3017 | descriptor_write.dstSet = descriptorSet; |
| 3018 | descriptor_write.dstBinding = 0; |
| 3019 | descriptor_write.descriptorCount = 1; |
| 3020 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3021 | descriptor_write.pBufferInfo = &buffInfo; |
| 3022 | |
| 3023 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3024 | |
| 3025 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3026 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3027 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3028 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3029 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3030 | uint32_t pDynOff[2] = {512, 756}; |
| 3031 | // 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] | 3032 | m_errorMonitor->SetDesiredFailureMsg( |
| 3033 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3034 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3035 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3036 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3037 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3038 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3039 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3040 | m_errorMonitor->SetDesiredFailureMsg( |
| 3041 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3042 | " from its update, this oversteps its buffer ("); |
| 3043 | // Create PSO to be used for draw-time errors below |
| 3044 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3045 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3046 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3047 | "out gl_PerVertex { \n" |
| 3048 | " vec4 gl_Position;\n" |
| 3049 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3050 | "void main(){\n" |
| 3051 | " gl_Position = vec4(1);\n" |
| 3052 | "}\n"; |
| 3053 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3054 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3055 | "\n" |
| 3056 | "layout(location=0) out vec4 x;\n" |
| 3057 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3058 | "void main(){\n" |
| 3059 | " x = vec4(bar.y);\n" |
| 3060 | "}\n"; |
| 3061 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3062 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3063 | VkPipelineObj pipe(m_device); |
| 3064 | pipe.AddShader(&vs); |
| 3065 | pipe.AddShader(&fs); |
| 3066 | pipe.AddColorAttachment(); |
| 3067 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3068 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3069 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3070 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3071 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3072 | // /w range 1024 & size 1024 |
| 3073 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3074 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3075 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3076 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3077 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3078 | |
| 3079 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3080 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3081 | } |
| 3082 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3083 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3084 | // Hit push constant error cases: |
| 3085 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3086 | // 2. Incorrectly set push constant size to 0 |
| 3087 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3088 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3089 | VkResult err; |
| 3090 | m_errorMonitor->SetDesiredFailureMsg( |
| 3091 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3092 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3093 | |
| 3094 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3095 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3096 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3097 | |
| 3098 | VkPushConstantRange pc_range = {}; |
| 3099 | pc_range.size = 0xFFFFFFFFu; |
| 3100 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3101 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3102 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3103 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3104 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3105 | |
| 3106 | VkPipelineLayout pipeline_layout; |
| 3107 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3108 | &pipeline_layout); |
| 3109 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3110 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3111 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3112 | pc_range.size = 0; |
| 3113 | m_errorMonitor->SetDesiredFailureMsg( |
| 3114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3115 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3116 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3117 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3118 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3119 | pc_range.size = 1; |
| 3120 | m_errorMonitor->SetDesiredFailureMsg( |
| 3121 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3122 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3123 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3124 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3125 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3126 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3127 | m_errorMonitor->SetDesiredFailureMsg( |
| 3128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3129 | "vkCmdPushConstants() call has push constants with offset "); |
| 3130 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3131 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3132 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3133 | &pipeline_layout); |
| 3134 | ASSERT_VK_SUCCESS(err); |
| 3135 | BeginCommandBuffer(); |
| 3136 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3137 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3138 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3139 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3140 | } |
| 3141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3142 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3143 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3144 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3145 | |
| 3146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3147 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3148 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3149 | |
| 3150 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3151 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3152 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3153 | ds_type_count[0].descriptorCount = 10; |
| 3154 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3155 | ds_type_count[1].descriptorCount = 2; |
| 3156 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3157 | ds_type_count[2].descriptorCount = 2; |
| 3158 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3159 | ds_type_count[3].descriptorCount = 5; |
| 3160 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3161 | // type |
| 3162 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3163 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3164 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3165 | |
| 3166 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3167 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3168 | ds_pool_ci.pNext = NULL; |
| 3169 | ds_pool_ci.maxSets = 5; |
| 3170 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3171 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3172 | |
| 3173 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | err = |
| 3175 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3176 | ASSERT_VK_SUCCESS(err); |
| 3177 | |
| 3178 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3179 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3180 | dsl_binding[0].binding = 0; |
| 3181 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3182 | dsl_binding[0].descriptorCount = 5; |
| 3183 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3184 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3185 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3186 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3187 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3188 | dsl_fs_stage_only.binding = 0; |
| 3189 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3190 | dsl_fs_stage_only.descriptorCount = 5; |
| 3191 | dsl_fs_stage_only.stageFlags = |
| 3192 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3193 | // bind time |
| 3194 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3195 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3196 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3197 | ds_layout_ci.pNext = NULL; |
| 3198 | ds_layout_ci.bindingCount = 1; |
| 3199 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3200 | static const uint32_t NUM_LAYOUTS = 4; |
| 3201 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3202 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3203 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3204 | // layout for error case |
| 3205 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3206 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3207 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3208 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3209 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3210 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3211 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3212 | dsl_binding[0].binding = 0; |
| 3213 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3214 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3215 | dsl_binding[1].binding = 1; |
| 3216 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3217 | dsl_binding[1].descriptorCount = 2; |
| 3218 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3219 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3220 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3221 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3222 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3223 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3224 | ASSERT_VK_SUCCESS(err); |
| 3225 | dsl_binding[0].binding = 0; |
| 3226 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3227 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3228 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3229 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3230 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3231 | ASSERT_VK_SUCCESS(err); |
| 3232 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3233 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3234 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3235 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3236 | ASSERT_VK_SUCCESS(err); |
| 3237 | |
| 3238 | static const uint32_t NUM_SETS = 4; |
| 3239 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3240 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3241 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3242 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3243 | alloc_info.descriptorPool = ds_pool; |
| 3244 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3245 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3246 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3247 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3248 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3249 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3250 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | err = |
| 3252 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3253 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3254 | |
| 3255 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3256 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3257 | pipeline_layout_ci.pNext = NULL; |
| 3258 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3259 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3260 | |
| 3261 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3262 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3263 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3264 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3265 | // Create pipelineLayout with only one setLayout |
| 3266 | pipeline_layout_ci.setLayoutCount = 1; |
| 3267 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3268 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3269 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3270 | ASSERT_VK_SUCCESS(err); |
| 3271 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3272 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3273 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3274 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3275 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3276 | ASSERT_VK_SUCCESS(err); |
| 3277 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3278 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3279 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3280 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3281 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3282 | ASSERT_VK_SUCCESS(err); |
| 3283 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3284 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3285 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3286 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3287 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3288 | ASSERT_VK_SUCCESS(err); |
| 3289 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3290 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3291 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3292 | pl_bad_s0[1] = ds_layout[1]; |
| 3293 | pipeline_layout_ci.setLayoutCount = 2; |
| 3294 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3295 | VkPipelineLayout pipe_layout_bad_set0; |
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_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3298 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3299 | |
| 3300 | // Create a buffer to update the descriptor with |
| 3301 | uint32_t qfi = 0; |
| 3302 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3303 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3304 | buffCI.size = 1024; |
| 3305 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3306 | buffCI.queueFamilyIndexCount = 1; |
| 3307 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3308 | |
| 3309 | VkBuffer dyub; |
| 3310 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3311 | ASSERT_VK_SUCCESS(err); |
| 3312 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3313 | static const uint32_t NUM_BUFFS = 5; |
| 3314 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3315 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3316 | buffInfo[i].buffer = dyub; |
| 3317 | buffInfo[i].offset = 0; |
| 3318 | buffInfo[i].range = 1024; |
| 3319 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3320 | VkImage image; |
| 3321 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3322 | const int32_t tex_width = 32; |
| 3323 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3324 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3325 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3326 | image_create_info.pNext = NULL; |
| 3327 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3328 | image_create_info.format = tex_format; |
| 3329 | image_create_info.extent.width = tex_width; |
| 3330 | image_create_info.extent.height = tex_height; |
| 3331 | image_create_info.extent.depth = 1; |
| 3332 | image_create_info.mipLevels = 1; |
| 3333 | image_create_info.arrayLayers = 1; |
| 3334 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3335 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3336 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3337 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3338 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3339 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3341 | VkMemoryRequirements memReqs; |
| 3342 | VkDeviceMemory imageMem; |
| 3343 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3344 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3345 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3346 | memAlloc.pNext = NULL; |
| 3347 | memAlloc.allocationSize = 0; |
| 3348 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3349 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3350 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3351 | pass = |
| 3352 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3353 | ASSERT_TRUE(pass); |
| 3354 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3355 | ASSERT_VK_SUCCESS(err); |
| 3356 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3357 | ASSERT_VK_SUCCESS(err); |
| 3358 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3359 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3360 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3361 | image_view_create_info.image = image; |
| 3362 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3363 | image_view_create_info.format = tex_format; |
| 3364 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3365 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3366 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3367 | image_view_create_info.subresourceRange.aspectMask = |
| 3368 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3369 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3370 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3371 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3372 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3373 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3374 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3375 | imageInfo[0].imageView = view; |
| 3376 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3377 | imageInfo[1].imageView = view; |
| 3378 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3379 | imageInfo[2].imageView = view; |
| 3380 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3381 | imageInfo[3].imageView = view; |
| 3382 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3383 | |
| 3384 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3385 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3386 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3387 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3388 | descriptor_write[0].dstBinding = 0; |
| 3389 | descriptor_write[0].descriptorCount = 5; |
| 3390 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3391 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3392 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3393 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3394 | descriptor_write[1].dstBinding = 0; |
| 3395 | descriptor_write[1].descriptorCount = 2; |
| 3396 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3397 | descriptor_write[1].pImageInfo = imageInfo; |
| 3398 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3399 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3400 | descriptor_write[2].dstBinding = 1; |
| 3401 | descriptor_write[2].descriptorCount = 2; |
| 3402 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3403 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3404 | |
| 3405 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3406 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3407 | // Create PSO to be used for draw-time errors below |
| 3408 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3409 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3410 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3411 | "out gl_PerVertex {\n" |
| 3412 | " vec4 gl_Position;\n" |
| 3413 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3414 | "void main(){\n" |
| 3415 | " gl_Position = vec4(1);\n" |
| 3416 | "}\n"; |
| 3417 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3418 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3419 | "\n" |
| 3420 | "layout(location=0) out vec4 x;\n" |
| 3421 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3422 | "void main(){\n" |
| 3423 | " x = vec4(bar.y);\n" |
| 3424 | "}\n"; |
| 3425 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3426 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3427 | VkPipelineObj pipe(m_device); |
| 3428 | pipe.AddShader(&vs); |
| 3429 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3430 | pipe.AddColorAttachment(); |
| 3431 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3432 | |
| 3433 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3434 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3435 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3436 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3437 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3438 | // of PSO |
| 3439 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3440 | // cmd_pipeline.c |
| 3441 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3442 | // cmd_bind_graphics_pipeline() |
| 3443 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3444 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3445 | // First cause various verify_layout_compatibility() fails |
| 3446 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3447 | // verify_set_layout_compatibility fail cases: |
| 3448 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3449 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3450 | " due to: invalid VkPipelineLayout "); |
| 3451 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3452 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3453 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3454 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3455 | m_errorMonitor->VerifyFound(); |
| 3456 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3457 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3458 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3459 | " attempting to bind set to index 1"); |
| 3460 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3461 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3462 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3463 | m_errorMonitor->VerifyFound(); |
| 3464 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3465 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3467 | // descriptors |
| 3468 | m_errorMonitor->SetDesiredFailureMsg( |
| 3469 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3470 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3471 | vkCmdBindDescriptorSets( |
| 3472 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3473 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3474 | m_errorMonitor->VerifyFound(); |
| 3475 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3476 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3477 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3478 | m_errorMonitor->SetDesiredFailureMsg( |
| 3479 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3480 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3481 | vkCmdBindDescriptorSets( |
| 3482 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3483 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3484 | m_errorMonitor->VerifyFound(); |
| 3485 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3486 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3487 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3488 | m_errorMonitor->SetDesiredFailureMsg( |
| 3489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3490 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3491 | vkCmdBindDescriptorSets( |
| 3492 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3493 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3494 | m_errorMonitor->VerifyFound(); |
| 3495 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3496 | // Cause INFO messages due to disturbing previously bound Sets |
| 3497 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3498 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3499 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3500 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3501 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3502 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3503 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3504 | " previously bound as set #0 was disturbed "); |
| 3505 | vkCmdBindDescriptorSets( |
| 3506 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3507 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3508 | m_errorMonitor->VerifyFound(); |
| 3509 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3510 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3511 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3512 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3513 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3515 | " newly bound as set #0 so set #1 and " |
| 3516 | "any subsequent sets were disturbed "); |
| 3517 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3518 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3519 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3520 | m_errorMonitor->VerifyFound(); |
| 3521 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3522 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3523 | // 1. Error due to not binding required set (we actually use same code as |
| 3524 | // above to disturb set0) |
| 3525 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3526 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3527 | 2, &descriptorSet[0], 0, NULL); |
| 3528 | vkCmdBindDescriptorSets( |
| 3529 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3530 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3531 | m_errorMonitor->SetDesiredFailureMsg( |
| 3532 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3533 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3534 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3535 | m_errorMonitor->VerifyFound(); |
| 3536 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3537 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3538 | // 2. Error due to bound set not being compatible with PSO's |
| 3539 | // VkPipelineLayout (diff stageFlags in this case) |
| 3540 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3541 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3542 | 2, &descriptorSet[0], 0, NULL); |
| 3543 | m_errorMonitor->SetDesiredFailureMsg( |
| 3544 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3545 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3546 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3547 | m_errorMonitor->VerifyFound(); |
| 3548 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3549 | // Remaining clean-up |
| 3550 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3551 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3552 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3553 | } |
| 3554 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 3555 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 3556 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3557 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3559 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3561 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3563 | m_errorMonitor->SetDesiredFailureMsg( |
| 3564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3565 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3566 | |
| 3567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3568 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3569 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3570 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3571 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3572 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3573 | } |
| 3574 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3575 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3576 | VkResult err; |
| 3577 | VkCommandBuffer draw_cmd; |
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, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3581 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3582 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3583 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3584 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3585 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3586 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3587 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3588 | cmd.commandPool = m_commandPool; |
| 3589 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3590 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3591 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3592 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3593 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3594 | |
| 3595 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3596 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3597 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3598 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3599 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3601 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3602 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3603 | |
| 3604 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3605 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3606 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3607 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3608 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3609 | } |
| 3610 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3611 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3612 | // Cause error due to Begin while recording CB |
| 3613 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3614 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3615 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3616 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3617 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3618 | |
| 3619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3620 | |
| 3621 | // Calls AllocateCommandBuffers |
| 3622 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3624 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3625 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3626 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3627 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3628 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3629 | cmd_buf_info.pNext = NULL; |
| 3630 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3631 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3632 | |
| 3633 | // Begin CB to transition to recording state |
| 3634 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3635 | // Can't re-begin. This should trigger error |
| 3636 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3637 | m_errorMonitor->VerifyFound(); |
| 3638 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3639 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3640 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3641 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3642 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3643 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3644 | m_errorMonitor->VerifyFound(); |
| 3645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | m_errorMonitor->SetDesiredFailureMsg( |
| 3647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3648 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3649 | // Transition CB to RECORDED state |
| 3650 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3651 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3652 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3653 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3654 | } |
| 3655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3656 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3657 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3658 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3659 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3660 | m_errorMonitor->SetDesiredFailureMsg( |
| 3661 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3662 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3663 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3665 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3666 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3667 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3668 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3669 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3670 | |
| 3671 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3672 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3673 | ds_pool_ci.pNext = NULL; |
| 3674 | ds_pool_ci.maxSets = 1; |
| 3675 | ds_pool_ci.poolSizeCount = 1; |
| 3676 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3677 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3678 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3679 | err = |
| 3680 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3681 | ASSERT_VK_SUCCESS(err); |
| 3682 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3683 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3684 | dsl_binding.binding = 0; |
| 3685 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3686 | dsl_binding.descriptorCount = 1; |
| 3687 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3688 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3689 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3690 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3691 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3692 | ds_layout_ci.pNext = NULL; |
| 3693 | ds_layout_ci.bindingCount = 1; |
| 3694 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3695 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3696 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3697 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3698 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3699 | ASSERT_VK_SUCCESS(err); |
| 3700 | |
| 3701 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3702 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3703 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3704 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3705 | alloc_info.descriptorPool = ds_pool; |
| 3706 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3707 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3708 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3709 | ASSERT_VK_SUCCESS(err); |
| 3710 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3711 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3712 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3713 | pipeline_layout_ci.setLayoutCount = 1; |
| 3714 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3715 | |
| 3716 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3717 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3718 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3719 | ASSERT_VK_SUCCESS(err); |
| 3720 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3721 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3722 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3723 | |
| 3724 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3725 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3726 | vp_state_ci.scissorCount = 1; |
| 3727 | vp_state_ci.pScissors = ≻ |
| 3728 | vp_state_ci.viewportCount = 1; |
| 3729 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3730 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3731 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3732 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3733 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3734 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3735 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3736 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3737 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3738 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3739 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3740 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3741 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3742 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3743 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3744 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3745 | gp_ci.layout = pipeline_layout; |
| 3746 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3747 | |
| 3748 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3749 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3750 | pc_ci.initialDataSize = 0; |
| 3751 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3752 | |
| 3753 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3754 | VkPipelineCache pipelineCache; |
| 3755 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3756 | err = |
| 3757 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3758 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3759 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3760 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3761 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3762 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3763 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3764 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3765 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3766 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3767 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3768 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3769 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 3770 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 3771 | { |
| 3772 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3773 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3774 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3775 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3776 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 3777 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3778 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3779 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3780 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3781 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3782 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3783 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3784 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3785 | |
| 3786 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3787 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3788 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3789 | ds_pool_ci.poolSizeCount = 1; |
| 3790 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3791 | |
| 3792 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3793 | err = vkCreateDescriptorPool(m_device->device(), |
| 3794 | 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] | 3795 | ASSERT_VK_SUCCESS(err); |
| 3796 | |
| 3797 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3798 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3799 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3800 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3801 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3802 | dsl_binding.pImmutableSamplers = NULL; |
| 3803 | |
| 3804 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3805 | ds_layout_ci.sType = |
| 3806 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3807 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3808 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3809 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3810 | |
| 3811 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3812 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3813 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3814 | ASSERT_VK_SUCCESS(err); |
| 3815 | |
| 3816 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3817 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 3818 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3819 | ASSERT_VK_SUCCESS(err); |
| 3820 | |
| 3821 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3822 | pipeline_layout_ci.sType = |
| 3823 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3824 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3825 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3826 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3827 | |
| 3828 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3829 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3830 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3831 | ASSERT_VK_SUCCESS(err); |
| 3832 | |
| 3833 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 3834 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3835 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3836 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 3837 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3838 | // 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] | 3839 | VkShaderObj |
| 3840 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 3841 | this); |
| 3842 | VkShaderObj |
| 3843 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 3844 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3845 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3846 | shaderStages[0].sType = |
| 3847 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3848 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3849 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3850 | shaderStages[1].sType = |
| 3851 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3852 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3853 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3854 | shaderStages[2].sType = |
| 3855 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3856 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3857 | shaderStages[2].shader = te.handle(); |
| 3858 | |
| 3859 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3860 | iaCI.sType = |
| 3861 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3862 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3863 | |
| 3864 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 3865 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 3866 | tsCI.patchControlPoints = 0; // This will cause an error |
| 3867 | |
| 3868 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3869 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3870 | gp_ci.pNext = NULL; |
| 3871 | gp_ci.stageCount = 3; |
| 3872 | gp_ci.pStages = shaderStages; |
| 3873 | gp_ci.pVertexInputState = NULL; |
| 3874 | gp_ci.pInputAssemblyState = &iaCI; |
| 3875 | gp_ci.pTessellationState = &tsCI; |
| 3876 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3877 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3878 | gp_ci.pMultisampleState = NULL; |
| 3879 | gp_ci.pDepthStencilState = NULL; |
| 3880 | gp_ci.pColorBlendState = NULL; |
| 3881 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3882 | gp_ci.layout = pipeline_layout; |
| 3883 | gp_ci.renderPass = renderPass(); |
| 3884 | |
| 3885 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3886 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3887 | pc_ci.pNext = NULL; |
| 3888 | pc_ci.initialSize = 0; |
| 3889 | pc_ci.initialData = 0; |
| 3890 | pc_ci.maxSize = 0; |
| 3891 | |
| 3892 | VkPipeline pipeline; |
| 3893 | VkPipelineCache pipelineCache; |
| 3894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3895 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 3896 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3897 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3898 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3899 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3900 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3901 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3902 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3903 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3904 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3905 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3906 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3907 | } |
| 3908 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3909 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3910 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3911 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3913 | m_errorMonitor->SetDesiredFailureMsg( |
| 3914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3915 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 3916 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3919 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3920 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3921 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3922 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3923 | |
| 3924 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3925 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3926 | ds_pool_ci.maxSets = 1; |
| 3927 | ds_pool_ci.poolSizeCount = 1; |
| 3928 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3929 | |
| 3930 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | err = |
| 3932 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3933 | ASSERT_VK_SUCCESS(err); |
| 3934 | |
| 3935 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3936 | dsl_binding.binding = 0; |
| 3937 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3938 | dsl_binding.descriptorCount = 1; |
| 3939 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3940 | |
| 3941 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3942 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3943 | ds_layout_ci.bindingCount = 1; |
| 3944 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3945 | |
| 3946 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3947 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3948 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3949 | ASSERT_VK_SUCCESS(err); |
| 3950 | |
| 3951 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3952 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3953 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3954 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3955 | alloc_info.descriptorPool = ds_pool; |
| 3956 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3957 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3958 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3959 | ASSERT_VK_SUCCESS(err); |
| 3960 | |
| 3961 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3962 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3963 | pipeline_layout_ci.setLayoutCount = 1; |
| 3964 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3965 | |
| 3966 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3967 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3968 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3969 | ASSERT_VK_SUCCESS(err); |
| 3970 | |
| 3971 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3972 | |
| 3973 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3974 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3975 | vp_state_ci.scissorCount = 0; |
| 3976 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 3977 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3978 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3979 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3980 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3981 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3982 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3983 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3984 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3985 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3986 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3987 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3988 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3990 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3991 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3992 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3993 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3994 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3995 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3996 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3997 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3998 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3999 | |
| 4000 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4001 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4002 | gp_ci.stageCount = 2; |
| 4003 | gp_ci.pStages = shaderStages; |
| 4004 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4005 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4006 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4007 | gp_ci.layout = pipeline_layout; |
| 4008 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4009 | |
| 4010 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4011 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4012 | |
| 4013 | VkPipeline pipeline; |
| 4014 | VkPipelineCache pipelineCache; |
| 4015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4016 | err = |
| 4017 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4018 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4019 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4020 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4021 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4022 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4023 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4024 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4025 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4026 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4027 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4028 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4029 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4030 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4031 | // 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] | 4032 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4033 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4036 | m_errorMonitor->SetDesiredFailureMsg( |
| 4037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4038 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4039 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4040 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4041 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4042 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4043 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4044 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4045 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4046 | |
| 4047 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4048 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4049 | ds_pool_ci.maxSets = 1; |
| 4050 | ds_pool_ci.poolSizeCount = 1; |
| 4051 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4052 | |
| 4053 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4054 | err = |
| 4055 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4056 | ASSERT_VK_SUCCESS(err); |
| 4057 | |
| 4058 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4059 | dsl_binding.binding = 0; |
| 4060 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4061 | dsl_binding.descriptorCount = 1; |
| 4062 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4063 | |
| 4064 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4065 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4066 | ds_layout_ci.bindingCount = 1; |
| 4067 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4068 | |
| 4069 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4071 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4072 | ASSERT_VK_SUCCESS(err); |
| 4073 | |
| 4074 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4075 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4076 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4077 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4078 | alloc_info.descriptorPool = ds_pool; |
| 4079 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4080 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4081 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4082 | ASSERT_VK_SUCCESS(err); |
| 4083 | |
| 4084 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4086 | pipeline_layout_ci.setLayoutCount = 1; |
| 4087 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4088 | |
| 4089 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4091 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4092 | ASSERT_VK_SUCCESS(err); |
| 4093 | |
| 4094 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4095 | // Set scissor as dynamic to avoid second error |
| 4096 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4097 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4098 | dyn_state_ci.dynamicStateCount = 1; |
| 4099 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4100 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4101 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4104 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4105 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4106 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4107 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4108 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4109 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4110 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4111 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4112 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4113 | |
| 4114 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4115 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4116 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4117 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4118 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4119 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4120 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4121 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4122 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4123 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4125 | gp_ci.stageCount = 2; |
| 4126 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4127 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4128 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4129 | // should cause validation error |
| 4130 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4131 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4132 | gp_ci.layout = pipeline_layout; |
| 4133 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4134 | |
| 4135 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4136 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4137 | |
| 4138 | VkPipeline pipeline; |
| 4139 | VkPipelineCache pipelineCache; |
| 4140 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4141 | err = |
| 4142 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4143 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4144 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4145 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4147 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4148 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4149 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4150 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4151 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4152 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4153 | } |
| 4154 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4155 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4156 | // count |
| 4157 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4158 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4160 | m_errorMonitor->SetDesiredFailureMsg( |
| 4161 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4162 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4163 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4165 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4166 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4167 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4168 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4169 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4170 | |
| 4171 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4172 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4173 | ds_pool_ci.maxSets = 1; |
| 4174 | ds_pool_ci.poolSizeCount = 1; |
| 4175 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4176 | |
| 4177 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4178 | err = |
| 4179 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4180 | ASSERT_VK_SUCCESS(err); |
| 4181 | |
| 4182 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4183 | dsl_binding.binding = 0; |
| 4184 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4185 | dsl_binding.descriptorCount = 1; |
| 4186 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4187 | |
| 4188 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4189 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4190 | ds_layout_ci.bindingCount = 1; |
| 4191 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4192 | |
| 4193 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4194 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4195 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4196 | ASSERT_VK_SUCCESS(err); |
| 4197 | |
| 4198 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4199 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4200 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4201 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4202 | alloc_info.descriptorPool = ds_pool; |
| 4203 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4204 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4205 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4206 | ASSERT_VK_SUCCESS(err); |
| 4207 | |
| 4208 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4209 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4210 | pipeline_layout_ci.setLayoutCount = 1; |
| 4211 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4212 | |
| 4213 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4214 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4215 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4216 | ASSERT_VK_SUCCESS(err); |
| 4217 | |
| 4218 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4219 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4220 | vp_state_ci.viewportCount = 1; |
| 4221 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4222 | vp_state_ci.scissorCount = 1; |
| 4223 | vp_state_ci.pScissors = |
| 4224 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4225 | |
| 4226 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4227 | // Set scissor as dynamic to avoid that error |
| 4228 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4229 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4230 | dyn_state_ci.dynamicStateCount = 1; |
| 4231 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4232 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4233 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4234 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4235 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4236 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4237 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4238 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4239 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4240 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4242 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4243 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4244 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4245 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4246 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4247 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4248 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4249 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4250 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4251 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4252 | |
| 4253 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4254 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4255 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4256 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4257 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4258 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4259 | rs_ci.pNext = nullptr; |
| 4260 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4261 | VkPipelineColorBlendAttachmentState att = {}; |
| 4262 | att.blendEnable = VK_FALSE; |
| 4263 | att.colorWriteMask = 0xf; |
| 4264 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4265 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4266 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4267 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4268 | cb_ci.attachmentCount = 1; |
| 4269 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4270 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4271 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4272 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4273 | gp_ci.stageCount = 2; |
| 4274 | gp_ci.pStages = shaderStages; |
| 4275 | gp_ci.pVertexInputState = &vi_ci; |
| 4276 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4277 | gp_ci.pViewportState = &vp_state_ci; |
| 4278 | gp_ci.pRasterizationState = &rs_ci; |
| 4279 | gp_ci.pColorBlendState = &cb_ci; |
| 4280 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4281 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4282 | gp_ci.layout = pipeline_layout; |
| 4283 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4284 | |
| 4285 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4286 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4287 | |
| 4288 | VkPipeline pipeline; |
| 4289 | VkPipelineCache pipelineCache; |
| 4290 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4291 | err = |
| 4292 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4293 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4294 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4295 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4297 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4298 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4299 | // 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] | 4300 | // First need to successfully create the PSO from above by setting |
| 4301 | // pViewports |
| 4302 | m_errorMonitor->SetDesiredFailureMsg( |
| 4303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4304 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4305 | "scissorCount is 1. These counts must match."); |
| 4306 | |
| 4307 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4308 | vp_state_ci.pViewports = &vp; |
| 4309 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4310 | &gp_ci, NULL, &pipeline); |
| 4311 | ASSERT_VK_SUCCESS(err); |
| 4312 | BeginCommandBuffer(); |
| 4313 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4314 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4315 | VkRect2D scissors[2] = {}; // don't care about data |
| 4316 | // Count of 2 doesn't match PSO count of 1 |
| 4317 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4318 | Draw(1, 0, 0, 0); |
| 4319 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4320 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | |
| 4322 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4323 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4324 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4325 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4326 | } |
| 4327 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4328 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4329 | // viewportCount |
| 4330 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4331 | VkResult err; |
| 4332 | |
| 4333 | m_errorMonitor->SetDesiredFailureMsg( |
| 4334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4335 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4336 | |
| 4337 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4338 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4339 | |
| 4340 | VkDescriptorPoolSize ds_type_count = {}; |
| 4341 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4342 | ds_type_count.descriptorCount = 1; |
| 4343 | |
| 4344 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4345 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4346 | ds_pool_ci.maxSets = 1; |
| 4347 | ds_pool_ci.poolSizeCount = 1; |
| 4348 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4349 | |
| 4350 | VkDescriptorPool ds_pool; |
| 4351 | err = |
| 4352 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4353 | ASSERT_VK_SUCCESS(err); |
| 4354 | |
| 4355 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4356 | dsl_binding.binding = 0; |
| 4357 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4358 | dsl_binding.descriptorCount = 1; |
| 4359 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4360 | |
| 4361 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4362 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4363 | ds_layout_ci.bindingCount = 1; |
| 4364 | ds_layout_ci.pBindings = &dsl_binding; |
| 4365 | |
| 4366 | VkDescriptorSetLayout ds_layout; |
| 4367 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4368 | &ds_layout); |
| 4369 | ASSERT_VK_SUCCESS(err); |
| 4370 | |
| 4371 | VkDescriptorSet descriptorSet; |
| 4372 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4373 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4374 | alloc_info.descriptorSetCount = 1; |
| 4375 | alloc_info.descriptorPool = ds_pool; |
| 4376 | alloc_info.pSetLayouts = &ds_layout; |
| 4377 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4378 | &descriptorSet); |
| 4379 | ASSERT_VK_SUCCESS(err); |
| 4380 | |
| 4381 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4382 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4383 | pipeline_layout_ci.setLayoutCount = 1; |
| 4384 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4385 | |
| 4386 | VkPipelineLayout pipeline_layout; |
| 4387 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4388 | &pipeline_layout); |
| 4389 | ASSERT_VK_SUCCESS(err); |
| 4390 | |
| 4391 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4392 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4393 | vp_state_ci.scissorCount = 1; |
| 4394 | vp_state_ci.pScissors = |
| 4395 | NULL; // Null scissor w/ count of 1 should cause error |
| 4396 | vp_state_ci.viewportCount = 1; |
| 4397 | vp_state_ci.pViewports = |
| 4398 | NULL; // vp is dynamic (below) so this won't cause error |
| 4399 | |
| 4400 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4401 | // Set scissor as dynamic to avoid that error |
| 4402 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4403 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4404 | dyn_state_ci.dynamicStateCount = 1; |
| 4405 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4406 | |
| 4407 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4408 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4409 | |
| 4410 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4411 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4412 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4413 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4414 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4415 | // but add it to be able to run on more devices |
| 4416 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4417 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4418 | |
| 4419 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4420 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4421 | vi_ci.pNext = nullptr; |
| 4422 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4423 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4424 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4425 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4426 | |
| 4427 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4428 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4429 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4430 | |
| 4431 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4432 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4433 | rs_ci.pNext = nullptr; |
| 4434 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4435 | VkPipelineColorBlendAttachmentState att = {}; |
| 4436 | att.blendEnable = VK_FALSE; |
| 4437 | att.colorWriteMask = 0xf; |
| 4438 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4439 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4440 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4441 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4442 | cb_ci.attachmentCount = 1; |
| 4443 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4444 | |
| 4445 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4446 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4447 | gp_ci.stageCount = 2; |
| 4448 | gp_ci.pStages = shaderStages; |
| 4449 | gp_ci.pVertexInputState = &vi_ci; |
| 4450 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4451 | gp_ci.pViewportState = &vp_state_ci; |
| 4452 | gp_ci.pRasterizationState = &rs_ci; |
| 4453 | gp_ci.pColorBlendState = &cb_ci; |
| 4454 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4455 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4456 | gp_ci.layout = pipeline_layout; |
| 4457 | gp_ci.renderPass = renderPass(); |
| 4458 | |
| 4459 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4460 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4461 | |
| 4462 | VkPipeline pipeline; |
| 4463 | VkPipelineCache pipelineCache; |
| 4464 | |
| 4465 | err = |
| 4466 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4467 | ASSERT_VK_SUCCESS(err); |
| 4468 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4469 | &gp_ci, NULL, &pipeline); |
| 4470 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4471 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4472 | |
| 4473 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4474 | // First need to successfully create the PSO from above by setting |
| 4475 | // pViewports |
| 4476 | m_errorMonitor->SetDesiredFailureMsg( |
| 4477 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4478 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4479 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4480 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4481 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4482 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4483 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4484 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4485 | ASSERT_VK_SUCCESS(err); |
| 4486 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4487 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4488 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4489 | VkViewport viewports[2] = {}; // don't care about data |
| 4490 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4491 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4492 | Draw(1, 0, 0, 0); |
| 4493 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4494 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4495 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4496 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4497 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4498 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4499 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4500 | } |
| 4501 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4502 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4503 | VkResult err; |
| 4504 | |
| 4505 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4506 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4507 | |
| 4508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4509 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4510 | |
| 4511 | VkDescriptorPoolSize ds_type_count = {}; |
| 4512 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4513 | ds_type_count.descriptorCount = 1; |
| 4514 | |
| 4515 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4516 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4517 | ds_pool_ci.maxSets = 1; |
| 4518 | ds_pool_ci.poolSizeCount = 1; |
| 4519 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4520 | |
| 4521 | VkDescriptorPool ds_pool; |
| 4522 | err = |
| 4523 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4524 | ASSERT_VK_SUCCESS(err); |
| 4525 | |
| 4526 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4527 | dsl_binding.binding = 0; |
| 4528 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4529 | dsl_binding.descriptorCount = 1; |
| 4530 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4531 | |
| 4532 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4533 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4534 | ds_layout_ci.bindingCount = 1; |
| 4535 | ds_layout_ci.pBindings = &dsl_binding; |
| 4536 | |
| 4537 | VkDescriptorSetLayout ds_layout; |
| 4538 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4539 | &ds_layout); |
| 4540 | ASSERT_VK_SUCCESS(err); |
| 4541 | |
| 4542 | VkDescriptorSet descriptorSet; |
| 4543 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4544 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4545 | alloc_info.descriptorSetCount = 1; |
| 4546 | alloc_info.descriptorPool = ds_pool; |
| 4547 | alloc_info.pSetLayouts = &ds_layout; |
| 4548 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4549 | &descriptorSet); |
| 4550 | ASSERT_VK_SUCCESS(err); |
| 4551 | |
| 4552 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4553 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4554 | pipeline_layout_ci.setLayoutCount = 1; |
| 4555 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4556 | |
| 4557 | VkPipelineLayout pipeline_layout; |
| 4558 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4559 | &pipeline_layout); |
| 4560 | ASSERT_VK_SUCCESS(err); |
| 4561 | |
| 4562 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4563 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4564 | vp_state_ci.scissorCount = 1; |
| 4565 | vp_state_ci.pScissors = NULL; |
| 4566 | vp_state_ci.viewportCount = 1; |
| 4567 | vp_state_ci.pViewports = NULL; |
| 4568 | |
| 4569 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4570 | VK_DYNAMIC_STATE_SCISSOR, |
| 4571 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4572 | // Set scissor as dynamic to avoid that error |
| 4573 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4574 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4575 | dyn_state_ci.dynamicStateCount = 2; |
| 4576 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4577 | |
| 4578 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4579 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4580 | |
| 4581 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4582 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4583 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4584 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4585 | this); // TODO - We shouldn't need a fragment shader |
| 4586 | // but add it to be able to run on more devices |
| 4587 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4588 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4589 | |
| 4590 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4591 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4592 | vi_ci.pNext = nullptr; |
| 4593 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4594 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4595 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4596 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4597 | |
| 4598 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4599 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4600 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4601 | |
| 4602 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4603 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4604 | rs_ci.pNext = nullptr; |
| 4605 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4606 | // Check too low (line width of -1.0f). |
| 4607 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4608 | |
| 4609 | VkPipelineColorBlendAttachmentState att = {}; |
| 4610 | att.blendEnable = VK_FALSE; |
| 4611 | att.colorWriteMask = 0xf; |
| 4612 | |
| 4613 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4614 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4615 | cb_ci.pNext = nullptr; |
| 4616 | cb_ci.attachmentCount = 1; |
| 4617 | cb_ci.pAttachments = &att; |
| 4618 | |
| 4619 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4620 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4621 | gp_ci.stageCount = 2; |
| 4622 | gp_ci.pStages = shaderStages; |
| 4623 | gp_ci.pVertexInputState = &vi_ci; |
| 4624 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4625 | gp_ci.pViewportState = &vp_state_ci; |
| 4626 | gp_ci.pRasterizationState = &rs_ci; |
| 4627 | gp_ci.pColorBlendState = &cb_ci; |
| 4628 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4629 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4630 | gp_ci.layout = pipeline_layout; |
| 4631 | gp_ci.renderPass = renderPass(); |
| 4632 | |
| 4633 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4634 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4635 | |
| 4636 | VkPipeline pipeline; |
| 4637 | VkPipelineCache pipelineCache; |
| 4638 | |
| 4639 | err = |
| 4640 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4641 | ASSERT_VK_SUCCESS(err); |
| 4642 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4643 | &gp_ci, NULL, &pipeline); |
| 4644 | |
| 4645 | m_errorMonitor->VerifyFound(); |
| 4646 | |
| 4647 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4648 | "Attempt to set lineWidth to 65536"); |
| 4649 | |
| 4650 | // Check too high (line width of 65536.0f). |
| 4651 | rs_ci.lineWidth = 65536.0f; |
| 4652 | |
| 4653 | err = |
| 4654 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4655 | ASSERT_VK_SUCCESS(err); |
| 4656 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4657 | &gp_ci, NULL, &pipeline); |
| 4658 | |
| 4659 | m_errorMonitor->VerifyFound(); |
| 4660 | |
| 4661 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4662 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4663 | |
| 4664 | dyn_state_ci.dynamicStateCount = 3; |
| 4665 | |
| 4666 | rs_ci.lineWidth = 1.0f; |
| 4667 | |
| 4668 | err = |
| 4669 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4670 | ASSERT_VK_SUCCESS(err); |
| 4671 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4672 | &gp_ci, NULL, &pipeline); |
| 4673 | BeginCommandBuffer(); |
| 4674 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4675 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4676 | |
| 4677 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4678 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4679 | m_errorMonitor->VerifyFound(); |
| 4680 | |
| 4681 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4682 | "Attempt to set lineWidth to 65536"); |
| 4683 | |
| 4684 | // Check too high with dynamic setting. |
| 4685 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 4686 | m_errorMonitor->VerifyFound(); |
| 4687 | EndCommandBuffer(); |
| 4688 | |
| 4689 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4690 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4691 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4692 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4693 | } |
| 4694 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4695 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4696 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4697 | m_errorMonitor->SetDesiredFailureMsg( |
| 4698 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4699 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4700 | |
| 4701 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4702 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4703 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4704 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4705 | // Don't care about RenderPass handle b/c error should be flagged before |
| 4706 | // that |
| 4707 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 4708 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4709 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4710 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4711 | } |
| 4712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4714 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4715 | m_errorMonitor->SetDesiredFailureMsg( |
| 4716 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4717 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4718 | |
| 4719 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4720 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4721 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4722 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4723 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 4724 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4725 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4726 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 4727 | rp_begin.pNext = NULL; |
| 4728 | rp_begin.renderPass = renderPass(); |
| 4729 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4731 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 4732 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4733 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4734 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4735 | } |
| 4736 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4737 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4738 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4739 | m_errorMonitor->SetDesiredFailureMsg( |
| 4740 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4741 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4742 | |
| 4743 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4744 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4745 | |
| 4746 | // Renderpass is started here |
| 4747 | BeginCommandBuffer(); |
| 4748 | |
| 4749 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4750 | vk_testing::Buffer dstBuffer; |
| 4751 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4752 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4753 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4754 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4755 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4756 | } |
| 4757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4758 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4759 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4760 | m_errorMonitor->SetDesiredFailureMsg( |
| 4761 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4762 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4763 | |
| 4764 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4765 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4766 | |
| 4767 | // Renderpass is started here |
| 4768 | BeginCommandBuffer(); |
| 4769 | |
| 4770 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4771 | vk_testing::Buffer dstBuffer; |
| 4772 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4774 | VkDeviceSize dstOffset = 0; |
| 4775 | VkDeviceSize dataSize = 1024; |
| 4776 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4778 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 4779 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4780 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4781 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4782 | } |
| 4783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4784 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4785 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4786 | m_errorMonitor->SetDesiredFailureMsg( |
| 4787 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4788 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4789 | |
| 4790 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4791 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4792 | |
| 4793 | // Renderpass is started here |
| 4794 | BeginCommandBuffer(); |
| 4795 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 4796 | VkClearColorValue clear_color; |
| 4797 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4798 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4799 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4800 | const int32_t tex_width = 32; |
| 4801 | const int32_t tex_height = 32; |
| 4802 | VkImageCreateInfo image_create_info = {}; |
| 4803 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4804 | image_create_info.pNext = NULL; |
| 4805 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4806 | image_create_info.format = tex_format; |
| 4807 | image_create_info.extent.width = tex_width; |
| 4808 | image_create_info.extent.height = tex_height; |
| 4809 | image_create_info.extent.depth = 1; |
| 4810 | image_create_info.mipLevels = 1; |
| 4811 | image_create_info.arrayLayers = 1; |
| 4812 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4813 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4814 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4815 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4816 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4817 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4818 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4820 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4821 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4822 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4823 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4824 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4825 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4826 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4827 | } |
| 4828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4829 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4830 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4831 | m_errorMonitor->SetDesiredFailureMsg( |
| 4832 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4833 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4834 | |
| 4835 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4836 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4837 | |
| 4838 | // Renderpass is started here |
| 4839 | BeginCommandBuffer(); |
| 4840 | |
| 4841 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 4842 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4843 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 4844 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4845 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 4846 | image_create_info.extent.width = 64; |
| 4847 | image_create_info.extent.height = 64; |
| 4848 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4849 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4850 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4851 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4852 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4853 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4854 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4855 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4856 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4858 | vkCmdClearDepthStencilImage( |
| 4859 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4860 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 4861 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4862 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4863 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4864 | } |
| 4865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4866 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4867 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4868 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4869 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4870 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4871 | "vkCmdClearAttachments: This call " |
| 4872 | "must be issued inside an active " |
| 4873 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4874 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4875 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4876 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4877 | |
| 4878 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4879 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4880 | ASSERT_VK_SUCCESS(err); |
| 4881 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4882 | VkClearAttachment color_attachment; |
| 4883 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4884 | color_attachment.clearValue.color.float32[0] = 0; |
| 4885 | color_attachment.clearValue.color.float32[1] = 0; |
| 4886 | color_attachment.clearValue.color.float32[2] = 0; |
| 4887 | color_attachment.clearValue.color.float32[3] = 0; |
| 4888 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4889 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 4890 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4891 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4892 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4893 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4894 | } |
| 4895 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 4896 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 4897 | // Try to add a buffer memory barrier with no buffer. |
| 4898 | m_errorMonitor->SetDesiredFailureMsg( |
| 4899 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4900 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 4901 | |
| 4902 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4903 | BeginCommandBuffer(); |
| 4904 | |
| 4905 | VkBufferMemoryBarrier buf_barrier = {}; |
| 4906 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 4907 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4908 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4909 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4910 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4911 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 4912 | buf_barrier.offset = 0; |
| 4913 | buf_barrier.size = VK_WHOLE_SIZE; |
| 4914 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4915 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 4916 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 4917 | |
| 4918 | m_errorMonitor->VerifyFound(); |
| 4919 | } |
| 4920 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 4921 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 4922 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 4923 | |
| 4924 | m_errorMonitor->SetDesiredFailureMsg( |
| 4925 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 4926 | |
| 4927 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4928 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4929 | |
| 4930 | VkMemoryBarrier mem_barrier = {}; |
| 4931 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 4932 | mem_barrier.pNext = NULL; |
| 4933 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4934 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4935 | BeginCommandBuffer(); |
| 4936 | // BeginCommandBuffer() starts a render pass |
| 4937 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4938 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4939 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 4940 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 4941 | m_errorMonitor->VerifyFound(); |
| 4942 | |
| 4943 | m_errorMonitor->SetDesiredFailureMsg( |
| 4944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4945 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 4946 | VkImageObj image(m_device); |
| 4947 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 4948 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 4949 | ASSERT_TRUE(image.initialized()); |
| 4950 | VkImageMemoryBarrier img_barrier = {}; |
| 4951 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 4952 | img_barrier.pNext = NULL; |
| 4953 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4954 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4955 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4956 | // New layout can't be UNDEFINED |
| 4957 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 4958 | img_barrier.image = image.handle(); |
| 4959 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4960 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4961 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4962 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 4963 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 4964 | img_barrier.subresourceRange.layerCount = 1; |
| 4965 | img_barrier.subresourceRange.levelCount = 1; |
| 4966 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4967 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4968 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4969 | nullptr, 1, &img_barrier); |
| 4970 | m_errorMonitor->VerifyFound(); |
| 4971 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4972 | |
| 4973 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4974 | "Subresource must have the sum of the " |
| 4975 | "baseArrayLayer"); |
| 4976 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 4977 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 4978 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4979 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4980 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4981 | nullptr, 1, &img_barrier); |
| 4982 | m_errorMonitor->VerifyFound(); |
| 4983 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 4984 | |
| 4985 | m_errorMonitor->SetDesiredFailureMsg( |
| 4986 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4987 | "Subresource must have the sum of the baseMipLevel"); |
| 4988 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 4989 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 4990 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4991 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4992 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4993 | nullptr, 1, &img_barrier); |
| 4994 | m_errorMonitor->VerifyFound(); |
| 4995 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 4996 | |
| 4997 | m_errorMonitor->SetDesiredFailureMsg( |
| 4998 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4999 | "Buffer Barriers cannot be used during a render pass"); |
| 5000 | vk_testing::Buffer buffer; |
| 5001 | buffer.init(*m_device, 256); |
| 5002 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5003 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5004 | buf_barrier.pNext = NULL; |
| 5005 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5006 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5007 | buf_barrier.buffer = buffer.handle(); |
| 5008 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5009 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5010 | buf_barrier.offset = 0; |
| 5011 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5012 | // Can't send buffer barrier during a render pass |
| 5013 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5014 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5015 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5016 | &buf_barrier, 0, nullptr); |
| 5017 | m_errorMonitor->VerifyFound(); |
| 5018 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5019 | |
| 5020 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5021 | "which is not less than total size"); |
| 5022 | buf_barrier.offset = 257; |
| 5023 | // Offset greater than total size |
| 5024 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5025 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5026 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5027 | &buf_barrier, 0, nullptr); |
| 5028 | m_errorMonitor->VerifyFound(); |
| 5029 | buf_barrier.offset = 0; |
| 5030 | |
| 5031 | m_errorMonitor->SetDesiredFailureMsg( |
| 5032 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5033 | buf_barrier.size = 257; |
| 5034 | // Size greater than total size |
| 5035 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5036 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5037 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5038 | &buf_barrier, 0, nullptr); |
| 5039 | m_errorMonitor->VerifyFound(); |
| 5040 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5041 | |
| 5042 | m_errorMonitor->SetDesiredFailureMsg( |
| 5043 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5044 | "Image is a depth and stencil format and thus must " |
| 5045 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5046 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5047 | VkDepthStencilObj ds_image(m_device); |
| 5048 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5049 | ASSERT_TRUE(ds_image.initialized()); |
| 5050 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5051 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5052 | img_barrier.image = ds_image.handle(); |
| 5053 | // Leave aspectMask at COLOR on purpose |
| 5054 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5055 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5056 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5057 | nullptr, 1, &img_barrier); |
| 5058 | m_errorMonitor->VerifyFound(); |
| 5059 | } |
| 5060 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5061 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5062 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5063 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5065 | m_errorMonitor->SetDesiredFailureMsg( |
| 5066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5067 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5068 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5069 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5070 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5071 | uint32_t qfi = 0; |
| 5072 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5073 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5074 | buffCI.size = 1024; |
| 5075 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5076 | buffCI.queueFamilyIndexCount = 1; |
| 5077 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5078 | |
| 5079 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5080 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5081 | ASSERT_VK_SUCCESS(err); |
| 5082 | |
| 5083 | BeginCommandBuffer(); |
| 5084 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5085 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5086 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5087 | // 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] | 5088 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5089 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5090 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5091 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5092 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5093 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5094 | } |
| 5095 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5096 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5097 | // Create an out-of-range queueFamilyIndex |
| 5098 | m_errorMonitor->SetDesiredFailureMsg( |
| 5099 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5100 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5101 | |
| 5102 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5103 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5104 | VkBufferCreateInfo buffCI = {}; |
| 5105 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5106 | buffCI.size = 1024; |
| 5107 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5108 | buffCI.queueFamilyIndexCount = 1; |
| 5109 | // Introduce failure by specifying invalid queue_family_index |
| 5110 | uint32_t qfi = 777; |
| 5111 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5112 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5113 | |
| 5114 | VkBuffer ib; |
| 5115 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5116 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5117 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5118 | } |
| 5119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5120 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5121 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5122 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | m_errorMonitor->SetDesiredFailureMsg( |
| 5125 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5126 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5127 | |
| 5128 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5129 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5130 | |
| 5131 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5132 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5133 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5134 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5135 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5136 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5137 | } |
| 5138 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5139 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5140 | // 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] | 5141 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | m_errorMonitor->SetDesiredFailureMsg( |
| 5144 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 5145 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 5146 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5147 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5148 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5149 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5150 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5151 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5152 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5153 | |
| 5154 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5156 | ds_pool_ci.pNext = NULL; |
| 5157 | ds_pool_ci.maxSets = 1; |
| 5158 | ds_pool_ci.poolSizeCount = 1; |
| 5159 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5160 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5161 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | err = |
| 5163 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5164 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5165 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5166 | dsl_binding.binding = 0; |
| 5167 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5168 | dsl_binding.descriptorCount = 1; |
| 5169 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5170 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5171 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5172 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5173 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5174 | ds_layout_ci.pNext = NULL; |
| 5175 | ds_layout_ci.bindingCount = 1; |
| 5176 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5177 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5178 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5179 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5180 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5181 | ASSERT_VK_SUCCESS(err); |
| 5182 | |
| 5183 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5184 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5185 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5186 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5187 | alloc_info.descriptorPool = ds_pool; |
| 5188 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5189 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5190 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5191 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5192 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5193 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5194 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5195 | sampler_ci.pNext = NULL; |
| 5196 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5197 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5198 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5199 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5200 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5201 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5202 | sampler_ci.mipLodBias = 1.0; |
| 5203 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5204 | sampler_ci.maxAnisotropy = 1; |
| 5205 | sampler_ci.compareEnable = VK_FALSE; |
| 5206 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5207 | sampler_ci.minLod = 1.0; |
| 5208 | sampler_ci.maxLod = 1.0; |
| 5209 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5210 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 5211 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5212 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5213 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5214 | ASSERT_VK_SUCCESS(err); |
| 5215 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5216 | VkDescriptorImageInfo info = {}; |
| 5217 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5218 | |
| 5219 | VkWriteDescriptorSet descriptor_write; |
| 5220 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5221 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5222 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5223 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5224 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5225 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5226 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5227 | |
| 5228 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5229 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5230 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5231 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5232 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5233 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5234 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5235 | } |
| 5236 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5238 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5240 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5241 | m_errorMonitor->SetDesiredFailureMsg( |
| 5242 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 5243 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 5244 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5245 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5246 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5247 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5248 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5249 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5250 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5251 | |
| 5252 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5254 | ds_pool_ci.pNext = NULL; |
| 5255 | ds_pool_ci.maxSets = 1; |
| 5256 | ds_pool_ci.poolSizeCount = 1; |
| 5257 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5258 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5259 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5260 | err = |
| 5261 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5262 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5263 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5264 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5265 | dsl_binding.binding = 0; |
| 5266 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5267 | dsl_binding.descriptorCount = 1; |
| 5268 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5269 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5270 | |
| 5271 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5272 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5273 | ds_layout_ci.pNext = NULL; |
| 5274 | ds_layout_ci.bindingCount = 1; |
| 5275 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5276 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5277 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5278 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5279 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5280 | ASSERT_VK_SUCCESS(err); |
| 5281 | |
| 5282 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5283 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5284 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5285 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5286 | alloc_info.descriptorPool = ds_pool; |
| 5287 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5288 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5289 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5290 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5291 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5292 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5294 | sampler_ci.pNext = NULL; |
| 5295 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5296 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5297 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5298 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5299 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5300 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5301 | sampler_ci.mipLodBias = 1.0; |
| 5302 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5303 | sampler_ci.maxAnisotropy = 1; |
| 5304 | sampler_ci.compareEnable = VK_FALSE; |
| 5305 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5306 | sampler_ci.minLod = 1.0; |
| 5307 | sampler_ci.maxLod = 1.0; |
| 5308 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5309 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5310 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5311 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5312 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5313 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5314 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5315 | VkDescriptorImageInfo info = {}; |
| 5316 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5317 | |
| 5318 | VkWriteDescriptorSet descriptor_write; |
| 5319 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5320 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5321 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5322 | descriptor_write.dstArrayElement = |
| 5323 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5324 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5325 | // 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] | 5326 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5327 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5328 | |
| 5329 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5330 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5331 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5332 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5333 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5334 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5335 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5336 | } |
| 5337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5338 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5339 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5340 | // index 2 |
| 5341 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5342 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5343 | m_errorMonitor->SetDesiredFailureMsg( |
| 5344 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5345 | " does not have binding to match update binding "); |
| 5346 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5348 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5349 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5351 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5352 | |
| 5353 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5354 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5355 | ds_pool_ci.pNext = NULL; |
| 5356 | ds_pool_ci.maxSets = 1; |
| 5357 | ds_pool_ci.poolSizeCount = 1; |
| 5358 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5359 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5360 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5361 | err = |
| 5362 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5363 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5364 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5365 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5366 | dsl_binding.binding = 0; |
| 5367 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5368 | dsl_binding.descriptorCount = 1; |
| 5369 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5370 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5371 | |
| 5372 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5373 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5374 | ds_layout_ci.pNext = NULL; |
| 5375 | ds_layout_ci.bindingCount = 1; |
| 5376 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5377 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5378 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5379 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5380 | ASSERT_VK_SUCCESS(err); |
| 5381 | |
| 5382 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5383 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5384 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5385 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5386 | alloc_info.descriptorPool = ds_pool; |
| 5387 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5388 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5389 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5390 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5391 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5392 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5393 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5394 | sampler_ci.pNext = NULL; |
| 5395 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5396 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5397 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5398 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5399 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5400 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5401 | sampler_ci.mipLodBias = 1.0; |
| 5402 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5403 | sampler_ci.maxAnisotropy = 1; |
| 5404 | sampler_ci.compareEnable = VK_FALSE; |
| 5405 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5406 | sampler_ci.minLod = 1.0; |
| 5407 | sampler_ci.maxLod = 1.0; |
| 5408 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5409 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5410 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5411 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5412 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5413 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5414 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5415 | VkDescriptorImageInfo info = {}; |
| 5416 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5417 | |
| 5418 | VkWriteDescriptorSet descriptor_write; |
| 5419 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5420 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5421 | descriptor_write.dstSet = descriptorSet; |
| 5422 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5423 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5424 | // 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] | 5425 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5426 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5427 | |
| 5428 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5429 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5430 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5431 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5432 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5433 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5434 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5435 | } |
| 5436 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5437 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5438 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5439 | // types |
| 5440 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5441 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5442 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5443 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5444 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5445 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5446 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5447 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5448 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5449 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5450 | |
| 5451 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5452 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5453 | ds_pool_ci.pNext = NULL; |
| 5454 | ds_pool_ci.maxSets = 1; |
| 5455 | ds_pool_ci.poolSizeCount = 1; |
| 5456 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5457 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5458 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5459 | err = |
| 5460 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5461 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5462 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5463 | dsl_binding.binding = 0; |
| 5464 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5465 | dsl_binding.descriptorCount = 1; |
| 5466 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5467 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5468 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5469 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5471 | ds_layout_ci.pNext = NULL; |
| 5472 | ds_layout_ci.bindingCount = 1; |
| 5473 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5474 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5475 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5476 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5477 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5478 | ASSERT_VK_SUCCESS(err); |
| 5479 | |
| 5480 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5481 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5482 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5483 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5484 | alloc_info.descriptorPool = ds_pool; |
| 5485 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5486 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5487 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5488 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5489 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5490 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5492 | sampler_ci.pNext = NULL; |
| 5493 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5494 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5495 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5496 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5497 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5498 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5499 | sampler_ci.mipLodBias = 1.0; |
| 5500 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5501 | sampler_ci.maxAnisotropy = 1; |
| 5502 | sampler_ci.compareEnable = VK_FALSE; |
| 5503 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5504 | sampler_ci.minLod = 1.0; |
| 5505 | sampler_ci.maxLod = 1.0; |
| 5506 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5507 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5508 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5509 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5510 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5511 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5512 | VkDescriptorImageInfo info = {}; |
| 5513 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5514 | |
| 5515 | VkWriteDescriptorSet descriptor_write; |
| 5516 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5517 | descriptor_write.sType = |
| 5518 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5519 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5520 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5521 | // 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] | 5522 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5523 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5524 | |
| 5525 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5526 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5527 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5528 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5529 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5530 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5531 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5532 | } |
| 5533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5534 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5535 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5536 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5537 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5538 | m_errorMonitor->SetDesiredFailureMsg( |
| 5539 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5540 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 5541 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5543 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5544 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5545 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5546 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5547 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5548 | |
| 5549 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5551 | ds_pool_ci.pNext = NULL; |
| 5552 | ds_pool_ci.maxSets = 1; |
| 5553 | ds_pool_ci.poolSizeCount = 1; |
| 5554 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5555 | |
| 5556 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5557 | err = |
| 5558 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5559 | ASSERT_VK_SUCCESS(err); |
| 5560 | |
| 5561 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5562 | dsl_binding.binding = 0; |
| 5563 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5564 | dsl_binding.descriptorCount = 1; |
| 5565 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5566 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5567 | |
| 5568 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5569 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5570 | ds_layout_ci.pNext = NULL; |
| 5571 | ds_layout_ci.bindingCount = 1; |
| 5572 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5573 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5575 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5576 | ASSERT_VK_SUCCESS(err); |
| 5577 | |
| 5578 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5579 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5580 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5581 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5582 | alloc_info.descriptorPool = ds_pool; |
| 5583 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5585 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5586 | ASSERT_VK_SUCCESS(err); |
| 5587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5588 | VkSampler sampler = |
| 5589 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5590 | |
| 5591 | VkDescriptorImageInfo descriptor_info; |
| 5592 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5593 | descriptor_info.sampler = sampler; |
| 5594 | |
| 5595 | VkWriteDescriptorSet descriptor_write; |
| 5596 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5597 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5598 | descriptor_write.dstSet = descriptorSet; |
| 5599 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5600 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5601 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5602 | descriptor_write.pImageInfo = &descriptor_info; |
| 5603 | |
| 5604 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5605 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5606 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5607 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5608 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5609 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5610 | } |
| 5611 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5612 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5613 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5614 | // imageView |
| 5615 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5617 | m_errorMonitor->SetDesiredFailureMsg( |
| 5618 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5619 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 5620 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5622 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5624 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5625 | |
| 5626 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5627 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5628 | ds_pool_ci.pNext = NULL; |
| 5629 | ds_pool_ci.maxSets = 1; |
| 5630 | ds_pool_ci.poolSizeCount = 1; |
| 5631 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5632 | |
| 5633 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | err = |
| 5635 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5636 | ASSERT_VK_SUCCESS(err); |
| 5637 | |
| 5638 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5639 | dsl_binding.binding = 0; |
| 5640 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5641 | dsl_binding.descriptorCount = 1; |
| 5642 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5643 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5644 | |
| 5645 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5646 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5647 | ds_layout_ci.pNext = NULL; |
| 5648 | ds_layout_ci.bindingCount = 1; |
| 5649 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5650 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5651 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5652 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5653 | ASSERT_VK_SUCCESS(err); |
| 5654 | |
| 5655 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5656 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5657 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5658 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5659 | alloc_info.descriptorPool = ds_pool; |
| 5660 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5661 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5662 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5663 | ASSERT_VK_SUCCESS(err); |
| 5664 | |
| 5665 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5666 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5667 | sampler_ci.pNext = NULL; |
| 5668 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5669 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5670 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5671 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5672 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5673 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5674 | sampler_ci.mipLodBias = 1.0; |
| 5675 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5676 | sampler_ci.maxAnisotropy = 1; |
| 5677 | sampler_ci.compareEnable = VK_FALSE; |
| 5678 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5679 | sampler_ci.minLod = 1.0; |
| 5680 | sampler_ci.maxLod = 1.0; |
| 5681 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5682 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5683 | |
| 5684 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5685 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5686 | ASSERT_VK_SUCCESS(err); |
| 5687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5688 | VkImageView view = |
| 5689 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5690 | |
| 5691 | VkDescriptorImageInfo descriptor_info; |
| 5692 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5693 | descriptor_info.sampler = sampler; |
| 5694 | descriptor_info.imageView = view; |
| 5695 | |
| 5696 | VkWriteDescriptorSet descriptor_write; |
| 5697 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5698 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5699 | descriptor_write.dstSet = descriptorSet; |
| 5700 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5701 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5702 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5703 | descriptor_write.pImageInfo = &descriptor_info; |
| 5704 | |
| 5705 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5706 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5707 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5708 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5709 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5710 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5711 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5712 | } |
| 5713 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5714 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 5715 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 5716 | // into the other |
| 5717 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5718 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5719 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5720 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5721 | "Copy descriptor update index 0, has src update descriptor " |
| 5722 | "type VK_DESCRIPTOR_TYPE_SAMPLER that does not match overlapping " |
| 5723 | "dest "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5724 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5725 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5726 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5727 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5728 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5729 | ds_type_count[0].descriptorCount = 1; |
| 5730 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5731 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5732 | |
| 5733 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5734 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5735 | ds_pool_ci.pNext = NULL; |
| 5736 | ds_pool_ci.maxSets = 1; |
| 5737 | ds_pool_ci.poolSizeCount = 2; |
| 5738 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5739 | |
| 5740 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5741 | err = |
| 5742 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5743 | ASSERT_VK_SUCCESS(err); |
| 5744 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5745 | dsl_binding[0].binding = 0; |
| 5746 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5747 | dsl_binding[0].descriptorCount = 1; |
| 5748 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5749 | dsl_binding[0].pImmutableSamplers = NULL; |
| 5750 | dsl_binding[1].binding = 1; |
| 5751 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5752 | dsl_binding[1].descriptorCount = 1; |
| 5753 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5754 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5755 | |
| 5756 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5757 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5758 | ds_layout_ci.pNext = NULL; |
| 5759 | ds_layout_ci.bindingCount = 2; |
| 5760 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5761 | |
| 5762 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5763 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5764 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5765 | ASSERT_VK_SUCCESS(err); |
| 5766 | |
| 5767 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5768 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5769 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5770 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5771 | alloc_info.descriptorPool = ds_pool; |
| 5772 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5773 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5774 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5775 | ASSERT_VK_SUCCESS(err); |
| 5776 | |
| 5777 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5779 | sampler_ci.pNext = NULL; |
| 5780 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5781 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5782 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5783 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5784 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5785 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5786 | sampler_ci.mipLodBias = 1.0; |
| 5787 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5788 | sampler_ci.maxAnisotropy = 1; |
| 5789 | sampler_ci.compareEnable = VK_FALSE; |
| 5790 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5791 | sampler_ci.minLod = 1.0; |
| 5792 | sampler_ci.maxLod = 1.0; |
| 5793 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5794 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5795 | |
| 5796 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5797 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5798 | ASSERT_VK_SUCCESS(err); |
| 5799 | |
| 5800 | VkDescriptorImageInfo info = {}; |
| 5801 | info.sampler = sampler; |
| 5802 | |
| 5803 | VkWriteDescriptorSet descriptor_write; |
| 5804 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 5805 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5806 | descriptor_write.dstSet = descriptorSet; |
| 5807 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5808 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5809 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5810 | descriptor_write.pImageInfo = &info; |
| 5811 | // This write update should succeed |
| 5812 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5813 | // Now perform a copy update that fails due to type mismatch |
| 5814 | VkCopyDescriptorSet copy_ds_update; |
| 5815 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5816 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5817 | copy_ds_update.srcSet = descriptorSet; |
| 5818 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5819 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5821 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5822 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5823 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5824 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5825 | // 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] | 5826 | m_errorMonitor->SetDesiredFailureMsg( |
| 5827 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5828 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5829 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5830 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5831 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5832 | copy_ds_update.srcBinding = |
| 5833 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5834 | copy_ds_update.dstSet = descriptorSet; |
| 5835 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5836 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5837 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5838 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5839 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5840 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5841 | // 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] | 5842 | m_errorMonitor->SetDesiredFailureMsg( |
| 5843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5844 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 5845 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5846 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5847 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5848 | copy_ds_update.srcSet = descriptorSet; |
| 5849 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5850 | copy_ds_update.dstSet = descriptorSet; |
| 5851 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | copy_ds_update.descriptorCount = |
| 5853 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5854 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5855 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5856 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5857 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5858 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5859 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5860 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5861 | } |
| 5862 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5863 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 5864 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 5865 | // sampleCount |
| 5866 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5867 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5869 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5870 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5871 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5873 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5874 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5875 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5876 | |
| 5877 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5878 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5879 | ds_pool_ci.pNext = NULL; |
| 5880 | ds_pool_ci.maxSets = 1; |
| 5881 | ds_pool_ci.poolSizeCount = 1; |
| 5882 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5883 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5884 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5885 | err = |
| 5886 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5887 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5888 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5889 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5890 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5891 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5892 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5893 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5894 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5895 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5896 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5897 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5898 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5899 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5900 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5901 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5902 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5903 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5904 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5905 | ASSERT_VK_SUCCESS(err); |
| 5906 | |
| 5907 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5908 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5909 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5910 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5911 | alloc_info.descriptorPool = ds_pool; |
| 5912 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5914 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5915 | ASSERT_VK_SUCCESS(err); |
| 5916 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5917 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5918 | pipe_ms_state_ci.sType = |
| 5919 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 5920 | pipe_ms_state_ci.pNext = NULL; |
| 5921 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 5922 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 5923 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 5924 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5925 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5926 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5927 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5928 | pipeline_layout_ci.pNext = NULL; |
| 5929 | pipeline_layout_ci.setLayoutCount = 1; |
| 5930 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5931 | |
| 5932 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5933 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5934 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5935 | ASSERT_VK_SUCCESS(err); |
| 5936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5938 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5939 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5940 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5941 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5942 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5943 | VkPipelineObj pipe(m_device); |
| 5944 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5945 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5946 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5947 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 5948 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5949 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5950 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5951 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5952 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5953 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5954 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5955 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5956 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5957 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5958 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5959 | } |
Tobin Ehlis | 0f10db5 | 2016-04-04 10:00:21 -0600 | [diff] [blame] | 5960 | #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] | 5961 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 5962 | // Create Pipeline where the number of blend attachments doesn't match the |
| 5963 | // number of color attachments. In this case, we don't add any color |
| 5964 | // blend attachments even though we have a color attachment. |
| 5965 | VkResult err; |
| 5966 | |
| 5967 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5968 | "Mismatch between blend state attachment"); |
| 5969 | |
| 5970 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5971 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5972 | VkDescriptorPoolSize ds_type_count = {}; |
| 5973 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5974 | ds_type_count.descriptorCount = 1; |
| 5975 | |
| 5976 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5977 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5978 | ds_pool_ci.pNext = NULL; |
| 5979 | ds_pool_ci.maxSets = 1; |
| 5980 | ds_pool_ci.poolSizeCount = 1; |
| 5981 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5982 | |
| 5983 | VkDescriptorPool ds_pool; |
| 5984 | err = |
| 5985 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5986 | ASSERT_VK_SUCCESS(err); |
| 5987 | |
| 5988 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5989 | dsl_binding.binding = 0; |
| 5990 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5991 | dsl_binding.descriptorCount = 1; |
| 5992 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5993 | dsl_binding.pImmutableSamplers = NULL; |
| 5994 | |
| 5995 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5996 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5997 | ds_layout_ci.pNext = NULL; |
| 5998 | ds_layout_ci.bindingCount = 1; |
| 5999 | ds_layout_ci.pBindings = &dsl_binding; |
| 6000 | |
| 6001 | VkDescriptorSetLayout ds_layout; |
| 6002 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6003 | &ds_layout); |
| 6004 | ASSERT_VK_SUCCESS(err); |
| 6005 | |
| 6006 | VkDescriptorSet descriptorSet; |
| 6007 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6008 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6009 | alloc_info.descriptorSetCount = 1; |
| 6010 | alloc_info.descriptorPool = ds_pool; |
| 6011 | alloc_info.pSetLayouts = &ds_layout; |
| 6012 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6013 | &descriptorSet); |
| 6014 | ASSERT_VK_SUCCESS(err); |
| 6015 | |
| 6016 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6017 | pipe_ms_state_ci.sType = |
| 6018 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6019 | pipe_ms_state_ci.pNext = NULL; |
| 6020 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6021 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6022 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6023 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6024 | |
| 6025 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6026 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6027 | pipeline_layout_ci.pNext = NULL; |
| 6028 | pipeline_layout_ci.setLayoutCount = 1; |
| 6029 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6030 | |
| 6031 | VkPipelineLayout pipeline_layout; |
| 6032 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6033 | &pipeline_layout); |
| 6034 | ASSERT_VK_SUCCESS(err); |
| 6035 | |
| 6036 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6037 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6038 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6039 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6040 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6041 | // but add it to be able to run on more devices |
| 6042 | VkPipelineObj pipe(m_device); |
| 6043 | pipe.AddShader(&vs); |
| 6044 | pipe.AddShader(&fs); |
| 6045 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6046 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6047 | |
| 6048 | BeginCommandBuffer(); |
| 6049 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6050 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6051 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6052 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6053 | |
| 6054 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6055 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6056 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6057 | } |
Tony Barbour | 4e81a20 | 2016-04-04 11:09:40 -0600 | [diff] [blame] | 6058 | #endif //ADD_BACK_IN_WHEN_CHECK_IS_BACK |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6059 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6060 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6061 | // to issuing a Draw |
| 6062 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6063 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6064 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6065 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6066 | "vkCmdClearAttachments() issued on CB object "); |
| 6067 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6068 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6069 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6070 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6071 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6072 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6073 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6074 | |
| 6075 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6076 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6077 | ds_pool_ci.pNext = NULL; |
| 6078 | ds_pool_ci.maxSets = 1; |
| 6079 | ds_pool_ci.poolSizeCount = 1; |
| 6080 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6081 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6082 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6083 | err = |
| 6084 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6085 | ASSERT_VK_SUCCESS(err); |
| 6086 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6087 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6088 | dsl_binding.binding = 0; |
| 6089 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6090 | dsl_binding.descriptorCount = 1; |
| 6091 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6092 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6093 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6094 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6095 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6096 | ds_layout_ci.pNext = NULL; |
| 6097 | ds_layout_ci.bindingCount = 1; |
| 6098 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6099 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6100 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6102 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6103 | ASSERT_VK_SUCCESS(err); |
| 6104 | |
| 6105 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6106 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6107 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6108 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6109 | alloc_info.descriptorPool = ds_pool; |
| 6110 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6111 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6112 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6113 | ASSERT_VK_SUCCESS(err); |
| 6114 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6115 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6116 | pipe_ms_state_ci.sType = |
| 6117 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6118 | pipe_ms_state_ci.pNext = NULL; |
| 6119 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6120 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6121 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6122 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6123 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6124 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6125 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6126 | pipeline_layout_ci.pNext = NULL; |
| 6127 | pipeline_layout_ci.setLayoutCount = 1; |
| 6128 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6129 | |
| 6130 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6131 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6132 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6133 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6134 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6136 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6137 | // 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] | 6138 | // on more devices |
| 6139 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6140 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6141 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6142 | VkPipelineObj pipe(m_device); |
| 6143 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6144 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6145 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6146 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6147 | |
| 6148 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6149 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6150 | // Main thing we care about for this test is that the VkImage obj we're |
| 6151 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6152 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6153 | VkClearAttachment color_attachment; |
| 6154 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6155 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6156 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6157 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6158 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6159 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6160 | VkClearRect clear_rect = { |
| 6161 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6163 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6164 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6165 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6166 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6167 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6168 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6169 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6170 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6171 | } |
| 6172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6173 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6174 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6176 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6177 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6178 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6179 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6181 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6182 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6183 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6184 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6185 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6186 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6187 | |
| 6188 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6190 | ds_pool_ci.pNext = NULL; |
| 6191 | ds_pool_ci.maxSets = 1; |
| 6192 | ds_pool_ci.poolSizeCount = 1; |
| 6193 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6194 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6195 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6196 | err = |
| 6197 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6198 | ASSERT_VK_SUCCESS(err); |
| 6199 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6200 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6201 | dsl_binding.binding = 0; |
| 6202 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6203 | dsl_binding.descriptorCount = 1; |
| 6204 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6205 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6206 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6207 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6208 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6209 | ds_layout_ci.pNext = NULL; |
| 6210 | ds_layout_ci.bindingCount = 1; |
| 6211 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6212 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6213 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6214 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6215 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6216 | ASSERT_VK_SUCCESS(err); |
| 6217 | |
| 6218 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6219 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6220 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6221 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6222 | alloc_info.descriptorPool = ds_pool; |
| 6223 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6224 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6225 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6226 | ASSERT_VK_SUCCESS(err); |
| 6227 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6228 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6229 | pipe_ms_state_ci.sType = |
| 6230 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6231 | pipe_ms_state_ci.pNext = NULL; |
| 6232 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6233 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6234 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6235 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6236 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6237 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6238 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6239 | pipeline_layout_ci.pNext = NULL; |
| 6240 | pipeline_layout_ci.setLayoutCount = 1; |
| 6241 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6242 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6244 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6245 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6246 | ASSERT_VK_SUCCESS(err); |
| 6247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6248 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6249 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6250 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6251 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6252 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6253 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6254 | VkPipelineObj pipe(m_device); |
| 6255 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6256 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6257 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6258 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6259 | pipe.SetViewport(m_viewports); |
| 6260 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6261 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6262 | |
| 6263 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6264 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6265 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6266 | // Don't care about actual data, just need to get to draw to flag error |
| 6267 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6268 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6269 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6270 | 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] | 6271 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6272 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6273 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6274 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6275 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6276 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6277 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6278 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6279 | #endif // DRAW_STATE_TESTS |
| 6280 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6281 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6282 | #if GTEST_IS_THREADSAFE |
| 6283 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6284 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6285 | VkEvent event; |
| 6286 | bool bailout; |
| 6287 | }; |
| 6288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6289 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6290 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6292 | for (int i = 0; i < 10000; i++) { |
| 6293 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6294 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6295 | if (data->bailout) { |
| 6296 | break; |
| 6297 | } |
| 6298 | } |
| 6299 | return NULL; |
| 6300 | } |
| 6301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6302 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6303 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6304 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6305 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6306 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6307 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6308 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6309 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6310 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6311 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6312 | // Calls AllocateCommandBuffers |
| 6313 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6314 | |
| 6315 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6316 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6317 | |
| 6318 | VkEventCreateInfo event_info; |
| 6319 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6320 | VkResult err; |
| 6321 | |
| 6322 | memset(&event_info, 0, sizeof(event_info)); |
| 6323 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6324 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6325 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6326 | ASSERT_VK_SUCCESS(err); |
| 6327 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6328 | err = vkResetEvent(device(), event); |
| 6329 | ASSERT_VK_SUCCESS(err); |
| 6330 | |
| 6331 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6332 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6333 | data.event = event; |
| 6334 | data.bailout = false; |
| 6335 | m_errorMonitor->SetBailout(&data.bailout); |
| 6336 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6337 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6338 | // Add many entries to command buffer from this thread at the same time. |
| 6339 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6340 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6341 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6342 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6343 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6344 | m_errorMonitor->SetBailout(NULL); |
| 6345 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6346 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6347 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6348 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6349 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6350 | #endif // GTEST_IS_THREADSAFE |
| 6351 | #endif // THREADING_TESTS |
| 6352 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6353 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6355 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6356 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6357 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6360 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6361 | VkShaderModule module; |
| 6362 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6363 | struct icd_spv_header spv; |
| 6364 | |
| 6365 | spv.magic = ICD_SPV_MAGIC; |
| 6366 | spv.version = ICD_SPV_VERSION; |
| 6367 | spv.gen_magic = 0; |
| 6368 | |
| 6369 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6370 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6371 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6372 | moduleCreateInfo.codeSize = 4; |
| 6373 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6374 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6375 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6376 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6377 | } |
| 6378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6379 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6380 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6381 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6382 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6384 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6385 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6386 | VkShaderModule module; |
| 6387 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6388 | struct icd_spv_header spv; |
| 6389 | |
| 6390 | spv.magic = ~ICD_SPV_MAGIC; |
| 6391 | spv.version = ICD_SPV_VERSION; |
| 6392 | spv.gen_magic = 0; |
| 6393 | |
| 6394 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6395 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6396 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6397 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6398 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6399 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6400 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6401 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6402 | } |
| 6403 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6404 | #if 0 |
| 6405 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6406 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6407 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6408 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6409 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6410 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6411 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6412 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6413 | VkShaderModule module; |
| 6414 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6415 | struct icd_spv_header spv; |
| 6416 | |
| 6417 | spv.magic = ICD_SPV_MAGIC; |
| 6418 | spv.version = ~ICD_SPV_VERSION; |
| 6419 | spv.gen_magic = 0; |
| 6420 | |
| 6421 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6422 | moduleCreateInfo.pNext = NULL; |
| 6423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6425 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6426 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6427 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6428 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6429 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6430 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6431 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6433 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6434 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6435 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6436 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6437 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6438 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6439 | |
| 6440 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6441 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6442 | "\n" |
| 6443 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6444 | "out gl_PerVertex {\n" |
| 6445 | " vec4 gl_Position;\n" |
| 6446 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6447 | "void main(){\n" |
| 6448 | " gl_Position = vec4(1);\n" |
| 6449 | " x = 0;\n" |
| 6450 | "}\n"; |
| 6451 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6452 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6453 | "\n" |
| 6454 | "layout(location=0) out vec4 color;\n" |
| 6455 | "void main(){\n" |
| 6456 | " color = vec4(1);\n" |
| 6457 | "}\n"; |
| 6458 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6459 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6460 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6461 | |
| 6462 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6463 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6464 | pipe.AddShader(&vs); |
| 6465 | pipe.AddShader(&fs); |
| 6466 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6467 | VkDescriptorSetObj descriptorSet(m_device); |
| 6468 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6469 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6470 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6471 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6473 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6474 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6476 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6477 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6479 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6482 | |
| 6483 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6484 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6485 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6486 | "out gl_PerVertex {\n" |
| 6487 | " vec4 gl_Position;\n" |
| 6488 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6489 | "void main(){\n" |
| 6490 | " gl_Position = vec4(1);\n" |
| 6491 | "}\n"; |
| 6492 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6493 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6494 | "\n" |
| 6495 | "layout(location=0) in float x;\n" |
| 6496 | "layout(location=0) out vec4 color;\n" |
| 6497 | "void main(){\n" |
| 6498 | " color = vec4(x);\n" |
| 6499 | "}\n"; |
| 6500 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6501 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6502 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6503 | |
| 6504 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6505 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6506 | pipe.AddShader(&vs); |
| 6507 | pipe.AddShader(&fs); |
| 6508 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6509 | VkDescriptorSetObj descriptorSet(m_device); |
| 6510 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6511 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6512 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6513 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6514 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6515 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6516 | } |
| 6517 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6518 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6519 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6520 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6521 | |
| 6522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6523 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6524 | |
| 6525 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6526 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6527 | "\n" |
| 6528 | "out gl_PerVertex {\n" |
| 6529 | " vec4 gl_Position;\n" |
| 6530 | "};\n" |
| 6531 | "void main(){\n" |
| 6532 | " gl_Position = vec4(1);\n" |
| 6533 | "}\n"; |
| 6534 | char const *fsSource = |
| 6535 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6536 | "\n" |
| 6537 | "in block { layout(location=0) float x; } ins;\n" |
| 6538 | "layout(location=0) out vec4 color;\n" |
| 6539 | "void main(){\n" |
| 6540 | " color = vec4(ins.x);\n" |
| 6541 | "}\n"; |
| 6542 | |
| 6543 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6544 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6545 | |
| 6546 | VkPipelineObj pipe(m_device); |
| 6547 | pipe.AddColorAttachment(); |
| 6548 | pipe.AddShader(&vs); |
| 6549 | pipe.AddShader(&fs); |
| 6550 | |
| 6551 | VkDescriptorSetObj descriptorSet(m_device); |
| 6552 | descriptorSet.AppendDummy(); |
| 6553 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6554 | |
| 6555 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6556 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6557 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6558 | } |
| 6559 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6560 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6561 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6562 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6563 | "output arr[2] of float32' vs 'ptr to " |
| 6564 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6565 | |
| 6566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6567 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6568 | |
| 6569 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6570 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6571 | "\n" |
| 6572 | "layout(location=0) out float x[2];\n" |
| 6573 | "out gl_PerVertex {\n" |
| 6574 | " vec4 gl_Position;\n" |
| 6575 | "};\n" |
| 6576 | "void main(){\n" |
| 6577 | " x[0] = 0; x[1] = 0;\n" |
| 6578 | " gl_Position = vec4(1);\n" |
| 6579 | "}\n"; |
| 6580 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6581 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6582 | "\n" |
| 6583 | "layout(location=0) in float x[3];\n" |
| 6584 | "layout(location=0) out vec4 color;\n" |
| 6585 | "void main(){\n" |
| 6586 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 6587 | "}\n"; |
| 6588 | |
| 6589 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6590 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6591 | |
| 6592 | VkPipelineObj pipe(m_device); |
| 6593 | pipe.AddColorAttachment(); |
| 6594 | pipe.AddShader(&vs); |
| 6595 | pipe.AddShader(&fs); |
| 6596 | |
| 6597 | VkDescriptorSetObj descriptorSet(m_device); |
| 6598 | descriptorSet.AppendDummy(); |
| 6599 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6600 | |
| 6601 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6602 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6603 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6604 | } |
| 6605 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6606 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6607 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6608 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6609 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6610 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6611 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6612 | |
| 6613 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6614 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6615 | "\n" |
| 6616 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6617 | "out gl_PerVertex {\n" |
| 6618 | " vec4 gl_Position;\n" |
| 6619 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6620 | "void main(){\n" |
| 6621 | " x = 0;\n" |
| 6622 | " gl_Position = vec4(1);\n" |
| 6623 | "}\n"; |
| 6624 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6625 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6626 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6627 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6628 | "layout(location=0) out vec4 color;\n" |
| 6629 | "void main(){\n" |
| 6630 | " color = vec4(x);\n" |
| 6631 | "}\n"; |
| 6632 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6633 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6634 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6635 | |
| 6636 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6637 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6638 | pipe.AddShader(&vs); |
| 6639 | pipe.AddShader(&fs); |
| 6640 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6641 | VkDescriptorSetObj descriptorSet(m_device); |
| 6642 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6643 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6644 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6645 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6646 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6647 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6648 | } |
| 6649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6651 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6652 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6653 | |
| 6654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6655 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6656 | |
| 6657 | char const *vsSource = |
| 6658 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6659 | "\n" |
| 6660 | "out block { layout(location=0) int x; } outs;\n" |
| 6661 | "out gl_PerVertex {\n" |
| 6662 | " vec4 gl_Position;\n" |
| 6663 | "};\n" |
| 6664 | "void main(){\n" |
| 6665 | " outs.x = 0;\n" |
| 6666 | " gl_Position = vec4(1);\n" |
| 6667 | "}\n"; |
| 6668 | char const *fsSource = |
| 6669 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6670 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6671 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6672 | "layout(location=0) out vec4 color;\n" |
| 6673 | "void main(){\n" |
| 6674 | " color = vec4(ins.x);\n" |
| 6675 | "}\n"; |
| 6676 | |
| 6677 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6678 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6679 | |
| 6680 | VkPipelineObj pipe(m_device); |
| 6681 | pipe.AddColorAttachment(); |
| 6682 | pipe.AddShader(&vs); |
| 6683 | pipe.AddShader(&fs); |
| 6684 | |
| 6685 | VkDescriptorSetObj descriptorSet(m_device); |
| 6686 | descriptorSet.AppendDummy(); |
| 6687 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6688 | |
| 6689 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6690 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6691 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6692 | } |
| 6693 | |
| 6694 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 6695 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6696 | "location 0.0 which is not written by vertex shader"); |
| 6697 | |
| 6698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6699 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6700 | |
| 6701 | char const *vsSource = |
| 6702 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6703 | "\n" |
| 6704 | "out block { layout(location=1) float x; } outs;\n" |
| 6705 | "out gl_PerVertex {\n" |
| 6706 | " vec4 gl_Position;\n" |
| 6707 | "};\n" |
| 6708 | "void main(){\n" |
| 6709 | " outs.x = 0;\n" |
| 6710 | " gl_Position = vec4(1);\n" |
| 6711 | "}\n"; |
| 6712 | char const *fsSource = |
| 6713 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6714 | "\n" |
| 6715 | "in block { layout(location=0) float x; } ins;\n" |
| 6716 | "layout(location=0) out vec4 color;\n" |
| 6717 | "void main(){\n" |
| 6718 | " color = vec4(ins.x);\n" |
| 6719 | "}\n"; |
| 6720 | |
| 6721 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6722 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6723 | |
| 6724 | VkPipelineObj pipe(m_device); |
| 6725 | pipe.AddColorAttachment(); |
| 6726 | pipe.AddShader(&vs); |
| 6727 | pipe.AddShader(&fs); |
| 6728 | |
| 6729 | VkDescriptorSetObj descriptorSet(m_device); |
| 6730 | descriptorSet.AppendDummy(); |
| 6731 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6732 | |
| 6733 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6734 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6735 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6736 | } |
| 6737 | |
| 6738 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 6739 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6740 | "location 0.1 which is not written by vertex shader"); |
| 6741 | |
| 6742 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6743 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6744 | |
| 6745 | char const *vsSource = |
| 6746 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6747 | "\n" |
| 6748 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 6749 | "out gl_PerVertex {\n" |
| 6750 | " vec4 gl_Position;\n" |
| 6751 | "};\n" |
| 6752 | "void main(){\n" |
| 6753 | " outs.x = 0;\n" |
| 6754 | " gl_Position = vec4(1);\n" |
| 6755 | "}\n"; |
| 6756 | char const *fsSource = |
| 6757 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6758 | "\n" |
| 6759 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 6760 | "layout(location=0) out vec4 color;\n" |
| 6761 | "void main(){\n" |
| 6762 | " color = vec4(ins.x);\n" |
| 6763 | "}\n"; |
| 6764 | |
| 6765 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6766 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6767 | |
| 6768 | VkPipelineObj pipe(m_device); |
| 6769 | pipe.AddColorAttachment(); |
| 6770 | pipe.AddShader(&vs); |
| 6771 | pipe.AddShader(&fs); |
| 6772 | |
| 6773 | VkDescriptorSetObj descriptorSet(m_device); |
| 6774 | descriptorSet.AppendDummy(); |
| 6775 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6776 | |
| 6777 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6778 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6779 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6780 | } |
| 6781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6782 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6783 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6784 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6785 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6786 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6787 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6788 | |
| 6789 | VkVertexInputBindingDescription input_binding; |
| 6790 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6791 | |
| 6792 | VkVertexInputAttributeDescription input_attrib; |
| 6793 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6794 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6795 | |
| 6796 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6797 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6798 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6799 | "out gl_PerVertex {\n" |
| 6800 | " vec4 gl_Position;\n" |
| 6801 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6802 | "void main(){\n" |
| 6803 | " gl_Position = vec4(1);\n" |
| 6804 | "}\n"; |
| 6805 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6806 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6807 | "\n" |
| 6808 | "layout(location=0) out vec4 color;\n" |
| 6809 | "void main(){\n" |
| 6810 | " color = vec4(1);\n" |
| 6811 | "}\n"; |
| 6812 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6813 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6814 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6815 | |
| 6816 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6817 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6818 | pipe.AddShader(&vs); |
| 6819 | pipe.AddShader(&fs); |
| 6820 | |
| 6821 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6822 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6823 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6824 | VkDescriptorSetObj descriptorSet(m_device); |
| 6825 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6826 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6827 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6828 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6829 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6830 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6831 | } |
| 6832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6834 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6835 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6836 | |
| 6837 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6838 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6839 | |
| 6840 | VkVertexInputBindingDescription input_binding; |
| 6841 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6842 | |
| 6843 | VkVertexInputAttributeDescription input_attrib; |
| 6844 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6845 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6846 | |
| 6847 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6848 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6849 | "\n" |
| 6850 | "layout(location=1) in float x;\n" |
| 6851 | "out gl_PerVertex {\n" |
| 6852 | " vec4 gl_Position;\n" |
| 6853 | "};\n" |
| 6854 | "void main(){\n" |
| 6855 | " gl_Position = vec4(x);\n" |
| 6856 | "}\n"; |
| 6857 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6858 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6859 | "\n" |
| 6860 | "layout(location=0) out vec4 color;\n" |
| 6861 | "void main(){\n" |
| 6862 | " color = vec4(1);\n" |
| 6863 | "}\n"; |
| 6864 | |
| 6865 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6866 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6867 | |
| 6868 | VkPipelineObj pipe(m_device); |
| 6869 | pipe.AddColorAttachment(); |
| 6870 | pipe.AddShader(&vs); |
| 6871 | pipe.AddShader(&fs); |
| 6872 | |
| 6873 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6874 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6875 | |
| 6876 | VkDescriptorSetObj descriptorSet(m_device); |
| 6877 | descriptorSet.AppendDummy(); |
| 6878 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6879 | |
| 6880 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6881 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6882 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6883 | } |
| 6884 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6885 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 6886 | m_errorMonitor->SetDesiredFailureMsg( |
| 6887 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6888 | "VS consumes input at location 0 but not provided"); |
| 6889 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6890 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6891 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6892 | |
| 6893 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6894 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6895 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6896 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6897 | "out gl_PerVertex {\n" |
| 6898 | " vec4 gl_Position;\n" |
| 6899 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6900 | "void main(){\n" |
| 6901 | " gl_Position = x;\n" |
| 6902 | "}\n"; |
| 6903 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6904 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6905 | "\n" |
| 6906 | "layout(location=0) out vec4 color;\n" |
| 6907 | "void main(){\n" |
| 6908 | " color = vec4(1);\n" |
| 6909 | "}\n"; |
| 6910 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6911 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6912 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6913 | |
| 6914 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6915 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6916 | pipe.AddShader(&vs); |
| 6917 | pipe.AddShader(&fs); |
| 6918 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6919 | VkDescriptorSetObj descriptorSet(m_device); |
| 6920 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6921 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6922 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6923 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6924 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6925 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6926 | } |
| 6927 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6928 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 6929 | m_errorMonitor->SetDesiredFailureMsg( |
| 6930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6931 | "location 0 does not match VS input type"); |
| 6932 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6933 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6934 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6935 | |
| 6936 | VkVertexInputBindingDescription input_binding; |
| 6937 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6938 | |
| 6939 | VkVertexInputAttributeDescription input_attrib; |
| 6940 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6941 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6942 | |
| 6943 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6944 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6945 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6946 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6947 | "out gl_PerVertex {\n" |
| 6948 | " vec4 gl_Position;\n" |
| 6949 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6950 | "void main(){\n" |
| 6951 | " gl_Position = vec4(x);\n" |
| 6952 | "}\n"; |
| 6953 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6954 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6955 | "\n" |
| 6956 | "layout(location=0) out vec4 color;\n" |
| 6957 | "void main(){\n" |
| 6958 | " color = vec4(1);\n" |
| 6959 | "}\n"; |
| 6960 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6961 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6962 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6963 | |
| 6964 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6965 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6966 | pipe.AddShader(&vs); |
| 6967 | pipe.AddShader(&fs); |
| 6968 | |
| 6969 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6970 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6971 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6972 | VkDescriptorSetObj descriptorSet(m_device); |
| 6973 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6974 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6975 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6976 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6977 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6978 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6979 | } |
| 6980 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 6981 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 6982 | m_errorMonitor->SetDesiredFailureMsg( |
| 6983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6984 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 6985 | |
| 6986 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6987 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6988 | |
| 6989 | char const *vsSource = |
| 6990 | "#version 450\n" |
| 6991 | "\n" |
| 6992 | "out gl_PerVertex {\n" |
| 6993 | " vec4 gl_Position;\n" |
| 6994 | "};\n" |
| 6995 | "void main(){\n" |
| 6996 | " gl_Position = vec4(1);\n" |
| 6997 | "}\n"; |
| 6998 | char const *fsSource = |
| 6999 | "#version 450\n" |
| 7000 | "\n" |
| 7001 | "layout(location=0) out vec4 color;\n" |
| 7002 | "void main(){\n" |
| 7003 | " color = vec4(1);\n" |
| 7004 | "}\n"; |
| 7005 | |
| 7006 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7007 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7008 | |
| 7009 | VkPipelineObj pipe(m_device); |
| 7010 | pipe.AddColorAttachment(); |
| 7011 | pipe.AddShader(&vs); |
| 7012 | pipe.AddShader(&vs); |
| 7013 | pipe.AddShader(&fs); |
| 7014 | |
| 7015 | VkDescriptorSetObj descriptorSet(m_device); |
| 7016 | descriptorSet.AppendDummy(); |
| 7017 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7018 | |
| 7019 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7020 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7021 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7022 | } |
| 7023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7024 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7025 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7026 | |
| 7027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7029 | |
| 7030 | VkVertexInputBindingDescription input_binding; |
| 7031 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7032 | |
| 7033 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7034 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7035 | |
| 7036 | for (int i = 0; i < 2; i++) { |
| 7037 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7038 | input_attribs[i].location = i; |
| 7039 | } |
| 7040 | |
| 7041 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7042 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7043 | "\n" |
| 7044 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7045 | "out gl_PerVertex {\n" |
| 7046 | " vec4 gl_Position;\n" |
| 7047 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7048 | "void main(){\n" |
| 7049 | " gl_Position = x[0] + x[1];\n" |
| 7050 | "}\n"; |
| 7051 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7052 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7053 | "\n" |
| 7054 | "layout(location=0) out vec4 color;\n" |
| 7055 | "void main(){\n" |
| 7056 | " color = vec4(1);\n" |
| 7057 | "}\n"; |
| 7058 | |
| 7059 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7060 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7061 | |
| 7062 | VkPipelineObj pipe(m_device); |
| 7063 | pipe.AddColorAttachment(); |
| 7064 | pipe.AddShader(&vs); |
| 7065 | pipe.AddShader(&fs); |
| 7066 | |
| 7067 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7068 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7069 | |
| 7070 | VkDescriptorSetObj descriptorSet(m_device); |
| 7071 | descriptorSet.AppendDummy(); |
| 7072 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7073 | |
| 7074 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7075 | |
| 7076 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7077 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7078 | } |
| 7079 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7080 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7081 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7082 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7083 | |
| 7084 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7085 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7086 | |
| 7087 | VkVertexInputBindingDescription input_binding; |
| 7088 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7089 | |
| 7090 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7091 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7092 | |
| 7093 | for (int i = 0; i < 2; i++) { |
| 7094 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7095 | input_attribs[i].location = i; |
| 7096 | } |
| 7097 | |
| 7098 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7099 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7100 | "\n" |
| 7101 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7102 | "out gl_PerVertex {\n" |
| 7103 | " vec4 gl_Position;\n" |
| 7104 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7105 | "void main(){\n" |
| 7106 | " gl_Position = x[0] + x[1];\n" |
| 7107 | "}\n"; |
| 7108 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7109 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7110 | "\n" |
| 7111 | "layout(location=0) out vec4 color;\n" |
| 7112 | "void main(){\n" |
| 7113 | " color = vec4(1);\n" |
| 7114 | "}\n"; |
| 7115 | |
| 7116 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7117 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7118 | |
| 7119 | VkPipelineObj pipe(m_device); |
| 7120 | pipe.AddColorAttachment(); |
| 7121 | pipe.AddShader(&vs); |
| 7122 | pipe.AddShader(&fs); |
| 7123 | |
| 7124 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7125 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7126 | |
| 7127 | VkDescriptorSetObj descriptorSet(m_device); |
| 7128 | descriptorSet.AppendDummy(); |
| 7129 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7130 | |
| 7131 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7132 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7133 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7134 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7135 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7136 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7137 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7138 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7139 | |
| 7140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7141 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7142 | |
| 7143 | char const *vsSource = |
| 7144 | "#version 450\n" |
| 7145 | "out gl_PerVertex {\n" |
| 7146 | " vec4 gl_Position;\n" |
| 7147 | "};\n" |
| 7148 | "void main(){\n" |
| 7149 | " gl_Position = vec4(0);\n" |
| 7150 | "}\n"; |
| 7151 | char const *fsSource = |
| 7152 | "#version 450\n" |
| 7153 | "\n" |
| 7154 | "layout(location=0) out vec4 color;\n" |
| 7155 | "void main(){\n" |
| 7156 | " color = vec4(1);\n" |
| 7157 | "}\n"; |
| 7158 | |
| 7159 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7160 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7161 | |
| 7162 | VkPipelineObj pipe(m_device); |
| 7163 | pipe.AddColorAttachment(); |
| 7164 | pipe.AddShader(&vs); |
| 7165 | pipe.AddShader(&fs); |
| 7166 | |
| 7167 | VkDescriptorSetObj descriptorSet(m_device); |
| 7168 | descriptorSet.AppendDummy(); |
| 7169 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7170 | |
| 7171 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7173 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7174 | } |
| 7175 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7176 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7177 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7178 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7179 | |
| 7180 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7181 | |
| 7182 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7183 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7184 | |
| 7185 | char const *vsSource = |
| 7186 | "#version 450\n" |
| 7187 | "out gl_PerVertex {\n" |
| 7188 | " vec4 gl_Position;\n" |
| 7189 | "};\n" |
| 7190 | "layout(location=0) out vec3 x;\n" |
| 7191 | "layout(location=1) out ivec3 y;\n" |
| 7192 | "layout(location=2) out vec3 z;\n" |
| 7193 | "void main(){\n" |
| 7194 | " gl_Position = vec4(0);\n" |
| 7195 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7196 | "}\n"; |
| 7197 | char const *fsSource = |
| 7198 | "#version 450\n" |
| 7199 | "\n" |
| 7200 | "layout(location=0) out vec4 color;\n" |
| 7201 | "layout(location=0) in float x;\n" |
| 7202 | "layout(location=1) flat in int y;\n" |
| 7203 | "layout(location=2) in vec2 z;\n" |
| 7204 | "void main(){\n" |
| 7205 | " color = vec4(1 + x + y + z.x);\n" |
| 7206 | "}\n"; |
| 7207 | |
| 7208 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7209 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7210 | |
| 7211 | VkPipelineObj pipe(m_device); |
| 7212 | pipe.AddColorAttachment(); |
| 7213 | pipe.AddShader(&vs); |
| 7214 | pipe.AddShader(&fs); |
| 7215 | |
| 7216 | VkDescriptorSetObj descriptorSet(m_device); |
| 7217 | descriptorSet.AppendDummy(); |
| 7218 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7219 | |
| 7220 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7221 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7222 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7223 | } |
| 7224 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7225 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7226 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7227 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7228 | |
| 7229 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7230 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7231 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7232 | if (!m_device->phy().features().tessellationShader) { |
| 7233 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7234 | return; |
| 7235 | } |
| 7236 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7237 | char const *vsSource = |
| 7238 | "#version 450\n" |
| 7239 | "void main(){}\n"; |
| 7240 | char const *tcsSource = |
| 7241 | "#version 450\n" |
| 7242 | "layout(location=0) out int x[];\n" |
| 7243 | "layout(vertices=3) out;\n" |
| 7244 | "void main(){\n" |
| 7245 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7246 | " gl_TessLevelInner[0] = 1;\n" |
| 7247 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7248 | "}\n"; |
| 7249 | char const *tesSource = |
| 7250 | "#version 450\n" |
| 7251 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7252 | "layout(location=0) in int x[];\n" |
| 7253 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7254 | "void main(){\n" |
| 7255 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7256 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7257 | "}\n"; |
| 7258 | char const *fsSource = |
| 7259 | "#version 450\n" |
| 7260 | "layout(location=0) out vec4 color;\n" |
| 7261 | "void main(){\n" |
| 7262 | " color = vec4(1);\n" |
| 7263 | "}\n"; |
| 7264 | |
| 7265 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7266 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7267 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7268 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7269 | |
| 7270 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7271 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7272 | nullptr, |
| 7273 | 0, |
| 7274 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7275 | VK_FALSE}; |
| 7276 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7277 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7278 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7279 | nullptr, |
| 7280 | 0, |
| 7281 | 3}; |
| 7282 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7283 | VkPipelineObj pipe(m_device); |
| 7284 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7285 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7286 | pipe.AddColorAttachment(); |
| 7287 | pipe.AddShader(&vs); |
| 7288 | pipe.AddShader(&tcs); |
| 7289 | pipe.AddShader(&tes); |
| 7290 | pipe.AddShader(&fs); |
| 7291 | |
| 7292 | VkDescriptorSetObj descriptorSet(m_device); |
| 7293 | descriptorSet.AppendDummy(); |
| 7294 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7295 | |
| 7296 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7297 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7298 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7299 | } |
| 7300 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7301 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7302 | { |
| 7303 | m_errorMonitor->ExpectSuccess(); |
| 7304 | |
| 7305 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7306 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7307 | |
| 7308 | if (!m_device->phy().features().geometryShader) { |
| 7309 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7310 | return; |
| 7311 | } |
| 7312 | |
| 7313 | char const *vsSource = |
| 7314 | "#version 450\n" |
| 7315 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7316 | "void main(){\n" |
| 7317 | " vs_out.x = vec4(1);\n" |
| 7318 | "}\n"; |
| 7319 | char const *gsSource = |
| 7320 | "#version 450\n" |
| 7321 | "layout(triangles) in;\n" |
| 7322 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7323 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7324 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7325 | "void main() {\n" |
| 7326 | " gl_Position = gs_in[0].x;\n" |
| 7327 | " EmitVertex();\n" |
| 7328 | "}\n"; |
| 7329 | char const *fsSource = |
| 7330 | "#version 450\n" |
| 7331 | "layout(location=0) out vec4 color;\n" |
| 7332 | "void main(){\n" |
| 7333 | " color = vec4(1);\n" |
| 7334 | "}\n"; |
| 7335 | |
| 7336 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7337 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7338 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7339 | |
| 7340 | VkPipelineObj pipe(m_device); |
| 7341 | pipe.AddColorAttachment(); |
| 7342 | pipe.AddShader(&vs); |
| 7343 | pipe.AddShader(&gs); |
| 7344 | pipe.AddShader(&fs); |
| 7345 | |
| 7346 | VkDescriptorSetObj descriptorSet(m_device); |
| 7347 | descriptorSet.AppendDummy(); |
| 7348 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7349 | |
| 7350 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7351 | |
| 7352 | m_errorMonitor->VerifyNotFound(); |
| 7353 | } |
| 7354 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7355 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7356 | { |
| 7357 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7358 | "is per-vertex in tessellation control shader stage " |
| 7359 | "but per-patch in tessellation evaluation shader stage"); |
| 7360 | |
| 7361 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7362 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7363 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7364 | if (!m_device->phy().features().tessellationShader) { |
| 7365 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7366 | return; |
| 7367 | } |
| 7368 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7369 | char const *vsSource = |
| 7370 | "#version 450\n" |
| 7371 | "void main(){}\n"; |
| 7372 | char const *tcsSource = |
| 7373 | "#version 450\n" |
| 7374 | "layout(location=0) out int x[];\n" |
| 7375 | "layout(vertices=3) out;\n" |
| 7376 | "void main(){\n" |
| 7377 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7378 | " gl_TessLevelInner[0] = 1;\n" |
| 7379 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7380 | "}\n"; |
| 7381 | char const *tesSource = |
| 7382 | "#version 450\n" |
| 7383 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7384 | "layout(location=0) patch in int x;\n" |
| 7385 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7386 | "void main(){\n" |
| 7387 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7388 | " gl_Position.w = x;\n" |
| 7389 | "}\n"; |
| 7390 | char const *fsSource = |
| 7391 | "#version 450\n" |
| 7392 | "layout(location=0) out vec4 color;\n" |
| 7393 | "void main(){\n" |
| 7394 | " color = vec4(1);\n" |
| 7395 | "}\n"; |
| 7396 | |
| 7397 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7398 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7399 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7400 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7401 | |
| 7402 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7403 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7404 | nullptr, |
| 7405 | 0, |
| 7406 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7407 | VK_FALSE}; |
| 7408 | |
| 7409 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7410 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7411 | nullptr, |
| 7412 | 0, |
| 7413 | 3}; |
| 7414 | |
| 7415 | VkPipelineObj pipe(m_device); |
| 7416 | pipe.SetInputAssembly(&iasci); |
| 7417 | pipe.SetTessellation(&tsci); |
| 7418 | pipe.AddColorAttachment(); |
| 7419 | pipe.AddShader(&vs); |
| 7420 | pipe.AddShader(&tcs); |
| 7421 | pipe.AddShader(&tes); |
| 7422 | pipe.AddShader(&fs); |
| 7423 | |
| 7424 | VkDescriptorSetObj descriptorSet(m_device); |
| 7425 | descriptorSet.AppendDummy(); |
| 7426 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7427 | |
| 7428 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7429 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7430 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7431 | } |
| 7432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7433 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7434 | m_errorMonitor->SetDesiredFailureMsg( |
| 7435 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7436 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7437 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7439 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7440 | |
| 7441 | /* Two binding descriptions for binding 0 */ |
| 7442 | VkVertexInputBindingDescription input_bindings[2]; |
| 7443 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7444 | |
| 7445 | VkVertexInputAttributeDescription input_attrib; |
| 7446 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7447 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7448 | |
| 7449 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7450 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7451 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7452 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7453 | "out gl_PerVertex {\n" |
| 7454 | " vec4 gl_Position;\n" |
| 7455 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7456 | "void main(){\n" |
| 7457 | " gl_Position = vec4(x);\n" |
| 7458 | "}\n"; |
| 7459 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7460 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7461 | "\n" |
| 7462 | "layout(location=0) out vec4 color;\n" |
| 7463 | "void main(){\n" |
| 7464 | " color = vec4(1);\n" |
| 7465 | "}\n"; |
| 7466 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7467 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7468 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7469 | |
| 7470 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7471 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7472 | pipe.AddShader(&vs); |
| 7473 | pipe.AddShader(&fs); |
| 7474 | |
| 7475 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7476 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7477 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7478 | VkDescriptorSetObj descriptorSet(m_device); |
| 7479 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7480 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7481 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7482 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7483 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7484 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7485 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7486 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7487 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7488 | m_errorMonitor->ExpectSuccess(); |
| 7489 | |
| 7490 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7491 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7492 | |
| 7493 | if (!m_device->phy().features().tessellationShader) { |
| 7494 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7495 | return; |
| 7496 | } |
| 7497 | |
| 7498 | VkVertexInputBindingDescription input_bindings[1]; |
| 7499 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7500 | |
| 7501 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7502 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7503 | input_attribs[0].location = 0; |
| 7504 | input_attribs[0].offset = 0; |
| 7505 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7506 | input_attribs[1].location = 2; |
| 7507 | input_attribs[1].offset = 32; |
| 7508 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7509 | input_attribs[2].location = 4; |
| 7510 | input_attribs[2].offset = 64; |
| 7511 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7512 | input_attribs[3].location = 6; |
| 7513 | input_attribs[3].offset = 96; |
| 7514 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7515 | |
| 7516 | char const *vsSource = |
| 7517 | "#version 450\n" |
| 7518 | "\n" |
| 7519 | "layout(location=0) in dmat4 x;\n" |
| 7520 | "out gl_PerVertex {\n" |
| 7521 | " vec4 gl_Position;\n" |
| 7522 | "};\n" |
| 7523 | "void main(){\n" |
| 7524 | " gl_Position = vec4(x[0][0]);\n" |
| 7525 | "}\n"; |
| 7526 | char const *fsSource = |
| 7527 | "#version 450\n" |
| 7528 | "\n" |
| 7529 | "layout(location=0) out vec4 color;\n" |
| 7530 | "void main(){\n" |
| 7531 | " color = vec4(1);\n" |
| 7532 | "}\n"; |
| 7533 | |
| 7534 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7535 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7536 | |
| 7537 | VkPipelineObj pipe(m_device); |
| 7538 | pipe.AddColorAttachment(); |
| 7539 | pipe.AddShader(&vs); |
| 7540 | pipe.AddShader(&fs); |
| 7541 | |
| 7542 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 7543 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 7544 | |
| 7545 | VkDescriptorSetObj descriptorSet(m_device); |
| 7546 | descriptorSet.AppendDummy(); |
| 7547 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7548 | |
| 7549 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7550 | |
| 7551 | m_errorMonitor->VerifyNotFound(); |
| 7552 | } |
| 7553 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7554 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7555 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7556 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7557 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7559 | |
| 7560 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7561 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7562 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7563 | "out gl_PerVertex {\n" |
| 7564 | " vec4 gl_Position;\n" |
| 7565 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7566 | "void main(){\n" |
| 7567 | " gl_Position = vec4(1);\n" |
| 7568 | "}\n"; |
| 7569 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7570 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7571 | "\n" |
| 7572 | "void main(){\n" |
| 7573 | "}\n"; |
| 7574 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7575 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7576 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7577 | |
| 7578 | VkPipelineObj pipe(m_device); |
| 7579 | pipe.AddShader(&vs); |
| 7580 | pipe.AddShader(&fs); |
| 7581 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7582 | /* set up CB 0, not written */ |
| 7583 | pipe.AddColorAttachment(); |
| 7584 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7585 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7586 | VkDescriptorSetObj descriptorSet(m_device); |
| 7587 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7588 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7589 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7590 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7591 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7592 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7593 | } |
| 7594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7595 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7596 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7597 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7598 | "FS writes to output location 1 with no matching attachment"); |
| 7599 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7600 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7601 | |
| 7602 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7603 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7604 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7605 | "out gl_PerVertex {\n" |
| 7606 | " vec4 gl_Position;\n" |
| 7607 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7608 | "void main(){\n" |
| 7609 | " gl_Position = vec4(1);\n" |
| 7610 | "}\n"; |
| 7611 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7612 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7613 | "\n" |
| 7614 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7615 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7616 | "void main(){\n" |
| 7617 | " x = vec4(1);\n" |
| 7618 | " y = vec4(1);\n" |
| 7619 | "}\n"; |
| 7620 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7621 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7622 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7623 | |
| 7624 | VkPipelineObj pipe(m_device); |
| 7625 | pipe.AddShader(&vs); |
| 7626 | pipe.AddShader(&fs); |
| 7627 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7628 | /* set up CB 0, not written */ |
| 7629 | pipe.AddColorAttachment(); |
| 7630 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7631 | /* FS writes CB 1, but we don't configure it */ |
| 7632 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7633 | VkDescriptorSetObj descriptorSet(m_device); |
| 7634 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7635 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7636 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7637 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7638 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7639 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7640 | } |
| 7641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7642 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7643 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7644 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7645 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7647 | |
| 7648 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7649 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7650 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7651 | "out gl_PerVertex {\n" |
| 7652 | " vec4 gl_Position;\n" |
| 7653 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7654 | "void main(){\n" |
| 7655 | " gl_Position = vec4(1);\n" |
| 7656 | "}\n"; |
| 7657 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7658 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7659 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7660 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7661 | "void main(){\n" |
| 7662 | " x = ivec4(1);\n" |
| 7663 | "}\n"; |
| 7664 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7665 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7666 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7667 | |
| 7668 | VkPipelineObj pipe(m_device); |
| 7669 | pipe.AddShader(&vs); |
| 7670 | pipe.AddShader(&fs); |
| 7671 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7672 | /* set up CB 0; type is UNORM by default */ |
| 7673 | pipe.AddColorAttachment(); |
| 7674 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7675 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7676 | VkDescriptorSetObj descriptorSet(m_device); |
| 7677 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7678 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7679 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7680 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7681 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7682 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7683 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 7684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7685 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7686 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7687 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7688 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7690 | |
| 7691 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7692 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7693 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7694 | "out gl_PerVertex {\n" |
| 7695 | " vec4 gl_Position;\n" |
| 7696 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7697 | "void main(){\n" |
| 7698 | " gl_Position = vec4(1);\n" |
| 7699 | "}\n"; |
| 7700 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7701 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7702 | "\n" |
| 7703 | "layout(location=0) out vec4 x;\n" |
| 7704 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 7705 | "void main(){\n" |
| 7706 | " x = vec4(bar.y);\n" |
| 7707 | "}\n"; |
| 7708 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7709 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7710 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7711 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7712 | VkPipelineObj pipe(m_device); |
| 7713 | pipe.AddShader(&vs); |
| 7714 | pipe.AddShader(&fs); |
| 7715 | |
| 7716 | /* set up CB 0; type is UNORM by default */ |
| 7717 | pipe.AddColorAttachment(); |
| 7718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7719 | |
| 7720 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7721 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7722 | |
| 7723 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7724 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7725 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7726 | } |
| 7727 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7728 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 7729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7730 | "not declared in layout"); |
| 7731 | |
| 7732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7733 | |
| 7734 | char const *vsSource = |
| 7735 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7736 | "\n" |
| 7737 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 7738 | "out gl_PerVertex {\n" |
| 7739 | " vec4 gl_Position;\n" |
| 7740 | "};\n" |
| 7741 | "void main(){\n" |
| 7742 | " gl_Position = vec4(consts.x);\n" |
| 7743 | "}\n"; |
| 7744 | char const *fsSource = |
| 7745 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7746 | "\n" |
| 7747 | "layout(location=0) out vec4 x;\n" |
| 7748 | "void main(){\n" |
| 7749 | " x = vec4(1);\n" |
| 7750 | "}\n"; |
| 7751 | |
| 7752 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7753 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7754 | |
| 7755 | VkPipelineObj pipe(m_device); |
| 7756 | pipe.AddShader(&vs); |
| 7757 | pipe.AddShader(&fs); |
| 7758 | |
| 7759 | /* set up CB 0; type is UNORM by default */ |
| 7760 | pipe.AddColorAttachment(); |
| 7761 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7762 | |
| 7763 | VkDescriptorSetObj descriptorSet(m_device); |
| 7764 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7765 | |
| 7766 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7767 | |
| 7768 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7769 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7770 | } |
| 7771 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7772 | #endif // SHADER_CHECKER_TESTS |
| 7773 | |
| 7774 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7775 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7776 | m_errorMonitor->SetDesiredFailureMsg( |
| 7777 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7778 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7779 | |
| 7780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7781 | |
| 7782 | // Create an image |
| 7783 | VkImage image; |
| 7784 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7785 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7786 | const int32_t tex_width = 32; |
| 7787 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7788 | |
| 7789 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7790 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7791 | image_create_info.pNext = NULL; |
| 7792 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7793 | image_create_info.format = tex_format; |
| 7794 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7795 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7796 | image_create_info.extent.depth = 1; |
| 7797 | image_create_info.mipLevels = 1; |
| 7798 | image_create_info.arrayLayers = 1; |
| 7799 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7800 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7801 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7802 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7803 | |
| 7804 | // Introduce error by sending down a bogus width extent |
| 7805 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7806 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7807 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7808 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7809 | } |
| 7810 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7811 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 7812 | m_errorMonitor->SetDesiredFailureMsg( |
| 7813 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7814 | "CreateImage extents is 0 for at least one required dimension"); |
| 7815 | |
| 7816 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7817 | |
| 7818 | // Create an image |
| 7819 | VkImage image; |
| 7820 | |
| 7821 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7822 | const int32_t tex_width = 32; |
| 7823 | const int32_t tex_height = 32; |
| 7824 | |
| 7825 | VkImageCreateInfo image_create_info = {}; |
| 7826 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7827 | image_create_info.pNext = NULL; |
| 7828 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7829 | image_create_info.format = tex_format; |
| 7830 | image_create_info.extent.width = tex_width; |
| 7831 | image_create_info.extent.height = tex_height; |
| 7832 | image_create_info.extent.depth = 1; |
| 7833 | image_create_info.mipLevels = 1; |
| 7834 | image_create_info.arrayLayers = 1; |
| 7835 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7836 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7837 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7838 | image_create_info.flags = 0; |
| 7839 | |
| 7840 | // Introduce error by sending down a bogus width extent |
| 7841 | image_create_info.extent.width = 0; |
| 7842 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 7843 | |
| 7844 | m_errorMonitor->VerifyFound(); |
| 7845 | } |
| 7846 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7847 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 7848 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7849 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7851 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7852 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7854 | |
| 7855 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7856 | vk_testing::Buffer buffer; |
| 7857 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7858 | |
| 7859 | BeginCommandBuffer(); |
| 7860 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7861 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7862 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7863 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7864 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7865 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7866 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7867 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7868 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7869 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7870 | EndCommandBuffer(); |
| 7871 | } |
| 7872 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7873 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7875 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7876 | |
| 7877 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7878 | |
| 7879 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7880 | vk_testing::Buffer buffer; |
| 7881 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7882 | |
| 7883 | BeginCommandBuffer(); |
| 7884 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7885 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7886 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7887 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7888 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7890 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7891 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7892 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7893 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7894 | m_errorMonitor->VerifyFound(); |
| 7895 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7896 | EndCommandBuffer(); |
| 7897 | } |
| 7898 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7899 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7900 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7901 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7902 | TEST_F(VkLayerTest, InvalidImageView) { |
| 7903 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7905 | m_errorMonitor->SetDesiredFailureMsg( |
| 7906 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7907 | "vkCreateImageView called with baseMipLevel 10 "); |
| 7908 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7910 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7911 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7912 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7913 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7914 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7915 | const int32_t tex_width = 32; |
| 7916 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7917 | |
| 7918 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7919 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7920 | image_create_info.pNext = NULL; |
| 7921 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7922 | image_create_info.format = tex_format; |
| 7923 | image_create_info.extent.width = tex_width; |
| 7924 | image_create_info.extent.height = tex_height; |
| 7925 | image_create_info.extent.depth = 1; |
| 7926 | image_create_info.mipLevels = 1; |
| 7927 | image_create_info.arrayLayers = 1; |
| 7928 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7929 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7930 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7931 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7932 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7933 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7934 | ASSERT_VK_SUCCESS(err); |
| 7935 | |
| 7936 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7937 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7938 | image_view_create_info.image = image; |
| 7939 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7940 | image_view_create_info.format = tex_format; |
| 7941 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7942 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 7943 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7944 | image_view_create_info.subresourceRange.aspectMask = |
| 7945 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7946 | |
| 7947 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7948 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7949 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7950 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7951 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7952 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7953 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7954 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 7955 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7956 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7957 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7958 | "vkCreateImageView: Color image " |
| 7959 | "formats must have ONLY the " |
| 7960 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7961 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7962 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7963 | |
| 7964 | // 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] | 7965 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7966 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7967 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7968 | const int32_t tex_width = 32; |
| 7969 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7970 | |
| 7971 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7972 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7973 | image_create_info.pNext = NULL; |
| 7974 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7975 | image_create_info.format = tex_format; |
| 7976 | image_create_info.extent.width = tex_width; |
| 7977 | image_create_info.extent.height = tex_height; |
| 7978 | image_create_info.extent.depth = 1; |
| 7979 | image_create_info.mipLevels = 1; |
| 7980 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7981 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7982 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7983 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7984 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7985 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7986 | ASSERT_VK_SUCCESS(err); |
| 7987 | |
| 7988 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7989 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7990 | image_view_create_info.image = image; |
| 7991 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7992 | image_view_create_info.format = tex_format; |
| 7993 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7994 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7995 | // Cause an error by setting an invalid image aspect |
| 7996 | image_view_create_info.subresourceRange.aspectMask = |
| 7997 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7998 | |
| 7999 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8000 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8001 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8002 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8003 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8004 | } |
| 8005 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8006 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8007 | VkResult err; |
| 8008 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8009 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8010 | m_errorMonitor->SetDesiredFailureMsg( |
| 8011 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8012 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8013 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8014 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8015 | |
| 8016 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | VkImage srcImage; |
| 8018 | VkImage dstImage; |
| 8019 | VkDeviceMemory srcMem; |
| 8020 | VkDeviceMemory destMem; |
| 8021 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8022 | |
| 8023 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8024 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8025 | image_create_info.pNext = NULL; |
| 8026 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8027 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8028 | image_create_info.extent.width = 32; |
| 8029 | image_create_info.extent.height = 32; |
| 8030 | image_create_info.extent.depth = 1; |
| 8031 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8032 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8033 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8034 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8035 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8036 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8038 | err = |
| 8039 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8040 | ASSERT_VK_SUCCESS(err); |
| 8041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8042 | err = |
| 8043 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8044 | ASSERT_VK_SUCCESS(err); |
| 8045 | |
| 8046 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8047 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8048 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8049 | memAlloc.pNext = NULL; |
| 8050 | memAlloc.allocationSize = 0; |
| 8051 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8052 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8053 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8054 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8055 | pass = |
| 8056 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8057 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8058 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8059 | ASSERT_VK_SUCCESS(err); |
| 8060 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8061 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8062 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8063 | pass = |
| 8064 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8065 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8066 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8067 | ASSERT_VK_SUCCESS(err); |
| 8068 | |
| 8069 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8070 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8071 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8072 | ASSERT_VK_SUCCESS(err); |
| 8073 | |
| 8074 | BeginCommandBuffer(); |
| 8075 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8076 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8077 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8078 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8079 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8080 | copyRegion.srcOffset.x = 0; |
| 8081 | copyRegion.srcOffset.y = 0; |
| 8082 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8083 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8084 | copyRegion.dstSubresource.mipLevel = 0; |
| 8085 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8086 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8087 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8088 | copyRegion.dstOffset.x = 0; |
| 8089 | copyRegion.dstOffset.y = 0; |
| 8090 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8091 | copyRegion.extent.width = 1; |
| 8092 | copyRegion.extent.height = 1; |
| 8093 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8094 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8095 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8096 | EndCommandBuffer(); |
| 8097 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8098 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8099 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8100 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8101 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8102 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8103 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8104 | } |
| 8105 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8106 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8107 | VkResult err; |
| 8108 | bool pass; |
| 8109 | |
| 8110 | // Create color images with different format sizes and try to copy between them |
| 8111 | m_errorMonitor->SetDesiredFailureMsg( |
| 8112 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8113 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8114 | |
| 8115 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8116 | |
| 8117 | // Create two images of different types and try to copy between them |
| 8118 | VkImage srcImage; |
| 8119 | VkImage dstImage; |
| 8120 | VkDeviceMemory srcMem; |
| 8121 | VkDeviceMemory destMem; |
| 8122 | VkMemoryRequirements memReqs; |
| 8123 | |
| 8124 | VkImageCreateInfo image_create_info = {}; |
| 8125 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8126 | image_create_info.pNext = NULL; |
| 8127 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8128 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8129 | image_create_info.extent.width = 32; |
| 8130 | image_create_info.extent.height = 32; |
| 8131 | image_create_info.extent.depth = 1; |
| 8132 | image_create_info.mipLevels = 1; |
| 8133 | image_create_info.arrayLayers = 1; |
| 8134 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8135 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8136 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8137 | image_create_info.flags = 0; |
| 8138 | |
| 8139 | err = |
| 8140 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8141 | ASSERT_VK_SUCCESS(err); |
| 8142 | |
| 8143 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8144 | // Introduce failure by creating second image with a different-sized format. |
| 8145 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8146 | |
| 8147 | err = |
| 8148 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8149 | ASSERT_VK_SUCCESS(err); |
| 8150 | |
| 8151 | // Allocate memory |
| 8152 | VkMemoryAllocateInfo memAlloc = {}; |
| 8153 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8154 | memAlloc.pNext = NULL; |
| 8155 | memAlloc.allocationSize = 0; |
| 8156 | memAlloc.memoryTypeIndex = 0; |
| 8157 | |
| 8158 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 8159 | memAlloc.allocationSize = memReqs.size; |
| 8160 | pass = |
| 8161 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8162 | ASSERT_TRUE(pass); |
| 8163 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 8164 | ASSERT_VK_SUCCESS(err); |
| 8165 | |
| 8166 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 8167 | memAlloc.allocationSize = memReqs.size; |
| 8168 | pass = |
| 8169 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8170 | ASSERT_TRUE(pass); |
| 8171 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 8172 | ASSERT_VK_SUCCESS(err); |
| 8173 | |
| 8174 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8175 | ASSERT_VK_SUCCESS(err); |
| 8176 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 8177 | ASSERT_VK_SUCCESS(err); |
| 8178 | |
| 8179 | BeginCommandBuffer(); |
| 8180 | VkImageCopy copyRegion; |
| 8181 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8182 | copyRegion.srcSubresource.mipLevel = 0; |
| 8183 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8184 | copyRegion.srcSubresource.layerCount = 0; |
| 8185 | copyRegion.srcOffset.x = 0; |
| 8186 | copyRegion.srcOffset.y = 0; |
| 8187 | copyRegion.srcOffset.z = 0; |
| 8188 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8189 | copyRegion.dstSubresource.mipLevel = 0; |
| 8190 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8191 | copyRegion.dstSubresource.layerCount = 0; |
| 8192 | copyRegion.dstOffset.x = 0; |
| 8193 | copyRegion.dstOffset.y = 0; |
| 8194 | copyRegion.dstOffset.z = 0; |
| 8195 | copyRegion.extent.width = 1; |
| 8196 | copyRegion.extent.height = 1; |
| 8197 | copyRegion.extent.depth = 1; |
| 8198 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8199 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8200 | EndCommandBuffer(); |
| 8201 | |
| 8202 | m_errorMonitor->VerifyFound(); |
| 8203 | |
| 8204 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 8205 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 8206 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8207 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8208 | } |
| 8209 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8210 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 8211 | VkResult err; |
| 8212 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8213 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8214 | // 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] | 8215 | m_errorMonitor->SetDesiredFailureMsg( |
| 8216 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8217 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8218 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8220 | |
| 8221 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8222 | VkImage srcImage; |
| 8223 | VkImage dstImage; |
| 8224 | VkDeviceMemory srcMem; |
| 8225 | VkDeviceMemory destMem; |
| 8226 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8227 | |
| 8228 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8229 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8230 | image_create_info.pNext = NULL; |
| 8231 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8232 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8233 | image_create_info.extent.width = 32; |
| 8234 | image_create_info.extent.height = 32; |
| 8235 | image_create_info.extent.depth = 1; |
| 8236 | image_create_info.mipLevels = 1; |
| 8237 | image_create_info.arrayLayers = 1; |
| 8238 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8239 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8240 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8241 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8243 | err = |
| 8244 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8245 | ASSERT_VK_SUCCESS(err); |
| 8246 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8247 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8248 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8249 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8250 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8251 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8252 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8253 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8254 | err = |
| 8255 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8256 | ASSERT_VK_SUCCESS(err); |
| 8257 | |
| 8258 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8259 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8261 | memAlloc.pNext = NULL; |
| 8262 | memAlloc.allocationSize = 0; |
| 8263 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8264 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8265 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8266 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8267 | pass = |
| 8268 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8269 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8270 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8271 | ASSERT_VK_SUCCESS(err); |
| 8272 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8273 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8274 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8275 | pass = |
| 8276 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8277 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8278 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8279 | ASSERT_VK_SUCCESS(err); |
| 8280 | |
| 8281 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8282 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8283 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8284 | ASSERT_VK_SUCCESS(err); |
| 8285 | |
| 8286 | BeginCommandBuffer(); |
| 8287 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8288 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8289 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8290 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8291 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8292 | copyRegion.srcOffset.x = 0; |
| 8293 | copyRegion.srcOffset.y = 0; |
| 8294 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8295 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8296 | copyRegion.dstSubresource.mipLevel = 0; |
| 8297 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8298 | copyRegion.dstSubresource.layerCount = 0; |
| 8299 | copyRegion.dstOffset.x = 0; |
| 8300 | copyRegion.dstOffset.y = 0; |
| 8301 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8302 | copyRegion.extent.width = 1; |
| 8303 | copyRegion.extent.height = 1; |
| 8304 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8305 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8306 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8307 | EndCommandBuffer(); |
| 8308 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8309 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8310 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8311 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8312 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8313 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8314 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8315 | } |
| 8316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8317 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 8318 | VkResult err; |
| 8319 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8321 | m_errorMonitor->SetDesiredFailureMsg( |
| 8322 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8323 | "vkCmdResolveImage called with source sample count less than 2."); |
| 8324 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8325 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8326 | |
| 8327 | // 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] | 8328 | VkImage srcImage; |
| 8329 | VkImage dstImage; |
| 8330 | VkDeviceMemory srcMem; |
| 8331 | VkDeviceMemory destMem; |
| 8332 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8333 | |
| 8334 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8335 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8336 | image_create_info.pNext = NULL; |
| 8337 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8338 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8339 | image_create_info.extent.width = 32; |
| 8340 | image_create_info.extent.height = 1; |
| 8341 | image_create_info.extent.depth = 1; |
| 8342 | image_create_info.mipLevels = 1; |
| 8343 | image_create_info.arrayLayers = 1; |
| 8344 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8345 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8346 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8347 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | err = |
| 8350 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8351 | ASSERT_VK_SUCCESS(err); |
| 8352 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8353 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8354 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8355 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8356 | err = |
| 8357 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8358 | ASSERT_VK_SUCCESS(err); |
| 8359 | |
| 8360 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8361 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8363 | memAlloc.pNext = NULL; |
| 8364 | memAlloc.allocationSize = 0; |
| 8365 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8366 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8367 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8368 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8369 | pass = |
| 8370 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8371 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8372 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8373 | ASSERT_VK_SUCCESS(err); |
| 8374 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8375 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8376 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8377 | pass = |
| 8378 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8379 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8380 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8381 | ASSERT_VK_SUCCESS(err); |
| 8382 | |
| 8383 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8384 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8385 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8386 | ASSERT_VK_SUCCESS(err); |
| 8387 | |
| 8388 | BeginCommandBuffer(); |
| 8389 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8390 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8391 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8392 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8393 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8394 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8395 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8396 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8397 | resolveRegion.srcOffset.x = 0; |
| 8398 | resolveRegion.srcOffset.y = 0; |
| 8399 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8400 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8401 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8402 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8403 | resolveRegion.dstSubresource.layerCount = 0; |
| 8404 | resolveRegion.dstOffset.x = 0; |
| 8405 | resolveRegion.dstOffset.y = 0; |
| 8406 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8407 | resolveRegion.extent.width = 1; |
| 8408 | resolveRegion.extent.height = 1; |
| 8409 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8410 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8411 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8412 | EndCommandBuffer(); |
| 8413 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8414 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8415 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8416 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8417 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8418 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8419 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8420 | } |
| 8421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8422 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 8423 | VkResult err; |
| 8424 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8426 | m_errorMonitor->SetDesiredFailureMsg( |
| 8427 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8428 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 8429 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8431 | |
| 8432 | // 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] | 8433 | VkImage srcImage; |
| 8434 | VkImage dstImage; |
| 8435 | VkDeviceMemory srcMem; |
| 8436 | VkDeviceMemory destMem; |
| 8437 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8438 | |
| 8439 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8440 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8441 | image_create_info.pNext = NULL; |
| 8442 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8443 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8444 | image_create_info.extent.width = 32; |
| 8445 | image_create_info.extent.height = 1; |
| 8446 | image_create_info.extent.depth = 1; |
| 8447 | image_create_info.mipLevels = 1; |
| 8448 | image_create_info.arrayLayers = 1; |
| 8449 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8450 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8451 | // Note: Some implementations expect color attachment usage for any |
| 8452 | // multisample surface |
| 8453 | image_create_info.usage = |
| 8454 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8455 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8457 | err = |
| 8458 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8459 | ASSERT_VK_SUCCESS(err); |
| 8460 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8461 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8462 | // Note: Some implementations expect color attachment usage for any |
| 8463 | // multisample surface |
| 8464 | image_create_info.usage = |
| 8465 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8467 | err = |
| 8468 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8469 | ASSERT_VK_SUCCESS(err); |
| 8470 | |
| 8471 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8472 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8473 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8474 | memAlloc.pNext = NULL; |
| 8475 | memAlloc.allocationSize = 0; |
| 8476 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8477 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8478 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8479 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8480 | pass = |
| 8481 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8482 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8483 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8484 | ASSERT_VK_SUCCESS(err); |
| 8485 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8486 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8487 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8488 | pass = |
| 8489 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8490 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8491 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8492 | ASSERT_VK_SUCCESS(err); |
| 8493 | |
| 8494 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8495 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8496 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8497 | ASSERT_VK_SUCCESS(err); |
| 8498 | |
| 8499 | BeginCommandBuffer(); |
| 8500 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8501 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8502 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8503 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8504 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8505 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8506 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8507 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8508 | resolveRegion.srcOffset.x = 0; |
| 8509 | resolveRegion.srcOffset.y = 0; |
| 8510 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8511 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8512 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8513 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8514 | resolveRegion.dstSubresource.layerCount = 0; |
| 8515 | resolveRegion.dstOffset.x = 0; |
| 8516 | resolveRegion.dstOffset.y = 0; |
| 8517 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8518 | resolveRegion.extent.width = 1; |
| 8519 | resolveRegion.extent.height = 1; |
| 8520 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8521 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8522 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8523 | EndCommandBuffer(); |
| 8524 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8525 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8526 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8527 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8528 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8529 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8530 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8531 | } |
| 8532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8533 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 8534 | VkResult err; |
| 8535 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8536 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8537 | m_errorMonitor->SetDesiredFailureMsg( |
| 8538 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8539 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 8540 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8542 | |
| 8543 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8544 | VkImage srcImage; |
| 8545 | VkImage dstImage; |
| 8546 | VkDeviceMemory srcMem; |
| 8547 | VkDeviceMemory destMem; |
| 8548 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8549 | |
| 8550 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8551 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8552 | image_create_info.pNext = NULL; |
| 8553 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8554 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8555 | image_create_info.extent.width = 32; |
| 8556 | image_create_info.extent.height = 1; |
| 8557 | image_create_info.extent.depth = 1; |
| 8558 | image_create_info.mipLevels = 1; |
| 8559 | image_create_info.arrayLayers = 1; |
| 8560 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8561 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8562 | // Note: Some implementations expect color attachment usage for any |
| 8563 | // multisample surface |
| 8564 | image_create_info.usage = |
| 8565 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8566 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8568 | err = |
| 8569 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8570 | ASSERT_VK_SUCCESS(err); |
| 8571 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8572 | // Set format to something other than source image |
| 8573 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 8574 | // Note: Some implementations expect color attachment usage for any |
| 8575 | // multisample surface |
| 8576 | image_create_info.usage = |
| 8577 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8578 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8580 | err = |
| 8581 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8582 | ASSERT_VK_SUCCESS(err); |
| 8583 | |
| 8584 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8585 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8586 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8587 | memAlloc.pNext = NULL; |
| 8588 | memAlloc.allocationSize = 0; |
| 8589 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8590 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8591 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8592 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8593 | pass = |
| 8594 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8595 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8596 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8597 | ASSERT_VK_SUCCESS(err); |
| 8598 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8599 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8600 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8601 | pass = |
| 8602 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8603 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8604 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8605 | ASSERT_VK_SUCCESS(err); |
| 8606 | |
| 8607 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8608 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8609 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8610 | ASSERT_VK_SUCCESS(err); |
| 8611 | |
| 8612 | BeginCommandBuffer(); |
| 8613 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8614 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8615 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8616 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8617 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8618 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8619 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8620 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8621 | resolveRegion.srcOffset.x = 0; |
| 8622 | resolveRegion.srcOffset.y = 0; |
| 8623 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8624 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8625 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8626 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8627 | resolveRegion.dstSubresource.layerCount = 0; |
| 8628 | resolveRegion.dstOffset.x = 0; |
| 8629 | resolveRegion.dstOffset.y = 0; |
| 8630 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8631 | resolveRegion.extent.width = 1; |
| 8632 | resolveRegion.extent.height = 1; |
| 8633 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8634 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8635 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8636 | EndCommandBuffer(); |
| 8637 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8638 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8639 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8640 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8641 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8642 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8643 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8644 | } |
| 8645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8646 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 8647 | VkResult err; |
| 8648 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8650 | m_errorMonitor->SetDesiredFailureMsg( |
| 8651 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8652 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 8653 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8655 | |
| 8656 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8657 | VkImage srcImage; |
| 8658 | VkImage dstImage; |
| 8659 | VkDeviceMemory srcMem; |
| 8660 | VkDeviceMemory destMem; |
| 8661 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8662 | |
| 8663 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8664 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8665 | image_create_info.pNext = NULL; |
| 8666 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8667 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8668 | image_create_info.extent.width = 32; |
| 8669 | image_create_info.extent.height = 1; |
| 8670 | image_create_info.extent.depth = 1; |
| 8671 | image_create_info.mipLevels = 1; |
| 8672 | image_create_info.arrayLayers = 1; |
| 8673 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8674 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8675 | // Note: Some implementations expect color attachment usage for any |
| 8676 | // multisample surface |
| 8677 | image_create_info.usage = |
| 8678 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8679 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8681 | err = |
| 8682 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8683 | ASSERT_VK_SUCCESS(err); |
| 8684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8685 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8686 | // Note: Some implementations expect color attachment usage for any |
| 8687 | // multisample surface |
| 8688 | image_create_info.usage = |
| 8689 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8690 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8691 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8692 | err = |
| 8693 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8694 | ASSERT_VK_SUCCESS(err); |
| 8695 | |
| 8696 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8697 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8698 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8699 | memAlloc.pNext = NULL; |
| 8700 | memAlloc.allocationSize = 0; |
| 8701 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8702 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8703 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8704 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8705 | pass = |
| 8706 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8707 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8708 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8709 | ASSERT_VK_SUCCESS(err); |
| 8710 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8711 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8712 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8713 | pass = |
| 8714 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8715 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8716 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8717 | ASSERT_VK_SUCCESS(err); |
| 8718 | |
| 8719 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8720 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8721 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8722 | ASSERT_VK_SUCCESS(err); |
| 8723 | |
| 8724 | BeginCommandBuffer(); |
| 8725 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8726 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8727 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8728 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8729 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8730 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8731 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8732 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8733 | resolveRegion.srcOffset.x = 0; |
| 8734 | resolveRegion.srcOffset.y = 0; |
| 8735 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8736 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8737 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8738 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8739 | resolveRegion.dstSubresource.layerCount = 0; |
| 8740 | resolveRegion.dstOffset.x = 0; |
| 8741 | resolveRegion.dstOffset.y = 0; |
| 8742 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8743 | resolveRegion.extent.width = 1; |
| 8744 | resolveRegion.extent.height = 1; |
| 8745 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8746 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8747 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8748 | EndCommandBuffer(); |
| 8749 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8750 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8751 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8752 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8753 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8754 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8755 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8756 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8758 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8759 | // 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] | 8760 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 8761 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8762 | // The image format check comes 2nd in validation so we trigger it first, |
| 8763 | // 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] | 8764 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8765 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8766 | m_errorMonitor->SetDesiredFailureMsg( |
| 8767 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8768 | "Combination depth/stencil image formats can have only the "); |
| 8769 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8771 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8772 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8773 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8774 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8775 | |
| 8776 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8777 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8778 | ds_pool_ci.pNext = NULL; |
| 8779 | ds_pool_ci.maxSets = 1; |
| 8780 | ds_pool_ci.poolSizeCount = 1; |
| 8781 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8782 | |
| 8783 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8784 | err = |
| 8785 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8786 | ASSERT_VK_SUCCESS(err); |
| 8787 | |
| 8788 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8789 | dsl_binding.binding = 0; |
| 8790 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8791 | dsl_binding.descriptorCount = 1; |
| 8792 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8793 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8794 | |
| 8795 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8796 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8797 | ds_layout_ci.pNext = NULL; |
| 8798 | ds_layout_ci.bindingCount = 1; |
| 8799 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8800 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8801 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8802 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8803 | ASSERT_VK_SUCCESS(err); |
| 8804 | |
| 8805 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8806 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8807 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8808 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8809 | alloc_info.descriptorPool = ds_pool; |
| 8810 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8811 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8812 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8813 | ASSERT_VK_SUCCESS(err); |
| 8814 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8815 | VkImage image_bad; |
| 8816 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8817 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8818 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8819 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8820 | const int32_t tex_width = 32; |
| 8821 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8822 | |
| 8823 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8824 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8825 | image_create_info.pNext = NULL; |
| 8826 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8827 | image_create_info.format = tex_format_bad; |
| 8828 | image_create_info.extent.width = tex_width; |
| 8829 | image_create_info.extent.height = tex_height; |
| 8830 | image_create_info.extent.depth = 1; |
| 8831 | image_create_info.mipLevels = 1; |
| 8832 | image_create_info.arrayLayers = 1; |
| 8833 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8834 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8835 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 8836 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 8837 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8839 | err = |
| 8840 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8841 | ASSERT_VK_SUCCESS(err); |
| 8842 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8843 | image_create_info.usage = |
| 8844 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8845 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 8846 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8847 | ASSERT_VK_SUCCESS(err); |
| 8848 | |
| 8849 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8850 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8851 | image_view_create_info.image = image_bad; |
| 8852 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8853 | image_view_create_info.format = tex_format_bad; |
| 8854 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 8855 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8856 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8857 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8858 | image_view_create_info.subresourceRange.aspectMask = |
| 8859 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8860 | |
| 8861 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8862 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8863 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8865 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8866 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8867 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 8868 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8869 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8870 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8871 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8872 | #endif // IMAGE_TESTS |
| 8873 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8874 | int main(int argc, char **argv) { |
| 8875 | int result; |
| 8876 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 8877 | #ifdef ANDROID |
| 8878 | int vulkanSupport = InitVulkan(); |
| 8879 | if (vulkanSupport == 0) |
| 8880 | return 1; |
| 8881 | #endif |
| 8882 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8883 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8884 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8885 | |
| 8886 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 8887 | |
| 8888 | result = RUN_ALL_TESTS(); |
| 8889 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8890 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8891 | return result; |
| 8892 | } |