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 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame^] | 670 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 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 |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1332 | |
| 1333 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1334 | VkResult err; |
| 1335 | |
| 1336 | TEST_DESCRIPTION( |
| 1337 | "Create a fence and destroy its device without first destroying the fence."); |
| 1338 | |
| 1339 | // Note that we have to create a new device since destroying the |
| 1340 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1341 | // will destroy the errorMonitor. |
| 1342 | |
| 1343 | m_errorMonitor->SetDesiredFailureMsg( |
| 1344 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1345 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1346 | |
| 1347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1348 | |
| 1349 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1350 | m_device->queue_props; |
| 1351 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1352 | queue_info.reserve(queue_props.size()); |
| 1353 | std::vector<std::vector<float>> queue_priorities; |
| 1354 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1355 | VkDeviceQueueCreateInfo qi = {}; |
| 1356 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1357 | qi.pNext = NULL; |
| 1358 | qi.queueFamilyIndex = i; |
| 1359 | qi.queueCount = queue_props[i].queueCount; |
| 1360 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1361 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1362 | queue_info.push_back(qi); |
| 1363 | } |
| 1364 | |
| 1365 | std::vector<const char *> device_layer_names; |
| 1366 | std::vector<const char *> device_extension_names; |
| 1367 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1368 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1369 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1370 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1371 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1372 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1373 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1374 | |
| 1375 | // The sacrificial device object |
| 1376 | VkDevice testDevice; |
| 1377 | VkDeviceCreateInfo device_create_info = {}; |
| 1378 | auto features = m_device->phy().features(); |
| 1379 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1380 | device_create_info.pNext = NULL; |
| 1381 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1382 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1383 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1384 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1385 | device_create_info.pEnabledFeatures = &features; |
| 1386 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1387 | ASSERT_VK_SUCCESS(err); |
| 1388 | |
| 1389 | VkFence fence; |
| 1390 | VkFenceCreateInfo fence_create_info = {}; |
| 1391 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1392 | fence_create_info.pNext = NULL; |
| 1393 | fence_create_info.flags = 0; |
| 1394 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1395 | ASSERT_VK_SUCCESS(err); |
| 1396 | |
| 1397 | // Induce failure by not calling vkDestroyFence |
| 1398 | vkDestroyDevice(testDevice, NULL); |
| 1399 | m_errorMonitor->VerifyFound(); |
| 1400 | } |
| 1401 | |
| 1402 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1403 | |
| 1404 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1405 | "attempt to delete them from another."); |
| 1406 | |
| 1407 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1408 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1409 | |
| 1410 | VkCommandPool command_pool_one; |
| 1411 | VkCommandPool command_pool_two; |
| 1412 | |
| 1413 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1414 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1415 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1416 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1417 | |
| 1418 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1419 | &command_pool_one); |
| 1420 | |
| 1421 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1422 | &command_pool_two); |
| 1423 | |
| 1424 | VkCommandBuffer command_buffer[9]; |
| 1425 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1426 | command_buffer_allocate_info.sType = |
| 1427 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1428 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1429 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1430 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1431 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1432 | command_buffer); |
| 1433 | |
| 1434 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1435 | &command_buffer[3]); |
| 1436 | |
| 1437 | m_errorMonitor->VerifyFound(); |
| 1438 | |
| 1439 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1440 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1441 | } |
| 1442 | |
| 1443 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1444 | VkResult err; |
| 1445 | |
| 1446 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1447 | "attempt to delete them from another."); |
| 1448 | |
| 1449 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1450 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1451 | |
| 1452 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1454 | |
| 1455 | VkDescriptorPoolSize ds_type_count = {}; |
| 1456 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1457 | ds_type_count.descriptorCount = 1; |
| 1458 | |
| 1459 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1460 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1461 | ds_pool_ci.pNext = NULL; |
| 1462 | ds_pool_ci.flags = 0; |
| 1463 | ds_pool_ci.maxSets = 1; |
| 1464 | ds_pool_ci.poolSizeCount = 1; |
| 1465 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1466 | |
| 1467 | VkDescriptorPool ds_pool_one; |
| 1468 | err = |
| 1469 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1470 | ASSERT_VK_SUCCESS(err); |
| 1471 | |
| 1472 | // Create a second descriptor pool |
| 1473 | VkDescriptorPool ds_pool_two; |
| 1474 | err = |
| 1475 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1476 | ASSERT_VK_SUCCESS(err); |
| 1477 | |
| 1478 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1479 | dsl_binding.binding = 0; |
| 1480 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1481 | dsl_binding.descriptorCount = 1; |
| 1482 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1483 | dsl_binding.pImmutableSamplers = NULL; |
| 1484 | |
| 1485 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1486 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1487 | ds_layout_ci.pNext = NULL; |
| 1488 | ds_layout_ci.bindingCount = 1; |
| 1489 | ds_layout_ci.pBindings = &dsl_binding; |
| 1490 | |
| 1491 | VkDescriptorSetLayout ds_layout; |
| 1492 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1493 | &ds_layout); |
| 1494 | ASSERT_VK_SUCCESS(err); |
| 1495 | |
| 1496 | VkDescriptorSet descriptorSet; |
| 1497 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1498 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1499 | alloc_info.descriptorSetCount = 1; |
| 1500 | alloc_info.descriptorPool = ds_pool_one; |
| 1501 | alloc_info.pSetLayouts = &ds_layout; |
| 1502 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1503 | &descriptorSet); |
| 1504 | ASSERT_VK_SUCCESS(err); |
| 1505 | |
| 1506 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1507 | |
| 1508 | m_errorMonitor->VerifyFound(); |
| 1509 | |
| 1510 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1511 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1512 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1513 | } |
| 1514 | |
| 1515 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1516 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1517 | "Invalid VkImage Object "); |
| 1518 | |
| 1519 | TEST_DESCRIPTION( |
| 1520 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1521 | |
| 1522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1523 | |
| 1524 | // Pass bogus handle into GetImageMemoryRequirements |
| 1525 | VkMemoryRequirements mem_reqs; |
| 1526 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1527 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1528 | |
| 1529 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1530 | |
| 1531 | m_errorMonitor->VerifyFound(); |
| 1532 | } |
| 1533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1534 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1535 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1536 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1537 | TEST_DESCRIPTION( |
| 1538 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1539 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1540 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1541 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1542 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1543 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1544 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1545 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1546 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1547 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1548 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1549 | |
| 1550 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1551 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1552 | ds_pool_ci.pNext = NULL; |
| 1553 | ds_pool_ci.maxSets = 1; |
| 1554 | ds_pool_ci.poolSizeCount = 1; |
| 1555 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1556 | |
| 1557 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1558 | err = |
| 1559 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1560 | ASSERT_VK_SUCCESS(err); |
| 1561 | |
| 1562 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1563 | dsl_binding.binding = 0; |
| 1564 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1565 | dsl_binding.descriptorCount = 1; |
| 1566 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1567 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1568 | |
| 1569 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1570 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1571 | ds_layout_ci.pNext = NULL; |
| 1572 | ds_layout_ci.bindingCount = 1; |
| 1573 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1574 | |
| 1575 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1576 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1577 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1578 | ASSERT_VK_SUCCESS(err); |
| 1579 | |
| 1580 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1581 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1582 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1583 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1584 | alloc_info.descriptorPool = ds_pool; |
| 1585 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1586 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1587 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1588 | ASSERT_VK_SUCCESS(err); |
| 1589 | |
| 1590 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1591 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1592 | pipeline_layout_ci.pNext = NULL; |
| 1593 | pipeline_layout_ci.setLayoutCount = 1; |
| 1594 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1595 | |
| 1596 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1597 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1598 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1599 | ASSERT_VK_SUCCESS(err); |
| 1600 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1601 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1602 | |
| 1603 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1604 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1605 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1606 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1607 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1608 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1609 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1610 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1611 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1612 | } |
| 1613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1614 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1615 | VkResult err; |
| 1616 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1617 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1618 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1619 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1620 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1622 | |
| 1623 | // 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] | 1624 | VkImage image; |
| 1625 | VkDeviceMemory mem; |
| 1626 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1627 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1628 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1629 | const int32_t tex_width = 32; |
| 1630 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1631 | |
| 1632 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1633 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1634 | image_create_info.pNext = NULL; |
| 1635 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1636 | image_create_info.format = tex_format; |
| 1637 | image_create_info.extent.width = tex_width; |
| 1638 | image_create_info.extent.height = tex_height; |
| 1639 | image_create_info.extent.depth = 1; |
| 1640 | image_create_info.mipLevels = 1; |
| 1641 | image_create_info.arrayLayers = 1; |
| 1642 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1643 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1644 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1645 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1646 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1647 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1648 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1649 | mem_alloc.pNext = NULL; |
| 1650 | mem_alloc.allocationSize = 0; |
| 1651 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1652 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1653 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1654 | ASSERT_VK_SUCCESS(err); |
| 1655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1656 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1657 | |
| 1658 | mem_alloc.allocationSize = mem_reqs.size; |
| 1659 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1660 | pass = |
| 1661 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1662 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1663 | |
| 1664 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1665 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1666 | ASSERT_VK_SUCCESS(err); |
| 1667 | |
| 1668 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1669 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1670 | |
| 1671 | // Try to bind free memory that has been freed |
| 1672 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1673 | // This may very well return an error. |
| 1674 | (void)err; |
| 1675 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1676 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1677 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1678 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1679 | } |
| 1680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1681 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1682 | VkResult err; |
| 1683 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1686 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1687 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1688 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1689 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1690 | // Create an image object, allocate memory, destroy the object and then try |
| 1691 | // to bind it |
| 1692 | VkImage image; |
| 1693 | VkDeviceMemory mem; |
| 1694 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1695 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1696 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1697 | const int32_t tex_width = 32; |
| 1698 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1699 | |
| 1700 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1701 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1702 | image_create_info.pNext = NULL; |
| 1703 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1704 | image_create_info.format = tex_format; |
| 1705 | image_create_info.extent.width = tex_width; |
| 1706 | image_create_info.extent.height = tex_height; |
| 1707 | image_create_info.extent.depth = 1; |
| 1708 | image_create_info.mipLevels = 1; |
| 1709 | image_create_info.arrayLayers = 1; |
| 1710 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1711 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1712 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1713 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1714 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1715 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1716 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1717 | mem_alloc.pNext = NULL; |
| 1718 | mem_alloc.allocationSize = 0; |
| 1719 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1720 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1721 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1722 | ASSERT_VK_SUCCESS(err); |
| 1723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1724 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1725 | |
| 1726 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1727 | pass = |
| 1728 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1729 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1730 | |
| 1731 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1732 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1733 | ASSERT_VK_SUCCESS(err); |
| 1734 | |
| 1735 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1736 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1737 | ASSERT_VK_SUCCESS(err); |
| 1738 | |
| 1739 | // Now Try to bind memory to this destroyed object |
| 1740 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1741 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1742 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1743 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1744 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1745 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1746 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1747 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1748 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1749 | #endif // OBJ_TRACKER_TESTS |
| 1750 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1751 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1752 | |
| 1753 | // This is a positive test. No errors should be generated. |
| 1754 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1755 | |
| 1756 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1757 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1758 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1759 | if ((m_device->queue_props.empty()) || |
| 1760 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1761 | return; |
| 1762 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1763 | m_errorMonitor->ExpectSuccess(); |
| 1764 | |
| 1765 | VkSemaphore semaphore; |
| 1766 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1767 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1768 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1769 | &semaphore); |
| 1770 | |
| 1771 | VkCommandPool command_pool; |
| 1772 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1773 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1774 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1775 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1776 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1777 | &command_pool); |
| 1778 | |
| 1779 | VkCommandBuffer command_buffer[2]; |
| 1780 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1781 | command_buffer_allocate_info.sType = |
| 1782 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1783 | command_buffer_allocate_info.commandPool = command_pool; |
| 1784 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1785 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1786 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1787 | command_buffer); |
| 1788 | |
| 1789 | VkQueue queue = VK_NULL_HANDLE; |
| 1790 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1791 | 1, &queue); |
| 1792 | |
| 1793 | { |
| 1794 | VkCommandBufferBeginInfo begin_info{}; |
| 1795 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1796 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1797 | |
| 1798 | vkCmdPipelineBarrier(command_buffer[0], |
| 1799 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1800 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1801 | 0, nullptr, 0, nullptr); |
| 1802 | |
| 1803 | VkViewport viewport{}; |
| 1804 | viewport.maxDepth = 1.0f; |
| 1805 | viewport.minDepth = 0.0f; |
| 1806 | viewport.width = 512; |
| 1807 | viewport.height = 512; |
| 1808 | viewport.x = 0; |
| 1809 | viewport.y = 0; |
| 1810 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1811 | vkEndCommandBuffer(command_buffer[0]); |
| 1812 | } |
| 1813 | { |
| 1814 | VkCommandBufferBeginInfo begin_info{}; |
| 1815 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1816 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1817 | |
| 1818 | VkViewport viewport{}; |
| 1819 | viewport.maxDepth = 1.0f; |
| 1820 | viewport.minDepth = 0.0f; |
| 1821 | viewport.width = 512; |
| 1822 | viewport.height = 512; |
| 1823 | viewport.x = 0; |
| 1824 | viewport.y = 0; |
| 1825 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1826 | vkEndCommandBuffer(command_buffer[1]); |
| 1827 | } |
| 1828 | { |
| 1829 | VkSubmitInfo submit_info{}; |
| 1830 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1831 | submit_info.commandBufferCount = 1; |
| 1832 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1833 | submit_info.signalSemaphoreCount = 1; |
| 1834 | submit_info.pSignalSemaphores = &semaphore; |
| 1835 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1836 | } |
| 1837 | { |
| 1838 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1839 | VkSubmitInfo submit_info{}; |
| 1840 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1841 | submit_info.commandBufferCount = 1; |
| 1842 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1843 | submit_info.waitSemaphoreCount = 1; |
| 1844 | submit_info.pWaitSemaphores = &semaphore; |
| 1845 | submit_info.pWaitDstStageMask = flags; |
| 1846 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1847 | } |
| 1848 | |
| 1849 | vkQueueWaitIdle(m_device->m_queue); |
| 1850 | |
| 1851 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1852 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1853 | &command_buffer[0]); |
| 1854 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1855 | |
| 1856 | m_errorMonitor->VerifyNotFound(); |
| 1857 | } |
| 1858 | |
| 1859 | // This is a positive test. No errors should be generated. |
| 1860 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1861 | |
| 1862 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1863 | "submitted on separate queues, the second having a fence" |
| 1864 | "followed by a QueueWaitIdle."); |
| 1865 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1866 | if ((m_device->queue_props.empty()) || |
| 1867 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1868 | return; |
| 1869 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1870 | m_errorMonitor->ExpectSuccess(); |
| 1871 | |
| 1872 | VkFence fence; |
| 1873 | VkFenceCreateInfo fence_create_info{}; |
| 1874 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1875 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1876 | |
| 1877 | VkSemaphore semaphore; |
| 1878 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1879 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1880 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1881 | &semaphore); |
| 1882 | |
| 1883 | VkCommandPool command_pool; |
| 1884 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1885 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1886 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1887 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1888 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1889 | &command_pool); |
| 1890 | |
| 1891 | VkCommandBuffer command_buffer[2]; |
| 1892 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1893 | command_buffer_allocate_info.sType = |
| 1894 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1895 | command_buffer_allocate_info.commandPool = command_pool; |
| 1896 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1897 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1898 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1899 | command_buffer); |
| 1900 | |
| 1901 | VkQueue queue = VK_NULL_HANDLE; |
| 1902 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1903 | 1, &queue); |
| 1904 | |
| 1905 | { |
| 1906 | VkCommandBufferBeginInfo begin_info{}; |
| 1907 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1908 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1909 | |
| 1910 | vkCmdPipelineBarrier(command_buffer[0], |
| 1911 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1912 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1913 | 0, nullptr, 0, nullptr); |
| 1914 | |
| 1915 | VkViewport viewport{}; |
| 1916 | viewport.maxDepth = 1.0f; |
| 1917 | viewport.minDepth = 0.0f; |
| 1918 | viewport.width = 512; |
| 1919 | viewport.height = 512; |
| 1920 | viewport.x = 0; |
| 1921 | viewport.y = 0; |
| 1922 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1923 | vkEndCommandBuffer(command_buffer[0]); |
| 1924 | } |
| 1925 | { |
| 1926 | VkCommandBufferBeginInfo begin_info{}; |
| 1927 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1928 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1929 | |
| 1930 | VkViewport viewport{}; |
| 1931 | viewport.maxDepth = 1.0f; |
| 1932 | viewport.minDepth = 0.0f; |
| 1933 | viewport.width = 512; |
| 1934 | viewport.height = 512; |
| 1935 | viewport.x = 0; |
| 1936 | viewport.y = 0; |
| 1937 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1938 | vkEndCommandBuffer(command_buffer[1]); |
| 1939 | } |
| 1940 | { |
| 1941 | VkSubmitInfo submit_info{}; |
| 1942 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1943 | submit_info.commandBufferCount = 1; |
| 1944 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1945 | submit_info.signalSemaphoreCount = 1; |
| 1946 | submit_info.pSignalSemaphores = &semaphore; |
| 1947 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1948 | } |
| 1949 | { |
| 1950 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1951 | VkSubmitInfo submit_info{}; |
| 1952 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1953 | submit_info.commandBufferCount = 1; |
| 1954 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1955 | submit_info.waitSemaphoreCount = 1; |
| 1956 | submit_info.pWaitSemaphores = &semaphore; |
| 1957 | submit_info.pWaitDstStageMask = flags; |
| 1958 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1959 | } |
| 1960 | |
| 1961 | vkQueueWaitIdle(m_device->m_queue); |
| 1962 | |
| 1963 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1964 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1965 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1966 | &command_buffer[0]); |
| 1967 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1968 | |
| 1969 | m_errorMonitor->VerifyNotFound(); |
| 1970 | } |
| 1971 | |
| 1972 | // This is a positive test. No errors should be generated. |
| 1973 | TEST_F(VkLayerTest, |
| 1974 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 1975 | |
| 1976 | TEST_DESCRIPTION( |
| 1977 | "Two command buffers, each in a separate QueueSubmit call " |
| 1978 | "submitted on separate queues, the second having a fence" |
| 1979 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 1980 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1981 | if ((m_device->queue_props.empty()) || |
| 1982 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1983 | return; |
| 1984 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1985 | m_errorMonitor->ExpectSuccess(); |
| 1986 | |
| 1987 | VkFence fence; |
| 1988 | VkFenceCreateInfo fence_create_info{}; |
| 1989 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1990 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1991 | |
| 1992 | VkSemaphore semaphore; |
| 1993 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1994 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1995 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1996 | &semaphore); |
| 1997 | |
| 1998 | VkCommandPool command_pool; |
| 1999 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2000 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2001 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2002 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2003 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2004 | &command_pool); |
| 2005 | |
| 2006 | VkCommandBuffer command_buffer[2]; |
| 2007 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2008 | command_buffer_allocate_info.sType = |
| 2009 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2010 | command_buffer_allocate_info.commandPool = command_pool; |
| 2011 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2012 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2013 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2014 | command_buffer); |
| 2015 | |
| 2016 | VkQueue queue = VK_NULL_HANDLE; |
| 2017 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2018 | 1, &queue); |
| 2019 | |
| 2020 | { |
| 2021 | VkCommandBufferBeginInfo begin_info{}; |
| 2022 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2023 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2024 | |
| 2025 | vkCmdPipelineBarrier(command_buffer[0], |
| 2026 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2027 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2028 | 0, nullptr, 0, nullptr); |
| 2029 | |
| 2030 | VkViewport viewport{}; |
| 2031 | viewport.maxDepth = 1.0f; |
| 2032 | viewport.minDepth = 0.0f; |
| 2033 | viewport.width = 512; |
| 2034 | viewport.height = 512; |
| 2035 | viewport.x = 0; |
| 2036 | viewport.y = 0; |
| 2037 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2038 | vkEndCommandBuffer(command_buffer[0]); |
| 2039 | } |
| 2040 | { |
| 2041 | VkCommandBufferBeginInfo begin_info{}; |
| 2042 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2043 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2044 | |
| 2045 | VkViewport viewport{}; |
| 2046 | viewport.maxDepth = 1.0f; |
| 2047 | viewport.minDepth = 0.0f; |
| 2048 | viewport.width = 512; |
| 2049 | viewport.height = 512; |
| 2050 | viewport.x = 0; |
| 2051 | viewport.y = 0; |
| 2052 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2053 | vkEndCommandBuffer(command_buffer[1]); |
| 2054 | } |
| 2055 | { |
| 2056 | VkSubmitInfo submit_info{}; |
| 2057 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2058 | submit_info.commandBufferCount = 1; |
| 2059 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2060 | submit_info.signalSemaphoreCount = 1; |
| 2061 | submit_info.pSignalSemaphores = &semaphore; |
| 2062 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2063 | } |
| 2064 | { |
| 2065 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2066 | VkSubmitInfo submit_info{}; |
| 2067 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2068 | submit_info.commandBufferCount = 1; |
| 2069 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2070 | submit_info.waitSemaphoreCount = 1; |
| 2071 | submit_info.pWaitSemaphores = &semaphore; |
| 2072 | submit_info.pWaitDstStageMask = flags; |
| 2073 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2074 | } |
| 2075 | |
| 2076 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2077 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2078 | |
| 2079 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2080 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2081 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2082 | &command_buffer[0]); |
| 2083 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2084 | |
| 2085 | m_errorMonitor->VerifyNotFound(); |
| 2086 | } |
| 2087 | |
| 2088 | // This is a positive test. No errors should be generated. |
| 2089 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2090 | |
| 2091 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2092 | "submitted on separate queues, the second having a fence, " |
| 2093 | "followed by a WaitForFences call."); |
| 2094 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2095 | if ((m_device->queue_props.empty()) || |
| 2096 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2097 | return; |
| 2098 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2099 | m_errorMonitor->ExpectSuccess(); |
| 2100 | |
| 2101 | VkFence fence; |
| 2102 | VkFenceCreateInfo fence_create_info{}; |
| 2103 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2104 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2105 | |
| 2106 | VkSemaphore semaphore; |
| 2107 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2108 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2109 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2110 | &semaphore); |
| 2111 | |
| 2112 | VkCommandPool command_pool; |
| 2113 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2114 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2115 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2116 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2117 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2118 | &command_pool); |
| 2119 | |
| 2120 | VkCommandBuffer command_buffer[2]; |
| 2121 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2122 | command_buffer_allocate_info.sType = |
| 2123 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2124 | command_buffer_allocate_info.commandPool = command_pool; |
| 2125 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2126 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2127 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2128 | command_buffer); |
| 2129 | |
| 2130 | VkQueue queue = VK_NULL_HANDLE; |
| 2131 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2132 | 1, &queue); |
| 2133 | |
| 2134 | |
| 2135 | { |
| 2136 | VkCommandBufferBeginInfo begin_info{}; |
| 2137 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2138 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2139 | |
| 2140 | vkCmdPipelineBarrier(command_buffer[0], |
| 2141 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2142 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2143 | 0, nullptr, 0, nullptr); |
| 2144 | |
| 2145 | VkViewport viewport{}; |
| 2146 | viewport.maxDepth = 1.0f; |
| 2147 | viewport.minDepth = 0.0f; |
| 2148 | viewport.width = 512; |
| 2149 | viewport.height = 512; |
| 2150 | viewport.x = 0; |
| 2151 | viewport.y = 0; |
| 2152 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2153 | vkEndCommandBuffer(command_buffer[0]); |
| 2154 | } |
| 2155 | { |
| 2156 | VkCommandBufferBeginInfo begin_info{}; |
| 2157 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2158 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2159 | |
| 2160 | VkViewport viewport{}; |
| 2161 | viewport.maxDepth = 1.0f; |
| 2162 | viewport.minDepth = 0.0f; |
| 2163 | viewport.width = 512; |
| 2164 | viewport.height = 512; |
| 2165 | viewport.x = 0; |
| 2166 | viewport.y = 0; |
| 2167 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2168 | vkEndCommandBuffer(command_buffer[1]); |
| 2169 | } |
| 2170 | { |
| 2171 | VkSubmitInfo submit_info{}; |
| 2172 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2173 | submit_info.commandBufferCount = 1; |
| 2174 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2175 | submit_info.signalSemaphoreCount = 1; |
| 2176 | submit_info.pSignalSemaphores = &semaphore; |
| 2177 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2178 | } |
| 2179 | { |
| 2180 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2181 | VkSubmitInfo submit_info{}; |
| 2182 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2183 | submit_info.commandBufferCount = 1; |
| 2184 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2185 | submit_info.waitSemaphoreCount = 1; |
| 2186 | submit_info.pWaitSemaphores = &semaphore; |
| 2187 | submit_info.pWaitDstStageMask = flags; |
| 2188 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2189 | } |
| 2190 | |
| 2191 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2192 | |
| 2193 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2194 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2195 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2196 | &command_buffer[0]); |
| 2197 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2198 | |
| 2199 | m_errorMonitor->VerifyNotFound(); |
| 2200 | } |
| 2201 | |
| 2202 | // This is a positive test. No errors should be generated. |
| 2203 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2204 | |
| 2205 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2206 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2207 | "second having a fence, " |
| 2208 | "followed by a WaitForFences call."); |
| 2209 | |
| 2210 | m_errorMonitor->ExpectSuccess(); |
| 2211 | |
| 2212 | VkFence fence; |
| 2213 | VkFenceCreateInfo fence_create_info{}; |
| 2214 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2215 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2216 | |
| 2217 | VkSemaphore semaphore; |
| 2218 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2219 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2220 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2221 | &semaphore); |
| 2222 | |
| 2223 | VkCommandPool command_pool; |
| 2224 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2225 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2226 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2227 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2228 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2229 | &command_pool); |
| 2230 | |
| 2231 | VkCommandBuffer command_buffer[2]; |
| 2232 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2233 | command_buffer_allocate_info.sType = |
| 2234 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2235 | command_buffer_allocate_info.commandPool = command_pool; |
| 2236 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2237 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2238 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2239 | command_buffer); |
| 2240 | |
| 2241 | { |
| 2242 | VkCommandBufferBeginInfo begin_info{}; |
| 2243 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2244 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2245 | |
| 2246 | vkCmdPipelineBarrier(command_buffer[0], |
| 2247 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2248 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2249 | 0, nullptr, 0, nullptr); |
| 2250 | |
| 2251 | VkViewport viewport{}; |
| 2252 | viewport.maxDepth = 1.0f; |
| 2253 | viewport.minDepth = 0.0f; |
| 2254 | viewport.width = 512; |
| 2255 | viewport.height = 512; |
| 2256 | viewport.x = 0; |
| 2257 | viewport.y = 0; |
| 2258 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2259 | vkEndCommandBuffer(command_buffer[0]); |
| 2260 | } |
| 2261 | { |
| 2262 | VkCommandBufferBeginInfo begin_info{}; |
| 2263 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2264 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2265 | |
| 2266 | VkViewport viewport{}; |
| 2267 | viewport.maxDepth = 1.0f; |
| 2268 | viewport.minDepth = 0.0f; |
| 2269 | viewport.width = 512; |
| 2270 | viewport.height = 512; |
| 2271 | viewport.x = 0; |
| 2272 | viewport.y = 0; |
| 2273 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2274 | vkEndCommandBuffer(command_buffer[1]); |
| 2275 | } |
| 2276 | { |
| 2277 | VkSubmitInfo submit_info{}; |
| 2278 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2279 | submit_info.commandBufferCount = 1; |
| 2280 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2281 | submit_info.signalSemaphoreCount = 1; |
| 2282 | submit_info.pSignalSemaphores = &semaphore; |
| 2283 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2284 | } |
| 2285 | { |
| 2286 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2287 | VkSubmitInfo submit_info{}; |
| 2288 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2289 | submit_info.commandBufferCount = 1; |
| 2290 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2291 | submit_info.waitSemaphoreCount = 1; |
| 2292 | submit_info.pWaitSemaphores = &semaphore; |
| 2293 | submit_info.pWaitDstStageMask = flags; |
| 2294 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2295 | } |
| 2296 | |
| 2297 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2298 | |
| 2299 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2300 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2301 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2302 | &command_buffer[0]); |
| 2303 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2304 | |
| 2305 | m_errorMonitor->VerifyNotFound(); |
| 2306 | } |
| 2307 | |
| 2308 | // This is a positive test. No errors should be generated. |
| 2309 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2310 | |
| 2311 | TEST_DESCRIPTION( |
| 2312 | "Two command buffers, each in a separate QueueSubmit call " |
| 2313 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2314 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2315 | |
| 2316 | m_errorMonitor->ExpectSuccess(); |
| 2317 | |
| 2318 | VkFence fence; |
| 2319 | VkFenceCreateInfo fence_create_info{}; |
| 2320 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2321 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2322 | |
| 2323 | VkCommandPool command_pool; |
| 2324 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2325 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2326 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2327 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2328 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2329 | &command_pool); |
| 2330 | |
| 2331 | VkCommandBuffer command_buffer[2]; |
| 2332 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2333 | command_buffer_allocate_info.sType = |
| 2334 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2335 | command_buffer_allocate_info.commandPool = command_pool; |
| 2336 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2337 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2338 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2339 | command_buffer); |
| 2340 | |
| 2341 | { |
| 2342 | VkCommandBufferBeginInfo begin_info{}; |
| 2343 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2344 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2345 | |
| 2346 | vkCmdPipelineBarrier(command_buffer[0], |
| 2347 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2348 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2349 | 0, nullptr, 0, nullptr); |
| 2350 | |
| 2351 | VkViewport viewport{}; |
| 2352 | viewport.maxDepth = 1.0f; |
| 2353 | viewport.minDepth = 0.0f; |
| 2354 | viewport.width = 512; |
| 2355 | viewport.height = 512; |
| 2356 | viewport.x = 0; |
| 2357 | viewport.y = 0; |
| 2358 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2359 | vkEndCommandBuffer(command_buffer[0]); |
| 2360 | } |
| 2361 | { |
| 2362 | VkCommandBufferBeginInfo begin_info{}; |
| 2363 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2364 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2365 | |
| 2366 | VkViewport viewport{}; |
| 2367 | viewport.maxDepth = 1.0f; |
| 2368 | viewport.minDepth = 0.0f; |
| 2369 | viewport.width = 512; |
| 2370 | viewport.height = 512; |
| 2371 | viewport.x = 0; |
| 2372 | viewport.y = 0; |
| 2373 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2374 | vkEndCommandBuffer(command_buffer[1]); |
| 2375 | } |
| 2376 | { |
| 2377 | VkSubmitInfo submit_info{}; |
| 2378 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2379 | submit_info.commandBufferCount = 1; |
| 2380 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2381 | submit_info.signalSemaphoreCount = 0; |
| 2382 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2383 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2384 | } |
| 2385 | { |
| 2386 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2387 | VkSubmitInfo submit_info{}; |
| 2388 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2389 | submit_info.commandBufferCount = 1; |
| 2390 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2391 | submit_info.waitSemaphoreCount = 0; |
| 2392 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2393 | submit_info.pWaitDstStageMask = flags; |
| 2394 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2395 | } |
| 2396 | |
| 2397 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2398 | |
| 2399 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2400 | |
| 2401 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2402 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2403 | &command_buffer[0]); |
| 2404 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2405 | |
| 2406 | m_errorMonitor->VerifyNotFound(); |
| 2407 | } |
| 2408 | |
| 2409 | // This is a positive test. No errors should be generated. |
| 2410 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2411 | |
| 2412 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2413 | "on the same queue, the second having a fence, followed " |
| 2414 | "by a WaitForFences call."); |
| 2415 | |
| 2416 | m_errorMonitor->ExpectSuccess(); |
| 2417 | |
| 2418 | VkFence fence; |
| 2419 | VkFenceCreateInfo fence_create_info{}; |
| 2420 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2421 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2422 | |
| 2423 | VkCommandPool command_pool; |
| 2424 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2425 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2426 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2427 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2428 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2429 | &command_pool); |
| 2430 | |
| 2431 | VkCommandBuffer command_buffer[2]; |
| 2432 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2433 | command_buffer_allocate_info.sType = |
| 2434 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2435 | command_buffer_allocate_info.commandPool = command_pool; |
| 2436 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2437 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2438 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2439 | command_buffer); |
| 2440 | |
| 2441 | { |
| 2442 | VkCommandBufferBeginInfo begin_info{}; |
| 2443 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2444 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2445 | |
| 2446 | vkCmdPipelineBarrier(command_buffer[0], |
| 2447 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2448 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2449 | 0, nullptr, 0, nullptr); |
| 2450 | |
| 2451 | VkViewport viewport{}; |
| 2452 | viewport.maxDepth = 1.0f; |
| 2453 | viewport.minDepth = 0.0f; |
| 2454 | viewport.width = 512; |
| 2455 | viewport.height = 512; |
| 2456 | viewport.x = 0; |
| 2457 | viewport.y = 0; |
| 2458 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2459 | vkEndCommandBuffer(command_buffer[0]); |
| 2460 | } |
| 2461 | { |
| 2462 | VkCommandBufferBeginInfo begin_info{}; |
| 2463 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2464 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2465 | |
| 2466 | VkViewport viewport{}; |
| 2467 | viewport.maxDepth = 1.0f; |
| 2468 | viewport.minDepth = 0.0f; |
| 2469 | viewport.width = 512; |
| 2470 | viewport.height = 512; |
| 2471 | viewport.x = 0; |
| 2472 | viewport.y = 0; |
| 2473 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2474 | vkEndCommandBuffer(command_buffer[1]); |
| 2475 | } |
| 2476 | { |
| 2477 | VkSubmitInfo submit_info{}; |
| 2478 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2479 | submit_info.commandBufferCount = 1; |
| 2480 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2481 | submit_info.signalSemaphoreCount = 0; |
| 2482 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2483 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2484 | } |
| 2485 | { |
| 2486 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2487 | VkSubmitInfo submit_info{}; |
| 2488 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2489 | submit_info.commandBufferCount = 1; |
| 2490 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2491 | submit_info.waitSemaphoreCount = 0; |
| 2492 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2493 | submit_info.pWaitDstStageMask = flags; |
| 2494 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2495 | } |
| 2496 | |
| 2497 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2498 | |
| 2499 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2500 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2501 | &command_buffer[0]); |
| 2502 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2503 | |
| 2504 | m_errorMonitor->VerifyNotFound(); |
| 2505 | } |
| 2506 | |
| 2507 | // This is a positive test. No errors should be generated. |
| 2508 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2509 | |
| 2510 | TEST_DESCRIPTION( |
| 2511 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2512 | "QueueSubmit call followed by a WaitForFences call."); |
| 2513 | |
| 2514 | m_errorMonitor->ExpectSuccess(); |
| 2515 | |
| 2516 | VkFence fence; |
| 2517 | VkFenceCreateInfo fence_create_info{}; |
| 2518 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2519 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2520 | |
| 2521 | VkSemaphore semaphore; |
| 2522 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2523 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2524 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2525 | &semaphore); |
| 2526 | |
| 2527 | VkCommandPool command_pool; |
| 2528 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2529 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2530 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2531 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2532 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2533 | &command_pool); |
| 2534 | |
| 2535 | VkCommandBuffer command_buffer[2]; |
| 2536 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2537 | command_buffer_allocate_info.sType = |
| 2538 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2539 | command_buffer_allocate_info.commandPool = command_pool; |
| 2540 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2541 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2542 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2543 | command_buffer); |
| 2544 | |
| 2545 | { |
| 2546 | VkCommandBufferBeginInfo begin_info{}; |
| 2547 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2548 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2549 | |
| 2550 | vkCmdPipelineBarrier(command_buffer[0], |
| 2551 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2552 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2553 | 0, nullptr, 0, nullptr); |
| 2554 | |
| 2555 | VkViewport viewport{}; |
| 2556 | viewport.maxDepth = 1.0f; |
| 2557 | viewport.minDepth = 0.0f; |
| 2558 | viewport.width = 512; |
| 2559 | viewport.height = 512; |
| 2560 | viewport.x = 0; |
| 2561 | viewport.y = 0; |
| 2562 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2563 | vkEndCommandBuffer(command_buffer[0]); |
| 2564 | } |
| 2565 | { |
| 2566 | VkCommandBufferBeginInfo begin_info{}; |
| 2567 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2568 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2569 | |
| 2570 | VkViewport viewport{}; |
| 2571 | viewport.maxDepth = 1.0f; |
| 2572 | viewport.minDepth = 0.0f; |
| 2573 | viewport.width = 512; |
| 2574 | viewport.height = 512; |
| 2575 | viewport.x = 0; |
| 2576 | viewport.y = 0; |
| 2577 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2578 | vkEndCommandBuffer(command_buffer[1]); |
| 2579 | } |
| 2580 | { |
| 2581 | VkSubmitInfo submit_info[2]; |
| 2582 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2583 | |
| 2584 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2585 | submit_info[0].pNext = NULL; |
| 2586 | submit_info[0].commandBufferCount = 1; |
| 2587 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2588 | submit_info[0].signalSemaphoreCount = 1; |
| 2589 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2590 | submit_info[0].waitSemaphoreCount = 0; |
| 2591 | submit_info[0].pWaitSemaphores = NULL; |
| 2592 | submit_info[0].pWaitDstStageMask = 0; |
| 2593 | |
| 2594 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2595 | submit_info[1].pNext = NULL; |
| 2596 | submit_info[1].commandBufferCount = 1; |
| 2597 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2598 | submit_info[1].waitSemaphoreCount = 1; |
| 2599 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2600 | submit_info[1].pWaitDstStageMask = flags; |
| 2601 | submit_info[1].signalSemaphoreCount = 0; |
| 2602 | submit_info[1].pSignalSemaphores = NULL; |
| 2603 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2604 | } |
| 2605 | |
| 2606 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2607 | |
| 2608 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2609 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2610 | &command_buffer[0]); |
| 2611 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2612 | |
| 2613 | m_errorMonitor->VerifyNotFound(); |
| 2614 | } |
| 2615 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2616 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2617 | TEST_DESCRIPTION( |
| 2618 | "Run a series of simple draw calls to validate all the different " |
| 2619 | "failure cases that can occur when dynamic state is required but not " |
| 2620 | "correctly bound." |
| 2621 | "Here are the different dynamic state cases verified by this test:\n" |
| 2622 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2623 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2624 | "Mask\n-Stencil Reference"); |
| 2625 | |
| 2626 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2627 | m_errorMonitor->SetDesiredFailureMsg( |
| 2628 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2629 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2630 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2631 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2632 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2633 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2634 | m_errorMonitor->SetDesiredFailureMsg( |
| 2635 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2636 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2637 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2638 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2639 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2640 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2641 | m_errorMonitor->SetDesiredFailureMsg( |
| 2642 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2643 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2644 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2645 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2646 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2647 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2648 | m_errorMonitor->SetDesiredFailureMsg( |
| 2649 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2650 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2651 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2652 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2653 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2654 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2655 | m_errorMonitor->SetDesiredFailureMsg( |
| 2656 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2657 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2658 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2659 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2660 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2661 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2662 | m_errorMonitor->SetDesiredFailureMsg( |
| 2663 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2664 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2665 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2666 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2667 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2668 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2669 | m_errorMonitor->SetDesiredFailureMsg( |
| 2670 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2671 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2672 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2673 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2674 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2675 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2676 | m_errorMonitor->SetDesiredFailureMsg( |
| 2677 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2678 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2679 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2680 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2681 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2682 | } |
| 2683 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2684 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2685 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2686 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2687 | m_errorMonitor->SetDesiredFailureMsg( |
| 2688 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2689 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2690 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2691 | |
| 2692 | VkFenceCreateInfo fenceInfo = {}; |
| 2693 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2694 | fenceInfo.pNext = NULL; |
| 2695 | fenceInfo.flags = 0; |
| 2696 | |
| 2697 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2698 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2699 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | // We luck out b/c by default the framework creates CB w/ the |
| 2702 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2703 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2704 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2705 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2706 | EndCommandBuffer(); |
| 2707 | |
| 2708 | testFence.init(*m_device, fenceInfo); |
| 2709 | |
| 2710 | // Bypass framework since it does the waits automatically |
| 2711 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2712 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2713 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2714 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2715 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2716 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2717 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2718 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2719 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2720 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2721 | submit_info.pSignalSemaphores = NULL; |
| 2722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2723 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2724 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2726 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2727 | // submitted once |
| 2728 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2729 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2730 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2731 | } |
| 2732 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2733 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2734 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2735 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2736 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2737 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2738 | "Unable to allocate 1 descriptors of " |
| 2739 | "type " |
| 2740 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2741 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2742 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2743 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2744 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2745 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2746 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2747 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2748 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2749 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2750 | |
| 2751 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2752 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2753 | ds_pool_ci.pNext = NULL; |
| 2754 | ds_pool_ci.flags = 0; |
| 2755 | ds_pool_ci.maxSets = 1; |
| 2756 | ds_pool_ci.poolSizeCount = 1; |
| 2757 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2758 | |
| 2759 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2760 | err = |
| 2761 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2762 | ASSERT_VK_SUCCESS(err); |
| 2763 | |
| 2764 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2765 | dsl_binding.binding = 0; |
| 2766 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2767 | dsl_binding.descriptorCount = 1; |
| 2768 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2769 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2770 | |
| 2771 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2772 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2773 | ds_layout_ci.pNext = NULL; |
| 2774 | ds_layout_ci.bindingCount = 1; |
| 2775 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2776 | |
| 2777 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2778 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2779 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2780 | ASSERT_VK_SUCCESS(err); |
| 2781 | |
| 2782 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2783 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2784 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2785 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2786 | alloc_info.descriptorPool = ds_pool; |
| 2787 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2788 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2789 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2790 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2791 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2792 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2793 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2794 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2795 | } |
| 2796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2797 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2798 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | m_errorMonitor->SetDesiredFailureMsg( |
| 2801 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2802 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2803 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2804 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2805 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2806 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2807 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2808 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2809 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2810 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2811 | |
| 2812 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2813 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2814 | ds_pool_ci.pNext = NULL; |
| 2815 | ds_pool_ci.maxSets = 1; |
| 2816 | ds_pool_ci.poolSizeCount = 1; |
| 2817 | ds_pool_ci.flags = 0; |
| 2818 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2819 | // app can only call vkResetDescriptorPool on this pool.; |
| 2820 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2821 | |
| 2822 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2823 | err = |
| 2824 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2825 | ASSERT_VK_SUCCESS(err); |
| 2826 | |
| 2827 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2828 | dsl_binding.binding = 0; |
| 2829 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2830 | dsl_binding.descriptorCount = 1; |
| 2831 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2832 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2833 | |
| 2834 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2835 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2836 | ds_layout_ci.pNext = NULL; |
| 2837 | ds_layout_ci.bindingCount = 1; |
| 2838 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2839 | |
| 2840 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2841 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2842 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2843 | ASSERT_VK_SUCCESS(err); |
| 2844 | |
| 2845 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2846 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2847 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2848 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2849 | alloc_info.descriptorPool = ds_pool; |
| 2850 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2851 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2852 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2853 | ASSERT_VK_SUCCESS(err); |
| 2854 | |
| 2855 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2856 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2857 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2858 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2859 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2860 | } |
| 2861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2862 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2863 | // Attempt to clear Descriptor Pool with bad object. |
| 2864 | // ObjectTracker should catch this. |
| 2865 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2866 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 2867 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 2868 | vkResetDescriptorPool(device(), badPool, 0); |
| 2869 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2870 | } |
| 2871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2872 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2873 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2874 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2875 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2876 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 2877 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 2878 | VkResult err; |
| 2879 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2880 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2881 | |
| 2882 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2883 | |
| 2884 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2885 | layout_bindings[0].binding = 0; |
| 2886 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2887 | layout_bindings[0].descriptorCount = 1; |
| 2888 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2889 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2890 | |
| 2891 | VkDescriptorSetLayout descriptor_set_layout; |
| 2892 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2893 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2894 | dslci.pNext = NULL; |
| 2895 | dslci.bindingCount = 1; |
| 2896 | dslci.pBindings = layout_bindings; |
| 2897 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2898 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2899 | |
| 2900 | VkPipelineLayout pipeline_layout; |
| 2901 | VkPipelineLayoutCreateInfo plci = {}; |
| 2902 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2903 | plci.pNext = NULL; |
| 2904 | plci.setLayoutCount = 1; |
| 2905 | plci.pSetLayouts = &descriptor_set_layout; |
| 2906 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2907 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2908 | |
| 2909 | BeginCommandBuffer(); |
| 2910 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2911 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 2912 | m_errorMonitor->VerifyFound(); |
| 2913 | EndCommandBuffer(); |
| 2914 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 2915 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2916 | } |
| 2917 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2918 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2919 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 2920 | // ObjectTracker should catch this. |
| 2921 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 2922 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2923 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 2924 | |
| 2925 | VkPipelineLayout pipeline_layout; |
| 2926 | VkPipelineLayoutCreateInfo plci = {}; |
| 2927 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2928 | plci.pNext = NULL; |
| 2929 | plci.setLayoutCount = 1; |
| 2930 | plci.pSetLayouts = &bad_layout; |
| 2931 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 2932 | |
| 2933 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2934 | } |
| 2935 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2936 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2937 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 2938 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2939 | // Create a valid cmd buffer |
| 2940 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2941 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 2942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2943 | "Invalid VkPipeline Object 0xbaad6001"); |
| 2944 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2945 | BeginCommandBuffer(); |
| 2946 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2947 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 2948 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 2949 | |
| 2950 | // Now issue a draw call with no pipeline bound |
| 2951 | m_errorMonitor->SetDesiredFailureMsg( |
| 2952 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2953 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2955 | BeginCommandBuffer(); |
| 2956 | Draw(1, 0, 0, 0); |
| 2957 | m_errorMonitor->VerifyFound(); |
| 2958 | // Finally same check once more but with Dispatch/Compute |
| 2959 | m_errorMonitor->SetDesiredFailureMsg( |
| 2960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2961 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2962 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2963 | BeginCommandBuffer(); |
| 2964 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 2965 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2966 | } |
| 2967 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2968 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 2969 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 2970 | // CommandBuffer |
| 2971 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2972 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2973 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2974 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2975 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2976 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2977 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2978 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2979 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2980 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2981 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2982 | |
| 2983 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2984 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2985 | ds_pool_ci.pNext = NULL; |
| 2986 | ds_pool_ci.maxSets = 1; |
| 2987 | ds_pool_ci.poolSizeCount = 1; |
| 2988 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2989 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2990 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2991 | err = |
| 2992 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2993 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2994 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2995 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2996 | dsl_binding.binding = 0; |
| 2997 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2998 | dsl_binding.descriptorCount = 1; |
| 2999 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3000 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3001 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3002 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3003 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3004 | ds_layout_ci.pNext = NULL; |
| 3005 | ds_layout_ci.bindingCount = 1; |
| 3006 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3007 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3008 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3009 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3010 | ASSERT_VK_SUCCESS(err); |
| 3011 | |
| 3012 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3013 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3014 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3015 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3016 | alloc_info.descriptorPool = ds_pool; |
| 3017 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3018 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3019 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3020 | ASSERT_VK_SUCCESS(err); |
| 3021 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3022 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3023 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3024 | pipeline_layout_ci.pNext = NULL; |
| 3025 | pipeline_layout_ci.setLayoutCount = 1; |
| 3026 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3027 | |
| 3028 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3029 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3030 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3031 | ASSERT_VK_SUCCESS(err); |
| 3032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3033 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3034 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3035 | // 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] | 3036 | // on more devices |
| 3037 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3038 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3039 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3040 | VkPipelineObj pipe(m_device); |
| 3041 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3042 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3043 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3044 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3045 | |
| 3046 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3047 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3048 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3049 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3050 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3051 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3052 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3053 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3054 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3055 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3056 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3057 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3058 | } |
| 3059 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3060 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3061 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3062 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3063 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3064 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3066 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3067 | |
| 3068 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3069 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3070 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3071 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3072 | |
| 3073 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3074 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3075 | ds_pool_ci.pNext = NULL; |
| 3076 | ds_pool_ci.maxSets = 1; |
| 3077 | ds_pool_ci.poolSizeCount = 1; |
| 3078 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3079 | |
| 3080 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3081 | err = |
| 3082 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3083 | ASSERT_VK_SUCCESS(err); |
| 3084 | |
| 3085 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3086 | dsl_binding.binding = 0; |
| 3087 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3088 | dsl_binding.descriptorCount = 1; |
| 3089 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3090 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3091 | |
| 3092 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3093 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3094 | ds_layout_ci.pNext = NULL; |
| 3095 | ds_layout_ci.bindingCount = 1; |
| 3096 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3097 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3098 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3099 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3100 | ASSERT_VK_SUCCESS(err); |
| 3101 | |
| 3102 | VkDescriptorSet descriptorSet; |
| 3103 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3104 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3105 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3106 | alloc_info.descriptorPool = ds_pool; |
| 3107 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3108 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3109 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3110 | ASSERT_VK_SUCCESS(err); |
| 3111 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3112 | VkBufferView view = |
| 3113 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3114 | VkWriteDescriptorSet descriptor_write; |
| 3115 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3116 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3117 | descriptor_write.dstSet = descriptorSet; |
| 3118 | descriptor_write.dstBinding = 0; |
| 3119 | descriptor_write.descriptorCount = 1; |
| 3120 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3121 | descriptor_write.pTexelBufferView = &view; |
| 3122 | |
| 3123 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3124 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3125 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3126 | |
| 3127 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3128 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3129 | } |
| 3130 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3131 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3132 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3133 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3134 | // 1. No dynamicOffset supplied |
| 3135 | // 2. Too many dynamicOffsets supplied |
| 3136 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3137 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3138 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3139 | " requires 1 dynamicOffsets, but only " |
| 3140 | "0 dynamicOffsets are left in " |
| 3141 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3142 | |
| 3143 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3144 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3145 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3146 | |
| 3147 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3148 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3149 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3150 | |
| 3151 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3152 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3153 | ds_pool_ci.pNext = NULL; |
| 3154 | ds_pool_ci.maxSets = 1; |
| 3155 | ds_pool_ci.poolSizeCount = 1; |
| 3156 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3157 | |
| 3158 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3159 | err = |
| 3160 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3161 | ASSERT_VK_SUCCESS(err); |
| 3162 | |
| 3163 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3164 | dsl_binding.binding = 0; |
| 3165 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3166 | dsl_binding.descriptorCount = 1; |
| 3167 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3168 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3169 | |
| 3170 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3171 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3172 | ds_layout_ci.pNext = NULL; |
| 3173 | ds_layout_ci.bindingCount = 1; |
| 3174 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3175 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3176 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3177 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3178 | ASSERT_VK_SUCCESS(err); |
| 3179 | |
| 3180 | VkDescriptorSet descriptorSet; |
| 3181 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3182 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3183 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3184 | alloc_info.descriptorPool = ds_pool; |
| 3185 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3186 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3187 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3188 | ASSERT_VK_SUCCESS(err); |
| 3189 | |
| 3190 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3191 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3192 | pipeline_layout_ci.pNext = NULL; |
| 3193 | pipeline_layout_ci.setLayoutCount = 1; |
| 3194 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3195 | |
| 3196 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3197 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3198 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3199 | ASSERT_VK_SUCCESS(err); |
| 3200 | |
| 3201 | // Create a buffer to update the descriptor with |
| 3202 | uint32_t qfi = 0; |
| 3203 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3204 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3205 | buffCI.size = 1024; |
| 3206 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3207 | buffCI.queueFamilyIndexCount = 1; |
| 3208 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3209 | |
| 3210 | VkBuffer dyub; |
| 3211 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3212 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3213 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3214 | // error |
| 3215 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3216 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3217 | mem_alloc.pNext = NULL; |
| 3218 | mem_alloc.allocationSize = 1024; |
| 3219 | mem_alloc.memoryTypeIndex = 1; |
| 3220 | VkDeviceMemory mem; |
| 3221 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3222 | ASSERT_VK_SUCCESS(err); |
| 3223 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3224 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3225 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3226 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3227 | buffInfo.buffer = dyub; |
| 3228 | buffInfo.offset = 0; |
| 3229 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3230 | |
| 3231 | VkWriteDescriptorSet descriptor_write; |
| 3232 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3233 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3234 | descriptor_write.dstSet = descriptorSet; |
| 3235 | descriptor_write.dstBinding = 0; |
| 3236 | descriptor_write.descriptorCount = 1; |
| 3237 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3238 | descriptor_write.pBufferInfo = &buffInfo; |
| 3239 | |
| 3240 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3241 | |
| 3242 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3243 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3244 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3245 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3246 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3247 | uint32_t pDynOff[2] = {512, 756}; |
| 3248 | // 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] | 3249 | m_errorMonitor->SetDesiredFailureMsg( |
| 3250 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3251 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3252 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3253 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3254 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3255 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3256 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3257 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3258 | " dynamic offset 512 combined with " |
| 3259 | "offset 0 and range 1024 that " |
| 3260 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3261 | // Create PSO to be used for draw-time errors below |
| 3262 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3263 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3264 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3265 | "out gl_PerVertex { \n" |
| 3266 | " vec4 gl_Position;\n" |
| 3267 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3268 | "void main(){\n" |
| 3269 | " gl_Position = vec4(1);\n" |
| 3270 | "}\n"; |
| 3271 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3272 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3273 | "\n" |
| 3274 | "layout(location=0) out vec4 x;\n" |
| 3275 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3276 | "void main(){\n" |
| 3277 | " x = vec4(bar.y);\n" |
| 3278 | "}\n"; |
| 3279 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3280 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3281 | VkPipelineObj pipe(m_device); |
| 3282 | pipe.AddShader(&vs); |
| 3283 | pipe.AddShader(&fs); |
| 3284 | pipe.AddColorAttachment(); |
| 3285 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3287 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3288 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3289 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3290 | // /w range 1024 & size 1024 |
| 3291 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3292 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3293 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3294 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3295 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3296 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3297 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3298 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3299 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3300 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3301 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3302 | } |
| 3303 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3304 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3305 | // Hit push constant error cases: |
| 3306 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3307 | // 2. Incorrectly set push constant size to 0 |
| 3308 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3309 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3310 | VkResult err; |
| 3311 | m_errorMonitor->SetDesiredFailureMsg( |
| 3312 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3313 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3314 | |
| 3315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3316 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3317 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3318 | |
| 3319 | VkPushConstantRange pc_range = {}; |
| 3320 | pc_range.size = 0xFFFFFFFFu; |
| 3321 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3322 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3323 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3324 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3325 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3326 | |
| 3327 | VkPipelineLayout pipeline_layout; |
| 3328 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3329 | &pipeline_layout); |
| 3330 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3331 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3332 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3333 | pc_range.size = 0; |
| 3334 | m_errorMonitor->SetDesiredFailureMsg( |
| 3335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3336 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3337 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3338 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3339 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3340 | pc_range.size = 1; |
| 3341 | m_errorMonitor->SetDesiredFailureMsg( |
| 3342 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3343 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3344 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3345 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3346 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3347 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3348 | m_errorMonitor->SetDesiredFailureMsg( |
| 3349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3350 | "vkCmdPushConstants() call has push constants with offset "); |
| 3351 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3352 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3353 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3354 | &pipeline_layout); |
| 3355 | ASSERT_VK_SUCCESS(err); |
| 3356 | BeginCommandBuffer(); |
| 3357 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3358 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3359 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3360 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3361 | } |
| 3362 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3363 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3364 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3365 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3366 | |
| 3367 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3368 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3369 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3370 | |
| 3371 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3372 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3373 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3374 | ds_type_count[0].descriptorCount = 10; |
| 3375 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3376 | ds_type_count[1].descriptorCount = 2; |
| 3377 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3378 | ds_type_count[2].descriptorCount = 2; |
| 3379 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3380 | ds_type_count[3].descriptorCount = 5; |
| 3381 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3382 | // type |
| 3383 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3384 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3385 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3386 | |
| 3387 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3388 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3389 | ds_pool_ci.pNext = NULL; |
| 3390 | ds_pool_ci.maxSets = 5; |
| 3391 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3392 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3393 | |
| 3394 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3395 | err = |
| 3396 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3397 | ASSERT_VK_SUCCESS(err); |
| 3398 | |
| 3399 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3400 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3401 | dsl_binding[0].binding = 0; |
| 3402 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3403 | dsl_binding[0].descriptorCount = 5; |
| 3404 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3405 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3406 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3407 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3408 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3409 | dsl_fs_stage_only.binding = 0; |
| 3410 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3411 | dsl_fs_stage_only.descriptorCount = 5; |
| 3412 | dsl_fs_stage_only.stageFlags = |
| 3413 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3414 | // bind time |
| 3415 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3416 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3418 | ds_layout_ci.pNext = NULL; |
| 3419 | ds_layout_ci.bindingCount = 1; |
| 3420 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3421 | static const uint32_t NUM_LAYOUTS = 4; |
| 3422 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3423 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3424 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3425 | // layout for error case |
| 3426 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3427 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3428 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3429 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3430 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3431 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3432 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3433 | dsl_binding[0].binding = 0; |
| 3434 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3435 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3436 | dsl_binding[1].binding = 1; |
| 3437 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3438 | dsl_binding[1].descriptorCount = 2; |
| 3439 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3440 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3441 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3442 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3443 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3444 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3445 | ASSERT_VK_SUCCESS(err); |
| 3446 | dsl_binding[0].binding = 0; |
| 3447 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3448 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3449 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3450 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3451 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3452 | ASSERT_VK_SUCCESS(err); |
| 3453 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3454 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3455 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3456 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3457 | ASSERT_VK_SUCCESS(err); |
| 3458 | |
| 3459 | static const uint32_t NUM_SETS = 4; |
| 3460 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3461 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3462 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3463 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3464 | alloc_info.descriptorPool = ds_pool; |
| 3465 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3467 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3468 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3469 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3470 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3471 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3472 | err = |
| 3473 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3474 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3475 | |
| 3476 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3477 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3478 | pipeline_layout_ci.pNext = NULL; |
| 3479 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3480 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3481 | |
| 3482 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3483 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3484 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3485 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3486 | // Create pipelineLayout with only one setLayout |
| 3487 | pipeline_layout_ci.setLayoutCount = 1; |
| 3488 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3489 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3490 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3491 | ASSERT_VK_SUCCESS(err); |
| 3492 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3493 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3494 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3495 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3496 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3497 | ASSERT_VK_SUCCESS(err); |
| 3498 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3499 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3500 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3501 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3502 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3503 | ASSERT_VK_SUCCESS(err); |
| 3504 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3505 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3506 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3507 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3508 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3509 | ASSERT_VK_SUCCESS(err); |
| 3510 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3511 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3512 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3513 | pl_bad_s0[1] = ds_layout[1]; |
| 3514 | pipeline_layout_ci.setLayoutCount = 2; |
| 3515 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3516 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3517 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3518 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3519 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3520 | |
| 3521 | // Create a buffer to update the descriptor with |
| 3522 | uint32_t qfi = 0; |
| 3523 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3524 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3525 | buffCI.size = 1024; |
| 3526 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3527 | buffCI.queueFamilyIndexCount = 1; |
| 3528 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3529 | |
| 3530 | VkBuffer dyub; |
| 3531 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3532 | ASSERT_VK_SUCCESS(err); |
| 3533 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3534 | static const uint32_t NUM_BUFFS = 5; |
| 3535 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3536 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3537 | buffInfo[i].buffer = dyub; |
| 3538 | buffInfo[i].offset = 0; |
| 3539 | buffInfo[i].range = 1024; |
| 3540 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3541 | VkImage image; |
| 3542 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3543 | const int32_t tex_width = 32; |
| 3544 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3545 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3546 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3547 | image_create_info.pNext = NULL; |
| 3548 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3549 | image_create_info.format = tex_format; |
| 3550 | image_create_info.extent.width = tex_width; |
| 3551 | image_create_info.extent.height = tex_height; |
| 3552 | image_create_info.extent.depth = 1; |
| 3553 | image_create_info.mipLevels = 1; |
| 3554 | image_create_info.arrayLayers = 1; |
| 3555 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3556 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3557 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3558 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3559 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3560 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3562 | VkMemoryRequirements memReqs; |
| 3563 | VkDeviceMemory imageMem; |
| 3564 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3565 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3566 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3567 | memAlloc.pNext = NULL; |
| 3568 | memAlloc.allocationSize = 0; |
| 3569 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3570 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3571 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3572 | pass = |
| 3573 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3574 | ASSERT_TRUE(pass); |
| 3575 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3576 | ASSERT_VK_SUCCESS(err); |
| 3577 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3578 | ASSERT_VK_SUCCESS(err); |
| 3579 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3580 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3581 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3582 | image_view_create_info.image = image; |
| 3583 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3584 | image_view_create_info.format = tex_format; |
| 3585 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3586 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3587 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3588 | image_view_create_info.subresourceRange.aspectMask = |
| 3589 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3590 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3591 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3592 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3593 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3594 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3595 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3596 | imageInfo[0].imageView = view; |
| 3597 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3598 | imageInfo[1].imageView = view; |
| 3599 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3600 | imageInfo[2].imageView = view; |
| 3601 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3602 | imageInfo[3].imageView = view; |
| 3603 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3604 | |
| 3605 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3606 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3607 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3608 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3609 | descriptor_write[0].dstBinding = 0; |
| 3610 | descriptor_write[0].descriptorCount = 5; |
| 3611 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3612 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3613 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3614 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3615 | descriptor_write[1].dstBinding = 0; |
| 3616 | descriptor_write[1].descriptorCount = 2; |
| 3617 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3618 | descriptor_write[1].pImageInfo = imageInfo; |
| 3619 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3620 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3621 | descriptor_write[2].dstBinding = 1; |
| 3622 | descriptor_write[2].descriptorCount = 2; |
| 3623 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3624 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3625 | |
| 3626 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3627 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3628 | // Create PSO to be used for draw-time errors below |
| 3629 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3630 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3631 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3632 | "out gl_PerVertex {\n" |
| 3633 | " vec4 gl_Position;\n" |
| 3634 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3635 | "void main(){\n" |
| 3636 | " gl_Position = vec4(1);\n" |
| 3637 | "}\n"; |
| 3638 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3639 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3640 | "\n" |
| 3641 | "layout(location=0) out vec4 x;\n" |
| 3642 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3643 | "void main(){\n" |
| 3644 | " x = vec4(bar.y);\n" |
| 3645 | "}\n"; |
| 3646 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3647 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3648 | VkPipelineObj pipe(m_device); |
| 3649 | pipe.AddShader(&vs); |
| 3650 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3651 | pipe.AddColorAttachment(); |
| 3652 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3653 | |
| 3654 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3656 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3657 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3658 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3659 | // of PSO |
| 3660 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3661 | // cmd_pipeline.c |
| 3662 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3663 | // cmd_bind_graphics_pipeline() |
| 3664 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3665 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3666 | // First cause various verify_layout_compatibility() fails |
| 3667 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3668 | // verify_set_layout_compatibility fail cases: |
| 3669 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3670 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3671 | " due to: invalid VkPipelineLayout "); |
| 3672 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3673 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3674 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3675 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3676 | m_errorMonitor->VerifyFound(); |
| 3677 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3678 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3679 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3680 | " attempting to bind set to index 1"); |
| 3681 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3682 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3683 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3684 | m_errorMonitor->VerifyFound(); |
| 3685 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3686 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3687 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3688 | // descriptors |
| 3689 | m_errorMonitor->SetDesiredFailureMsg( |
| 3690 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3691 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3692 | vkCmdBindDescriptorSets( |
| 3693 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3694 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3695 | m_errorMonitor->VerifyFound(); |
| 3696 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3697 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3698 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3699 | m_errorMonitor->SetDesiredFailureMsg( |
| 3700 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3701 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3702 | vkCmdBindDescriptorSets( |
| 3703 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3704 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3705 | m_errorMonitor->VerifyFound(); |
| 3706 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3707 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3708 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3709 | m_errorMonitor->SetDesiredFailureMsg( |
| 3710 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3711 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3712 | vkCmdBindDescriptorSets( |
| 3713 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3714 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3715 | m_errorMonitor->VerifyFound(); |
| 3716 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3717 | // Cause INFO messages due to disturbing previously bound Sets |
| 3718 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3719 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3720 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3721 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3722 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3723 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3724 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3725 | " previously bound as set #0 was disturbed "); |
| 3726 | vkCmdBindDescriptorSets( |
| 3727 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3728 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3729 | m_errorMonitor->VerifyFound(); |
| 3730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3731 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3732 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3733 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3734 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3735 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3736 | " newly bound as set #0 so set #1 and " |
| 3737 | "any subsequent sets were disturbed "); |
| 3738 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3739 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3740 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3741 | m_errorMonitor->VerifyFound(); |
| 3742 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3743 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3744 | // 1. Error due to not binding required set (we actually use same code as |
| 3745 | // above to disturb set0) |
| 3746 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3747 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3748 | 2, &descriptorSet[0], 0, NULL); |
| 3749 | vkCmdBindDescriptorSets( |
| 3750 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3751 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3752 | m_errorMonitor->SetDesiredFailureMsg( |
| 3753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3754 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3755 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3756 | m_errorMonitor->VerifyFound(); |
| 3757 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3758 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3759 | // 2. Error due to bound set not being compatible with PSO's |
| 3760 | // VkPipelineLayout (diff stageFlags in this case) |
| 3761 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3762 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3763 | 2, &descriptorSet[0], 0, NULL); |
| 3764 | m_errorMonitor->SetDesiredFailureMsg( |
| 3765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3766 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3767 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3768 | m_errorMonitor->VerifyFound(); |
| 3769 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3770 | // Remaining clean-up |
| 3771 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3772 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3773 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3774 | } |
| 3775 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 3776 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 3777 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3778 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3779 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3780 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3781 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3782 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3783 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3784 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3785 | m_errorMonitor->SetDesiredFailureMsg( |
| 3786 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3787 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3788 | |
| 3789 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3790 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3791 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3792 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3793 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3794 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3795 | } |
| 3796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3797 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3798 | VkResult err; |
| 3799 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3801 | m_errorMonitor->SetDesiredFailureMsg( |
| 3802 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3803 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3804 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3805 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3806 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3807 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3808 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3809 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3810 | cmd.commandPool = m_commandPool; |
| 3811 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3812 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3813 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3814 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3815 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3816 | |
| 3817 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3818 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3819 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3820 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3821 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3822 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3823 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3824 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3825 | |
| 3826 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3827 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3828 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3829 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3830 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3831 | } |
| 3832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3834 | // Cause error due to Begin while recording CB |
| 3835 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3836 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3837 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3838 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3839 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3840 | |
| 3841 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3842 | |
| 3843 | // Calls AllocateCommandBuffers |
| 3844 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3845 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3846 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3847 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3848 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3849 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3850 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3851 | cmd_buf_info.pNext = NULL; |
| 3852 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3853 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3854 | |
| 3855 | // Begin CB to transition to recording state |
| 3856 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3857 | // Can't re-begin. This should trigger error |
| 3858 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3859 | m_errorMonitor->VerifyFound(); |
| 3860 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3862 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3863 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3864 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3865 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3866 | m_errorMonitor->VerifyFound(); |
| 3867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3868 | m_errorMonitor->SetDesiredFailureMsg( |
| 3869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3870 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3871 | // Transition CB to RECORDED state |
| 3872 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3873 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3874 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3875 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3876 | } |
| 3877 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3878 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3879 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3880 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3882 | m_errorMonitor->SetDesiredFailureMsg( |
| 3883 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3884 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3885 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3887 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3888 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3889 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3890 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3891 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3892 | |
| 3893 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3894 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3895 | ds_pool_ci.pNext = NULL; |
| 3896 | ds_pool_ci.maxSets = 1; |
| 3897 | ds_pool_ci.poolSizeCount = 1; |
| 3898 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3899 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3900 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3901 | err = |
| 3902 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3903 | ASSERT_VK_SUCCESS(err); |
| 3904 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3905 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3906 | dsl_binding.binding = 0; |
| 3907 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3908 | dsl_binding.descriptorCount = 1; |
| 3909 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3910 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3911 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3912 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3913 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3914 | ds_layout_ci.pNext = NULL; |
| 3915 | ds_layout_ci.bindingCount = 1; |
| 3916 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3917 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3918 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3919 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3920 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3921 | ASSERT_VK_SUCCESS(err); |
| 3922 | |
| 3923 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3924 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3925 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3926 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3927 | alloc_info.descriptorPool = ds_pool; |
| 3928 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3929 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3930 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3931 | ASSERT_VK_SUCCESS(err); |
| 3932 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3933 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3934 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3935 | pipeline_layout_ci.setLayoutCount = 1; |
| 3936 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3937 | |
| 3938 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3939 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3940 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3941 | ASSERT_VK_SUCCESS(err); |
| 3942 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3943 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3944 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3945 | |
| 3946 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3947 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3948 | vp_state_ci.scissorCount = 1; |
| 3949 | vp_state_ci.pScissors = ≻ |
| 3950 | vp_state_ci.viewportCount = 1; |
| 3951 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3952 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3953 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3954 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3955 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3956 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3957 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3958 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3959 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3960 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3961 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3962 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3963 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3964 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3965 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3966 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3967 | gp_ci.layout = pipeline_layout; |
| 3968 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3969 | |
| 3970 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3971 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3972 | pc_ci.initialDataSize = 0; |
| 3973 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3974 | |
| 3975 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3976 | VkPipelineCache pipelineCache; |
| 3977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3978 | err = |
| 3979 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3980 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3981 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3982 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3983 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3984 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3985 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3986 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3987 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3988 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3989 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3990 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3991 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 3992 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 3993 | { |
| 3994 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3995 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3996 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 3999 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4000 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4001 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4003 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4004 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4005 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4006 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4007 | |
| 4008 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4009 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4010 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4011 | ds_pool_ci.poolSizeCount = 1; |
| 4012 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4013 | |
| 4014 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | err = vkCreateDescriptorPool(m_device->device(), |
| 4016 | 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] | 4017 | ASSERT_VK_SUCCESS(err); |
| 4018 | |
| 4019 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4020 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4021 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4022 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4023 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4024 | dsl_binding.pImmutableSamplers = NULL; |
| 4025 | |
| 4026 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4027 | ds_layout_ci.sType = |
| 4028 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4029 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4030 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4031 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4032 | |
| 4033 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4035 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4036 | ASSERT_VK_SUCCESS(err); |
| 4037 | |
| 4038 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4039 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4040 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4041 | ASSERT_VK_SUCCESS(err); |
| 4042 | |
| 4043 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4044 | pipeline_layout_ci.sType = |
| 4045 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4046 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4047 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4048 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4049 | |
| 4050 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4051 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4052 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4053 | ASSERT_VK_SUCCESS(err); |
| 4054 | |
| 4055 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4056 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4058 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4059 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4060 | // 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] | 4061 | VkShaderObj |
| 4062 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4063 | this); |
| 4064 | VkShaderObj |
| 4065 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4066 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4068 | shaderStages[0].sType = |
| 4069 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4070 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4071 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4072 | shaderStages[1].sType = |
| 4073 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4074 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4075 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4076 | shaderStages[2].sType = |
| 4077 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4078 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4079 | shaderStages[2].shader = te.handle(); |
| 4080 | |
| 4081 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4082 | iaCI.sType = |
| 4083 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4084 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4085 | |
| 4086 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4087 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4088 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4089 | |
| 4090 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4091 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4092 | gp_ci.pNext = NULL; |
| 4093 | gp_ci.stageCount = 3; |
| 4094 | gp_ci.pStages = shaderStages; |
| 4095 | gp_ci.pVertexInputState = NULL; |
| 4096 | gp_ci.pInputAssemblyState = &iaCI; |
| 4097 | gp_ci.pTessellationState = &tsCI; |
| 4098 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4099 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4100 | gp_ci.pMultisampleState = NULL; |
| 4101 | gp_ci.pDepthStencilState = NULL; |
| 4102 | gp_ci.pColorBlendState = NULL; |
| 4103 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4104 | gp_ci.layout = pipeline_layout; |
| 4105 | gp_ci.renderPass = renderPass(); |
| 4106 | |
| 4107 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4108 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4109 | pc_ci.pNext = NULL; |
| 4110 | pc_ci.initialSize = 0; |
| 4111 | pc_ci.initialData = 0; |
| 4112 | pc_ci.maxSize = 0; |
| 4113 | |
| 4114 | VkPipeline pipeline; |
| 4115 | VkPipelineCache pipelineCache; |
| 4116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4118 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4119 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4120 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4121 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4122 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4123 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4124 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4125 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4126 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4127 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4128 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4129 | } |
| 4130 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4131 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4132 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4134 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4135 | m_errorMonitor->SetDesiredFailureMsg( |
| 4136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4137 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4138 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4139 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4140 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4141 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4142 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4143 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4144 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4145 | |
| 4146 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4147 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4148 | ds_pool_ci.maxSets = 1; |
| 4149 | ds_pool_ci.poolSizeCount = 1; |
| 4150 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4151 | |
| 4152 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4153 | err = |
| 4154 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4155 | ASSERT_VK_SUCCESS(err); |
| 4156 | |
| 4157 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4158 | dsl_binding.binding = 0; |
| 4159 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4160 | dsl_binding.descriptorCount = 1; |
| 4161 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4162 | |
| 4163 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4164 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4165 | ds_layout_ci.bindingCount = 1; |
| 4166 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4167 | |
| 4168 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4169 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4170 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4171 | ASSERT_VK_SUCCESS(err); |
| 4172 | |
| 4173 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4174 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4175 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4176 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4177 | alloc_info.descriptorPool = ds_pool; |
| 4178 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4179 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4180 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4181 | ASSERT_VK_SUCCESS(err); |
| 4182 | |
| 4183 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4184 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4185 | pipeline_layout_ci.setLayoutCount = 1; |
| 4186 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4187 | |
| 4188 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4189 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4190 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4191 | ASSERT_VK_SUCCESS(err); |
| 4192 | |
| 4193 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4194 | |
| 4195 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4196 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4197 | vp_state_ci.scissorCount = 0; |
| 4198 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4199 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4200 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4201 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4202 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4203 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4204 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4205 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4206 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4207 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4208 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4209 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4210 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4211 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4212 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4213 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4214 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4215 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4216 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4217 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4218 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4219 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4220 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4221 | |
| 4222 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4223 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4224 | gp_ci.stageCount = 2; |
| 4225 | gp_ci.pStages = shaderStages; |
| 4226 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4227 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4228 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4229 | gp_ci.layout = pipeline_layout; |
| 4230 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4231 | |
| 4232 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4233 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4234 | |
| 4235 | VkPipeline pipeline; |
| 4236 | VkPipelineCache pipelineCache; |
| 4237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4238 | err = |
| 4239 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4240 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4242 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4243 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4244 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4245 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4246 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4247 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4248 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4249 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4250 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4251 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4252 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4253 | // 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] | 4254 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4255 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4256 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4257 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4258 | m_errorMonitor->SetDesiredFailureMsg( |
| 4259 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4260 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4261 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4262 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4263 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4264 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4265 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4266 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4267 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4268 | |
| 4269 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4270 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4271 | ds_pool_ci.maxSets = 1; |
| 4272 | ds_pool_ci.poolSizeCount = 1; |
| 4273 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4274 | |
| 4275 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4276 | err = |
| 4277 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4278 | ASSERT_VK_SUCCESS(err); |
| 4279 | |
| 4280 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4281 | dsl_binding.binding = 0; |
| 4282 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4283 | dsl_binding.descriptorCount = 1; |
| 4284 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4285 | |
| 4286 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4287 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4288 | ds_layout_ci.bindingCount = 1; |
| 4289 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4290 | |
| 4291 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4292 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4293 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4294 | ASSERT_VK_SUCCESS(err); |
| 4295 | |
| 4296 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4297 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4298 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4299 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4300 | alloc_info.descriptorPool = ds_pool; |
| 4301 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4302 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4303 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4304 | ASSERT_VK_SUCCESS(err); |
| 4305 | |
| 4306 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4307 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4308 | pipeline_layout_ci.setLayoutCount = 1; |
| 4309 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4310 | |
| 4311 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4312 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4313 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4314 | ASSERT_VK_SUCCESS(err); |
| 4315 | |
| 4316 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4317 | // Set scissor as dynamic to avoid second error |
| 4318 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4319 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4320 | dyn_state_ci.dynamicStateCount = 1; |
| 4321 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4322 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4323 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4324 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4326 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4327 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4328 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4329 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4330 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4331 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4332 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4333 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4334 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4335 | |
| 4336 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4337 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4338 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4339 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4340 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4341 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4342 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4343 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4344 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4345 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4346 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4347 | gp_ci.stageCount = 2; |
| 4348 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4349 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4350 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4351 | // should cause validation error |
| 4352 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4353 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4354 | gp_ci.layout = pipeline_layout; |
| 4355 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4356 | |
| 4357 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4358 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4359 | |
| 4360 | VkPipeline pipeline; |
| 4361 | VkPipelineCache pipelineCache; |
| 4362 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4363 | err = |
| 4364 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4365 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4366 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4367 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4368 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4369 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4370 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4371 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4372 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4373 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4374 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4375 | } |
| 4376 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4377 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4378 | // count |
| 4379 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4380 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4382 | m_errorMonitor->SetDesiredFailureMsg( |
| 4383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4384 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4385 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4387 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4388 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4389 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4391 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4392 | |
| 4393 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4394 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4395 | ds_pool_ci.maxSets = 1; |
| 4396 | ds_pool_ci.poolSizeCount = 1; |
| 4397 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4398 | |
| 4399 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4400 | err = |
| 4401 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4402 | ASSERT_VK_SUCCESS(err); |
| 4403 | |
| 4404 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4405 | dsl_binding.binding = 0; |
| 4406 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4407 | dsl_binding.descriptorCount = 1; |
| 4408 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4409 | |
| 4410 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4411 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4412 | ds_layout_ci.bindingCount = 1; |
| 4413 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4414 | |
| 4415 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4416 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4417 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4418 | ASSERT_VK_SUCCESS(err); |
| 4419 | |
| 4420 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4421 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4422 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4423 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4424 | alloc_info.descriptorPool = ds_pool; |
| 4425 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4426 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4427 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4428 | ASSERT_VK_SUCCESS(err); |
| 4429 | |
| 4430 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4432 | pipeline_layout_ci.setLayoutCount = 1; |
| 4433 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4434 | |
| 4435 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4436 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4437 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4438 | ASSERT_VK_SUCCESS(err); |
| 4439 | |
| 4440 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4441 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4442 | vp_state_ci.viewportCount = 1; |
| 4443 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4444 | vp_state_ci.scissorCount = 1; |
| 4445 | vp_state_ci.pScissors = |
| 4446 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4447 | |
| 4448 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4449 | // Set scissor as dynamic to avoid that error |
| 4450 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4451 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4452 | dyn_state_ci.dynamicStateCount = 1; |
| 4453 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4454 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4455 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4456 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4458 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4459 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4460 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4461 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4462 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4463 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4464 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4465 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4466 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4467 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4468 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4469 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4470 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4471 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4472 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4473 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4474 | |
| 4475 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4476 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4477 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4478 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4479 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4480 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4481 | rs_ci.pNext = nullptr; |
| 4482 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4483 | VkPipelineColorBlendAttachmentState att = {}; |
| 4484 | att.blendEnable = VK_FALSE; |
| 4485 | att.colorWriteMask = 0xf; |
| 4486 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4487 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4488 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4489 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4490 | cb_ci.attachmentCount = 1; |
| 4491 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4492 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4493 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4495 | gp_ci.stageCount = 2; |
| 4496 | gp_ci.pStages = shaderStages; |
| 4497 | gp_ci.pVertexInputState = &vi_ci; |
| 4498 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4499 | gp_ci.pViewportState = &vp_state_ci; |
| 4500 | gp_ci.pRasterizationState = &rs_ci; |
| 4501 | gp_ci.pColorBlendState = &cb_ci; |
| 4502 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4503 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4504 | gp_ci.layout = pipeline_layout; |
| 4505 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4506 | |
| 4507 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4508 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4509 | |
| 4510 | VkPipeline pipeline; |
| 4511 | VkPipelineCache pipelineCache; |
| 4512 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4513 | err = |
| 4514 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4515 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4516 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4517 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4518 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4519 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4520 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4521 | // 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] | 4522 | // First need to successfully create the PSO from above by setting |
| 4523 | // pViewports |
| 4524 | m_errorMonitor->SetDesiredFailureMsg( |
| 4525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4526 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4527 | "scissorCount is 1. These counts must match."); |
| 4528 | |
| 4529 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4530 | vp_state_ci.pViewports = &vp; |
| 4531 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4532 | &gp_ci, NULL, &pipeline); |
| 4533 | ASSERT_VK_SUCCESS(err); |
| 4534 | BeginCommandBuffer(); |
| 4535 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4536 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4537 | VkRect2D scissors[2] = {}; // don't care about data |
| 4538 | // Count of 2 doesn't match PSO count of 1 |
| 4539 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4540 | Draw(1, 0, 0, 0); |
| 4541 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4542 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4543 | |
| 4544 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4545 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4546 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4547 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4548 | } |
| 4549 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4550 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4551 | // viewportCount |
| 4552 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4553 | VkResult err; |
| 4554 | |
| 4555 | m_errorMonitor->SetDesiredFailureMsg( |
| 4556 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4557 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4558 | |
| 4559 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4560 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4561 | |
| 4562 | VkDescriptorPoolSize ds_type_count = {}; |
| 4563 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4564 | ds_type_count.descriptorCount = 1; |
| 4565 | |
| 4566 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4567 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4568 | ds_pool_ci.maxSets = 1; |
| 4569 | ds_pool_ci.poolSizeCount = 1; |
| 4570 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4571 | |
| 4572 | VkDescriptorPool ds_pool; |
| 4573 | err = |
| 4574 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4575 | ASSERT_VK_SUCCESS(err); |
| 4576 | |
| 4577 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4578 | dsl_binding.binding = 0; |
| 4579 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4580 | dsl_binding.descriptorCount = 1; |
| 4581 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4582 | |
| 4583 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4584 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4585 | ds_layout_ci.bindingCount = 1; |
| 4586 | ds_layout_ci.pBindings = &dsl_binding; |
| 4587 | |
| 4588 | VkDescriptorSetLayout ds_layout; |
| 4589 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4590 | &ds_layout); |
| 4591 | ASSERT_VK_SUCCESS(err); |
| 4592 | |
| 4593 | VkDescriptorSet descriptorSet; |
| 4594 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4595 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4596 | alloc_info.descriptorSetCount = 1; |
| 4597 | alloc_info.descriptorPool = ds_pool; |
| 4598 | alloc_info.pSetLayouts = &ds_layout; |
| 4599 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4600 | &descriptorSet); |
| 4601 | ASSERT_VK_SUCCESS(err); |
| 4602 | |
| 4603 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4604 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4605 | pipeline_layout_ci.setLayoutCount = 1; |
| 4606 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4607 | |
| 4608 | VkPipelineLayout pipeline_layout; |
| 4609 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4610 | &pipeline_layout); |
| 4611 | ASSERT_VK_SUCCESS(err); |
| 4612 | |
| 4613 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4614 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4615 | vp_state_ci.scissorCount = 1; |
| 4616 | vp_state_ci.pScissors = |
| 4617 | NULL; // Null scissor w/ count of 1 should cause error |
| 4618 | vp_state_ci.viewportCount = 1; |
| 4619 | vp_state_ci.pViewports = |
| 4620 | NULL; // vp is dynamic (below) so this won't cause error |
| 4621 | |
| 4622 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4623 | // Set scissor as dynamic to avoid that error |
| 4624 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4625 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4626 | dyn_state_ci.dynamicStateCount = 1; |
| 4627 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4628 | |
| 4629 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4630 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4631 | |
| 4632 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4633 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4634 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4635 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4636 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4637 | // but add it to be able to run on more devices |
| 4638 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4639 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4640 | |
| 4641 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4642 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4643 | vi_ci.pNext = nullptr; |
| 4644 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4645 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4646 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4647 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4648 | |
| 4649 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4650 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4651 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4652 | |
| 4653 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4654 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4655 | rs_ci.pNext = nullptr; |
| 4656 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4657 | VkPipelineColorBlendAttachmentState att = {}; |
| 4658 | att.blendEnable = VK_FALSE; |
| 4659 | att.colorWriteMask = 0xf; |
| 4660 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4661 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4662 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4663 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4664 | cb_ci.attachmentCount = 1; |
| 4665 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4666 | |
| 4667 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4668 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4669 | gp_ci.stageCount = 2; |
| 4670 | gp_ci.pStages = shaderStages; |
| 4671 | gp_ci.pVertexInputState = &vi_ci; |
| 4672 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4673 | gp_ci.pViewportState = &vp_state_ci; |
| 4674 | gp_ci.pRasterizationState = &rs_ci; |
| 4675 | gp_ci.pColorBlendState = &cb_ci; |
| 4676 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4677 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4678 | gp_ci.layout = pipeline_layout; |
| 4679 | gp_ci.renderPass = renderPass(); |
| 4680 | |
| 4681 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4682 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4683 | |
| 4684 | VkPipeline pipeline; |
| 4685 | VkPipelineCache pipelineCache; |
| 4686 | |
| 4687 | err = |
| 4688 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4689 | ASSERT_VK_SUCCESS(err); |
| 4690 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4691 | &gp_ci, NULL, &pipeline); |
| 4692 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4693 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4694 | |
| 4695 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4696 | // First need to successfully create the PSO from above by setting |
| 4697 | // pViewports |
| 4698 | m_errorMonitor->SetDesiredFailureMsg( |
| 4699 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4700 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4701 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4702 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4703 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4704 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4705 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4706 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4707 | ASSERT_VK_SUCCESS(err); |
| 4708 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4709 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4710 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4711 | VkViewport viewports[2] = {}; // don't care about data |
| 4712 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4713 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4714 | Draw(1, 0, 0, 0); |
| 4715 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4716 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4717 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4718 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4719 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4720 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4721 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4722 | } |
| 4723 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4724 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4725 | VkResult err; |
| 4726 | |
| 4727 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4728 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4729 | |
| 4730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4731 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4732 | |
| 4733 | VkDescriptorPoolSize ds_type_count = {}; |
| 4734 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4735 | ds_type_count.descriptorCount = 1; |
| 4736 | |
| 4737 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4738 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4739 | ds_pool_ci.maxSets = 1; |
| 4740 | ds_pool_ci.poolSizeCount = 1; |
| 4741 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4742 | |
| 4743 | VkDescriptorPool ds_pool; |
| 4744 | err = |
| 4745 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4746 | ASSERT_VK_SUCCESS(err); |
| 4747 | |
| 4748 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4749 | dsl_binding.binding = 0; |
| 4750 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4751 | dsl_binding.descriptorCount = 1; |
| 4752 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4753 | |
| 4754 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4755 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4756 | ds_layout_ci.bindingCount = 1; |
| 4757 | ds_layout_ci.pBindings = &dsl_binding; |
| 4758 | |
| 4759 | VkDescriptorSetLayout ds_layout; |
| 4760 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4761 | &ds_layout); |
| 4762 | ASSERT_VK_SUCCESS(err); |
| 4763 | |
| 4764 | VkDescriptorSet descriptorSet; |
| 4765 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4766 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4767 | alloc_info.descriptorSetCount = 1; |
| 4768 | alloc_info.descriptorPool = ds_pool; |
| 4769 | alloc_info.pSetLayouts = &ds_layout; |
| 4770 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4771 | &descriptorSet); |
| 4772 | ASSERT_VK_SUCCESS(err); |
| 4773 | |
| 4774 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4775 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4776 | pipeline_layout_ci.setLayoutCount = 1; |
| 4777 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4778 | |
| 4779 | VkPipelineLayout pipeline_layout; |
| 4780 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4781 | &pipeline_layout); |
| 4782 | ASSERT_VK_SUCCESS(err); |
| 4783 | |
| 4784 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4785 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4786 | vp_state_ci.scissorCount = 1; |
| 4787 | vp_state_ci.pScissors = NULL; |
| 4788 | vp_state_ci.viewportCount = 1; |
| 4789 | vp_state_ci.pViewports = NULL; |
| 4790 | |
| 4791 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4792 | VK_DYNAMIC_STATE_SCISSOR, |
| 4793 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4794 | // Set scissor as dynamic to avoid that error |
| 4795 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4796 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4797 | dyn_state_ci.dynamicStateCount = 2; |
| 4798 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4799 | |
| 4800 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4801 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4802 | |
| 4803 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4804 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4805 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4806 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4807 | this); // TODO - We shouldn't need a fragment shader |
| 4808 | // but add it to be able to run on more devices |
| 4809 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4810 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4811 | |
| 4812 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4813 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4814 | vi_ci.pNext = nullptr; |
| 4815 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4816 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4817 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4818 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4819 | |
| 4820 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4821 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4822 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4823 | |
| 4824 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4825 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4826 | rs_ci.pNext = nullptr; |
| 4827 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4828 | // Check too low (line width of -1.0f). |
| 4829 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4830 | |
| 4831 | VkPipelineColorBlendAttachmentState att = {}; |
| 4832 | att.blendEnable = VK_FALSE; |
| 4833 | att.colorWriteMask = 0xf; |
| 4834 | |
| 4835 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4836 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4837 | cb_ci.pNext = nullptr; |
| 4838 | cb_ci.attachmentCount = 1; |
| 4839 | cb_ci.pAttachments = &att; |
| 4840 | |
| 4841 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4842 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4843 | gp_ci.stageCount = 2; |
| 4844 | gp_ci.pStages = shaderStages; |
| 4845 | gp_ci.pVertexInputState = &vi_ci; |
| 4846 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4847 | gp_ci.pViewportState = &vp_state_ci; |
| 4848 | gp_ci.pRasterizationState = &rs_ci; |
| 4849 | gp_ci.pColorBlendState = &cb_ci; |
| 4850 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4851 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4852 | gp_ci.layout = pipeline_layout; |
| 4853 | gp_ci.renderPass = renderPass(); |
| 4854 | |
| 4855 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4856 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4857 | |
| 4858 | VkPipeline pipeline; |
| 4859 | VkPipelineCache pipelineCache; |
| 4860 | |
| 4861 | err = |
| 4862 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4863 | ASSERT_VK_SUCCESS(err); |
| 4864 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4865 | &gp_ci, NULL, &pipeline); |
| 4866 | |
| 4867 | m_errorMonitor->VerifyFound(); |
| 4868 | |
| 4869 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4870 | "Attempt to set lineWidth to 65536"); |
| 4871 | |
| 4872 | // Check too high (line width of 65536.0f). |
| 4873 | rs_ci.lineWidth = 65536.0f; |
| 4874 | |
| 4875 | err = |
| 4876 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4877 | ASSERT_VK_SUCCESS(err); |
| 4878 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4879 | &gp_ci, NULL, &pipeline); |
| 4880 | |
| 4881 | m_errorMonitor->VerifyFound(); |
| 4882 | |
| 4883 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4884 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4885 | |
| 4886 | dyn_state_ci.dynamicStateCount = 3; |
| 4887 | |
| 4888 | rs_ci.lineWidth = 1.0f; |
| 4889 | |
| 4890 | err = |
| 4891 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4892 | ASSERT_VK_SUCCESS(err); |
| 4893 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4894 | &gp_ci, NULL, &pipeline); |
| 4895 | BeginCommandBuffer(); |
| 4896 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4897 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4898 | |
| 4899 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4900 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4901 | m_errorMonitor->VerifyFound(); |
| 4902 | |
| 4903 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4904 | "Attempt to set lineWidth to 65536"); |
| 4905 | |
| 4906 | // Check too high with dynamic setting. |
| 4907 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 4908 | m_errorMonitor->VerifyFound(); |
| 4909 | EndCommandBuffer(); |
| 4910 | |
| 4911 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4912 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4913 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4914 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4915 | } |
| 4916 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4917 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4918 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4919 | m_errorMonitor->SetDesiredFailureMsg( |
| 4920 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4921 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4922 | |
| 4923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4925 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4926 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4927 | // Don't care about RenderPass handle b/c error should be flagged before |
| 4928 | // that |
| 4929 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 4930 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4931 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4932 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4933 | } |
| 4934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4935 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4936 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4937 | m_errorMonitor->SetDesiredFailureMsg( |
| 4938 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4939 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4940 | |
| 4941 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4942 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4943 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4944 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4945 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 4946 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4947 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4948 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 4949 | rp_begin.pNext = NULL; |
| 4950 | rp_begin.renderPass = renderPass(); |
| 4951 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4952 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4953 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 4954 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4955 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4956 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4957 | } |
| 4958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4959 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4960 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4961 | m_errorMonitor->SetDesiredFailureMsg( |
| 4962 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4963 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4964 | |
| 4965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4966 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4967 | |
| 4968 | // Renderpass is started here |
| 4969 | BeginCommandBuffer(); |
| 4970 | |
| 4971 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4972 | vk_testing::Buffer dstBuffer; |
| 4973 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4974 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4975 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4976 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4977 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4978 | } |
| 4979 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4980 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4981 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4982 | m_errorMonitor->SetDesiredFailureMsg( |
| 4983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4984 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4985 | |
| 4986 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4987 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4988 | |
| 4989 | // Renderpass is started here |
| 4990 | BeginCommandBuffer(); |
| 4991 | |
| 4992 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4993 | vk_testing::Buffer dstBuffer; |
| 4994 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4996 | VkDeviceSize dstOffset = 0; |
| 4997 | VkDeviceSize dataSize = 1024; |
| 4998 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4999 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5000 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5001 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5002 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5003 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5004 | } |
| 5005 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5006 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5007 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | m_errorMonitor->SetDesiredFailureMsg( |
| 5009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5010 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5011 | |
| 5012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5013 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5014 | |
| 5015 | // Renderpass is started here |
| 5016 | BeginCommandBuffer(); |
| 5017 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5018 | VkClearColorValue clear_color; |
| 5019 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5020 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5021 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5022 | const int32_t tex_width = 32; |
| 5023 | const int32_t tex_height = 32; |
| 5024 | VkImageCreateInfo image_create_info = {}; |
| 5025 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5026 | image_create_info.pNext = NULL; |
| 5027 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5028 | image_create_info.format = tex_format; |
| 5029 | image_create_info.extent.width = tex_width; |
| 5030 | image_create_info.extent.height = tex_height; |
| 5031 | image_create_info.extent.depth = 1; |
| 5032 | image_create_info.mipLevels = 1; |
| 5033 | image_create_info.arrayLayers = 1; |
| 5034 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5035 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5036 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5037 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5038 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5039 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5040 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5042 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5043 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5045 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5046 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5047 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5048 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5049 | } |
| 5050 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5051 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5052 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5053 | m_errorMonitor->SetDesiredFailureMsg( |
| 5054 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5055 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5056 | |
| 5057 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5058 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5059 | |
| 5060 | // Renderpass is started here |
| 5061 | BeginCommandBuffer(); |
| 5062 | |
| 5063 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5064 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5065 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5066 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5067 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5068 | image_create_info.extent.width = 64; |
| 5069 | image_create_info.extent.height = 64; |
| 5070 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5071 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5072 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5073 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5074 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5075 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5077 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5078 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5079 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5080 | vkCmdClearDepthStencilImage( |
| 5081 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5082 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5083 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5084 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5085 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5086 | } |
| 5087 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5088 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5089 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5090 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5091 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5092 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5093 | "vkCmdClearAttachments: This call " |
| 5094 | "must be issued inside an active " |
| 5095 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5096 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5098 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5099 | |
| 5100 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5101 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5104 | VkClearAttachment color_attachment; |
| 5105 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5106 | color_attachment.clearValue.color.float32[0] = 0; |
| 5107 | color_attachment.clearValue.color.float32[1] = 0; |
| 5108 | color_attachment.clearValue.color.float32[2] = 0; |
| 5109 | color_attachment.clearValue.color.float32[3] = 0; |
| 5110 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5111 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5112 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5113 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5114 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5115 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5116 | } |
| 5117 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5118 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5119 | // Try to add a buffer memory barrier with no buffer. |
| 5120 | m_errorMonitor->SetDesiredFailureMsg( |
| 5121 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5122 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5123 | |
| 5124 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5125 | BeginCommandBuffer(); |
| 5126 | |
| 5127 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5128 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5129 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5130 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5131 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5132 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5133 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5134 | buf_barrier.offset = 0; |
| 5135 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5136 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5137 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5138 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5139 | |
| 5140 | m_errorMonitor->VerifyFound(); |
| 5141 | } |
| 5142 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5143 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5144 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5145 | |
| 5146 | m_errorMonitor->SetDesiredFailureMsg( |
| 5147 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5148 | |
| 5149 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5150 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5151 | |
| 5152 | VkMemoryBarrier mem_barrier = {}; |
| 5153 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5154 | mem_barrier.pNext = NULL; |
| 5155 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5156 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5157 | BeginCommandBuffer(); |
| 5158 | // BeginCommandBuffer() starts a render pass |
| 5159 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5160 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5161 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5162 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5163 | m_errorMonitor->VerifyFound(); |
| 5164 | |
| 5165 | m_errorMonitor->SetDesiredFailureMsg( |
| 5166 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5167 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5168 | VkImageObj image(m_device); |
| 5169 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5170 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5171 | ASSERT_TRUE(image.initialized()); |
| 5172 | VkImageMemoryBarrier img_barrier = {}; |
| 5173 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5174 | img_barrier.pNext = NULL; |
| 5175 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5176 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5177 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5178 | // New layout can't be UNDEFINED |
| 5179 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5180 | img_barrier.image = image.handle(); |
| 5181 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5182 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5183 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5184 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5185 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5186 | img_barrier.subresourceRange.layerCount = 1; |
| 5187 | img_barrier.subresourceRange.levelCount = 1; |
| 5188 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5189 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5190 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5191 | nullptr, 1, &img_barrier); |
| 5192 | m_errorMonitor->VerifyFound(); |
| 5193 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5194 | |
| 5195 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5196 | "Subresource must have the sum of the " |
| 5197 | "baseArrayLayer"); |
| 5198 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5199 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5200 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5201 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5202 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5203 | nullptr, 1, &img_barrier); |
| 5204 | m_errorMonitor->VerifyFound(); |
| 5205 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5206 | |
| 5207 | m_errorMonitor->SetDesiredFailureMsg( |
| 5208 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5209 | "Subresource must have the sum of the baseMipLevel"); |
| 5210 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5211 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5212 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5213 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5214 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5215 | nullptr, 1, &img_barrier); |
| 5216 | m_errorMonitor->VerifyFound(); |
| 5217 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5218 | |
| 5219 | m_errorMonitor->SetDesiredFailureMsg( |
| 5220 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5221 | "Buffer Barriers cannot be used during a render pass"); |
| 5222 | vk_testing::Buffer buffer; |
| 5223 | buffer.init(*m_device, 256); |
| 5224 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5225 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5226 | buf_barrier.pNext = NULL; |
| 5227 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5228 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5229 | buf_barrier.buffer = buffer.handle(); |
| 5230 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5231 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5232 | buf_barrier.offset = 0; |
| 5233 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5234 | // Can't send buffer barrier during a render pass |
| 5235 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5236 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5237 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5238 | &buf_barrier, 0, nullptr); |
| 5239 | m_errorMonitor->VerifyFound(); |
| 5240 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5241 | |
| 5242 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5243 | "which is not less than total size"); |
| 5244 | buf_barrier.offset = 257; |
| 5245 | // Offset greater than total size |
| 5246 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5247 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5248 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5249 | &buf_barrier, 0, nullptr); |
| 5250 | m_errorMonitor->VerifyFound(); |
| 5251 | buf_barrier.offset = 0; |
| 5252 | |
| 5253 | m_errorMonitor->SetDesiredFailureMsg( |
| 5254 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5255 | buf_barrier.size = 257; |
| 5256 | // Size greater than total size |
| 5257 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5258 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5259 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5260 | &buf_barrier, 0, nullptr); |
| 5261 | m_errorMonitor->VerifyFound(); |
| 5262 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5263 | |
| 5264 | m_errorMonitor->SetDesiredFailureMsg( |
| 5265 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5266 | "Image is a depth and stencil format and thus must " |
| 5267 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5268 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5269 | VkDepthStencilObj ds_image(m_device); |
| 5270 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5271 | ASSERT_TRUE(ds_image.initialized()); |
| 5272 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5273 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5274 | img_barrier.image = ds_image.handle(); |
| 5275 | // Leave aspectMask at COLOR on purpose |
| 5276 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5277 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5278 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5279 | nullptr, 1, &img_barrier); |
| 5280 | m_errorMonitor->VerifyFound(); |
| 5281 | } |
| 5282 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5283 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5284 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5285 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5287 | m_errorMonitor->SetDesiredFailureMsg( |
| 5288 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5289 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5290 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5291 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5292 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5293 | uint32_t qfi = 0; |
| 5294 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5295 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5296 | buffCI.size = 1024; |
| 5297 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5298 | buffCI.queueFamilyIndexCount = 1; |
| 5299 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5300 | |
| 5301 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5302 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5303 | ASSERT_VK_SUCCESS(err); |
| 5304 | |
| 5305 | BeginCommandBuffer(); |
| 5306 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5307 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5308 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5309 | // 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] | 5310 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5311 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5312 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5313 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5314 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5315 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5316 | } |
| 5317 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5318 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5319 | // Create an out-of-range queueFamilyIndex |
| 5320 | m_errorMonitor->SetDesiredFailureMsg( |
| 5321 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5322 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5323 | |
| 5324 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5325 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5326 | VkBufferCreateInfo buffCI = {}; |
| 5327 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5328 | buffCI.size = 1024; |
| 5329 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5330 | buffCI.queueFamilyIndexCount = 1; |
| 5331 | // Introduce failure by specifying invalid queue_family_index |
| 5332 | uint32_t qfi = 777; |
| 5333 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5334 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5335 | |
| 5336 | VkBuffer ib; |
| 5337 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5338 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5339 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5340 | } |
| 5341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5342 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5343 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5344 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5346 | m_errorMonitor->SetDesiredFailureMsg( |
| 5347 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5348 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5349 | |
| 5350 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5352 | |
| 5353 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5354 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5355 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5356 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5357 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5358 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5359 | } |
| 5360 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5361 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5362 | // 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] | 5363 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5365 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5366 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5367 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5368 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5369 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5370 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5371 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5372 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5373 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5374 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5375 | |
| 5376 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5377 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5378 | ds_pool_ci.pNext = NULL; |
| 5379 | ds_pool_ci.maxSets = 1; |
| 5380 | ds_pool_ci.poolSizeCount = 1; |
| 5381 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5382 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5383 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5384 | err = |
| 5385 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5386 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5387 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5388 | dsl_binding.binding = 0; |
| 5389 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5390 | dsl_binding.descriptorCount = 1; |
| 5391 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5392 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5393 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5394 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5395 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5396 | ds_layout_ci.pNext = NULL; |
| 5397 | ds_layout_ci.bindingCount = 1; |
| 5398 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5399 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5400 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5401 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5402 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5403 | ASSERT_VK_SUCCESS(err); |
| 5404 | |
| 5405 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5406 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5407 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5408 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5409 | alloc_info.descriptorPool = ds_pool; |
| 5410 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5411 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5412 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5413 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5414 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5415 | VkSamplerCreateInfo sampler_ci = {}; |
| 5416 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5417 | sampler_ci.pNext = NULL; |
| 5418 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5419 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5420 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5421 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5422 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5423 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5424 | sampler_ci.mipLodBias = 1.0; |
| 5425 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5426 | sampler_ci.maxAnisotropy = 1; |
| 5427 | sampler_ci.compareEnable = VK_FALSE; |
| 5428 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5429 | sampler_ci.minLod = 1.0; |
| 5430 | sampler_ci.maxLod = 1.0; |
| 5431 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5432 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5433 | VkSampler sampler; |
| 5434 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5435 | ASSERT_VK_SUCCESS(err); |
| 5436 | |
| 5437 | VkDescriptorImageInfo info = {}; |
| 5438 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5439 | |
| 5440 | VkWriteDescriptorSet descriptor_write; |
| 5441 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5442 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5443 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5444 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5445 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5446 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5447 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5448 | |
| 5449 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5450 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5451 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5452 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5453 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5454 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5455 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5456 | } |
| 5457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5459 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5460 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5461 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5462 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5463 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5464 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5465 | "starting at binding offset of 0 combined with update array element " |
| 5466 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5467 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5468 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5469 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5470 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5471 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5472 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5473 | |
| 5474 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5475 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5476 | ds_pool_ci.pNext = NULL; |
| 5477 | ds_pool_ci.maxSets = 1; |
| 5478 | ds_pool_ci.poolSizeCount = 1; |
| 5479 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5480 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5481 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5482 | err = |
| 5483 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5484 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5485 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5486 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5487 | dsl_binding.binding = 0; |
| 5488 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5489 | dsl_binding.descriptorCount = 1; |
| 5490 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5491 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5492 | |
| 5493 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5494 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5495 | ds_layout_ci.pNext = NULL; |
| 5496 | ds_layout_ci.bindingCount = 1; |
| 5497 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5498 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5499 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5500 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5501 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5502 | ASSERT_VK_SUCCESS(err); |
| 5503 | |
| 5504 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5505 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5506 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5507 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5508 | alloc_info.descriptorPool = ds_pool; |
| 5509 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5510 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5511 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5512 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5513 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5514 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5515 | VkDescriptorBufferInfo buff_info = {}; |
| 5516 | buff_info.buffer = |
| 5517 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5518 | buff_info.offset = 0; |
| 5519 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5520 | |
| 5521 | VkWriteDescriptorSet descriptor_write; |
| 5522 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5523 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5524 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | descriptor_write.dstArrayElement = |
| 5526 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5527 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5528 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5529 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5530 | |
| 5531 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5532 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5533 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5534 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5535 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5536 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5537 | } |
| 5538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5540 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5541 | // index 2 |
| 5542 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5543 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5544 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5545 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5546 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5548 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5549 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5551 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5552 | |
| 5553 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5554 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5555 | ds_pool_ci.pNext = NULL; |
| 5556 | ds_pool_ci.maxSets = 1; |
| 5557 | ds_pool_ci.poolSizeCount = 1; |
| 5558 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5559 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5560 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5561 | err = |
| 5562 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5563 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5564 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5565 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5566 | dsl_binding.binding = 0; |
| 5567 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5568 | dsl_binding.descriptorCount = 1; |
| 5569 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5570 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5571 | |
| 5572 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5573 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5574 | ds_layout_ci.pNext = NULL; |
| 5575 | ds_layout_ci.bindingCount = 1; |
| 5576 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5577 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5578 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5579 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5580 | ASSERT_VK_SUCCESS(err); |
| 5581 | |
| 5582 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5583 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5584 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5585 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5586 | alloc_info.descriptorPool = ds_pool; |
| 5587 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5588 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5589 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5590 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5591 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5592 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5593 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5594 | sampler_ci.pNext = NULL; |
| 5595 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5596 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5597 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5598 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5599 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5600 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5601 | sampler_ci.mipLodBias = 1.0; |
| 5602 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5603 | sampler_ci.maxAnisotropy = 1; |
| 5604 | sampler_ci.compareEnable = VK_FALSE; |
| 5605 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5606 | sampler_ci.minLod = 1.0; |
| 5607 | sampler_ci.maxLod = 1.0; |
| 5608 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5609 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5610 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5611 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5612 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5613 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5614 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5615 | VkDescriptorImageInfo info = {}; |
| 5616 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5617 | |
| 5618 | VkWriteDescriptorSet descriptor_write; |
| 5619 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5620 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5621 | descriptor_write.dstSet = descriptorSet; |
| 5622 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5623 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5624 | // 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] | 5625 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5626 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5627 | |
| 5628 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5629 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5630 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5631 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5632 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5633 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5634 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5635 | } |
| 5636 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5637 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5638 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5639 | // types |
| 5640 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5641 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5642 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5643 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5644 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5645 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5646 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5647 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5648 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5649 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5650 | |
| 5651 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5652 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5653 | ds_pool_ci.pNext = NULL; |
| 5654 | ds_pool_ci.maxSets = 1; |
| 5655 | ds_pool_ci.poolSizeCount = 1; |
| 5656 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5657 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5658 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | err = |
| 5660 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5661 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5662 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5663 | dsl_binding.binding = 0; |
| 5664 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5665 | dsl_binding.descriptorCount = 1; |
| 5666 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5667 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5668 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5669 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5671 | ds_layout_ci.pNext = NULL; |
| 5672 | ds_layout_ci.bindingCount = 1; |
| 5673 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5674 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5675 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5676 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5677 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5678 | ASSERT_VK_SUCCESS(err); |
| 5679 | |
| 5680 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5681 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5682 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5683 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5684 | alloc_info.descriptorPool = ds_pool; |
| 5685 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5686 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5687 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5688 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5689 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5690 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5691 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5692 | sampler_ci.pNext = NULL; |
| 5693 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5694 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5695 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5696 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5697 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5698 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5699 | sampler_ci.mipLodBias = 1.0; |
| 5700 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5701 | sampler_ci.maxAnisotropy = 1; |
| 5702 | sampler_ci.compareEnable = VK_FALSE; |
| 5703 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5704 | sampler_ci.minLod = 1.0; |
| 5705 | sampler_ci.maxLod = 1.0; |
| 5706 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5707 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5708 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5709 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5710 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5711 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5712 | VkDescriptorImageInfo info = {}; |
| 5713 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5714 | |
| 5715 | VkWriteDescriptorSet descriptor_write; |
| 5716 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | descriptor_write.sType = |
| 5718 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5719 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5720 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5721 | // 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] | 5722 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5723 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5724 | |
| 5725 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5726 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5727 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5728 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5729 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5730 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5731 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5732 | } |
| 5733 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5734 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5735 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5736 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5737 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5738 | m_errorMonitor->SetDesiredFailureMsg( |
| 5739 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5740 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5741 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5742 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5743 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5744 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5745 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5746 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5747 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5748 | |
| 5749 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5750 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5751 | ds_pool_ci.pNext = NULL; |
| 5752 | ds_pool_ci.maxSets = 1; |
| 5753 | ds_pool_ci.poolSizeCount = 1; |
| 5754 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5755 | |
| 5756 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5757 | err = |
| 5758 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5759 | ASSERT_VK_SUCCESS(err); |
| 5760 | |
| 5761 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5762 | dsl_binding.binding = 0; |
| 5763 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5764 | dsl_binding.descriptorCount = 1; |
| 5765 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5766 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5767 | |
| 5768 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5769 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5770 | ds_layout_ci.pNext = NULL; |
| 5771 | ds_layout_ci.bindingCount = 1; |
| 5772 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5773 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5774 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5775 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5776 | ASSERT_VK_SUCCESS(err); |
| 5777 | |
| 5778 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5779 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5780 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5781 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5782 | alloc_info.descriptorPool = ds_pool; |
| 5783 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5784 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5785 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5786 | ASSERT_VK_SUCCESS(err); |
| 5787 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5788 | VkSampler sampler = |
| 5789 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5790 | |
| 5791 | VkDescriptorImageInfo descriptor_info; |
| 5792 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5793 | descriptor_info.sampler = sampler; |
| 5794 | |
| 5795 | VkWriteDescriptorSet descriptor_write; |
| 5796 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5797 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5798 | descriptor_write.dstSet = descriptorSet; |
| 5799 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5800 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5801 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5802 | descriptor_write.pImageInfo = &descriptor_info; |
| 5803 | |
| 5804 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5805 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5806 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5807 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5808 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5809 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5810 | } |
| 5811 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5812 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5813 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5814 | // imageView |
| 5815 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5816 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5817 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5818 | "Attempted write update to combined " |
| 5819 | "image sampler descriptor failed due " |
| 5820 | "to: Invalid VkImageView: 0xbaadbeef"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5821 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5822 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5823 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5824 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5825 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5826 | |
| 5827 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5828 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5829 | ds_pool_ci.pNext = NULL; |
| 5830 | ds_pool_ci.maxSets = 1; |
| 5831 | ds_pool_ci.poolSizeCount = 1; |
| 5832 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5833 | |
| 5834 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5835 | err = |
| 5836 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5837 | ASSERT_VK_SUCCESS(err); |
| 5838 | |
| 5839 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5840 | dsl_binding.binding = 0; |
| 5841 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5842 | dsl_binding.descriptorCount = 1; |
| 5843 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5844 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5845 | |
| 5846 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5847 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5848 | ds_layout_ci.pNext = NULL; |
| 5849 | ds_layout_ci.bindingCount = 1; |
| 5850 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5851 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5853 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5854 | ASSERT_VK_SUCCESS(err); |
| 5855 | |
| 5856 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5857 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5858 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5859 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5860 | alloc_info.descriptorPool = ds_pool; |
| 5861 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5862 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5863 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5864 | ASSERT_VK_SUCCESS(err); |
| 5865 | |
| 5866 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5867 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5868 | sampler_ci.pNext = NULL; |
| 5869 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5870 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5871 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5872 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5873 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5874 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5875 | sampler_ci.mipLodBias = 1.0; |
| 5876 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5877 | sampler_ci.maxAnisotropy = 1; |
| 5878 | sampler_ci.compareEnable = VK_FALSE; |
| 5879 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5880 | sampler_ci.minLod = 1.0; |
| 5881 | sampler_ci.maxLod = 1.0; |
| 5882 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5883 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5884 | |
| 5885 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5886 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5887 | ASSERT_VK_SUCCESS(err); |
| 5888 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5889 | VkImageView view = |
| 5890 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5891 | |
| 5892 | VkDescriptorImageInfo descriptor_info; |
| 5893 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5894 | descriptor_info.sampler = sampler; |
| 5895 | descriptor_info.imageView = view; |
| 5896 | |
| 5897 | VkWriteDescriptorSet descriptor_write; |
| 5898 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5899 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5900 | descriptor_write.dstSet = descriptorSet; |
| 5901 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5902 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5903 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5904 | descriptor_write.pImageInfo = &descriptor_info; |
| 5905 | |
| 5906 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5907 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5908 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5909 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5910 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5911 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5912 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5913 | } |
| 5914 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5915 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 5916 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 5917 | // into the other |
| 5918 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5919 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5920 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5921 | " binding #1 with type " |
| 5922 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 5923 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5924 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5925 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5926 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5927 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5928 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5929 | ds_type_count[0].descriptorCount = 1; |
| 5930 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5931 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5932 | |
| 5933 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5934 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5935 | ds_pool_ci.pNext = NULL; |
| 5936 | ds_pool_ci.maxSets = 1; |
| 5937 | ds_pool_ci.poolSizeCount = 2; |
| 5938 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5939 | |
| 5940 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5941 | err = |
| 5942 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5943 | ASSERT_VK_SUCCESS(err); |
| 5944 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5945 | dsl_binding[0].binding = 0; |
| 5946 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5947 | dsl_binding[0].descriptorCount = 1; |
| 5948 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5949 | dsl_binding[0].pImmutableSamplers = NULL; |
| 5950 | dsl_binding[1].binding = 1; |
| 5951 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5952 | dsl_binding[1].descriptorCount = 1; |
| 5953 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5954 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5955 | |
| 5956 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5958 | ds_layout_ci.pNext = NULL; |
| 5959 | ds_layout_ci.bindingCount = 2; |
| 5960 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5961 | |
| 5962 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5963 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5964 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5965 | ASSERT_VK_SUCCESS(err); |
| 5966 | |
| 5967 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5968 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5969 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5970 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5971 | alloc_info.descriptorPool = ds_pool; |
| 5972 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5973 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5974 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5975 | ASSERT_VK_SUCCESS(err); |
| 5976 | |
| 5977 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5979 | sampler_ci.pNext = NULL; |
| 5980 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5981 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5982 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5983 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5984 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5985 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5986 | sampler_ci.mipLodBias = 1.0; |
| 5987 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5988 | sampler_ci.maxAnisotropy = 1; |
| 5989 | sampler_ci.compareEnable = VK_FALSE; |
| 5990 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5991 | sampler_ci.minLod = 1.0; |
| 5992 | sampler_ci.maxLod = 1.0; |
| 5993 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5994 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5995 | |
| 5996 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5997 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5998 | ASSERT_VK_SUCCESS(err); |
| 5999 | |
| 6000 | VkDescriptorImageInfo info = {}; |
| 6001 | info.sampler = sampler; |
| 6002 | |
| 6003 | VkWriteDescriptorSet descriptor_write; |
| 6004 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6005 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6006 | descriptor_write.dstSet = descriptorSet; |
| 6007 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6008 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6009 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6010 | descriptor_write.pImageInfo = &info; |
| 6011 | // This write update should succeed |
| 6012 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6013 | // Now perform a copy update that fails due to type mismatch |
| 6014 | VkCopyDescriptorSet copy_ds_update; |
| 6015 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6016 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6017 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6018 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6019 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6020 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6021 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6022 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6023 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6024 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6025 | // 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] | 6026 | m_errorMonitor->SetDesiredFailureMsg( |
| 6027 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6028 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6029 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6030 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6031 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6032 | copy_ds_update.srcBinding = |
| 6033 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6034 | copy_ds_update.dstSet = descriptorSet; |
| 6035 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6036 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6037 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6038 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6039 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6040 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6041 | // 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] | 6042 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6043 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6044 | "update array offset of 0 and update of " |
| 6045 | "5 descriptors oversteps total number " |
| 6046 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6047 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6048 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6049 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6050 | copy_ds_update.srcSet = descriptorSet; |
| 6051 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6052 | copy_ds_update.dstSet = descriptorSet; |
| 6053 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6054 | copy_ds_update.descriptorCount = |
| 6055 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6056 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6057 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6058 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6059 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6060 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6061 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6062 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6063 | } |
| 6064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6065 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6066 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6067 | // sampleCount |
| 6068 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6069 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6070 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6071 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6072 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6073 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6074 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6075 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6076 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6077 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6078 | |
| 6079 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6080 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6081 | ds_pool_ci.pNext = NULL; |
| 6082 | ds_pool_ci.maxSets = 1; |
| 6083 | ds_pool_ci.poolSizeCount = 1; |
| 6084 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6085 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6086 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6087 | err = |
| 6088 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6089 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6090 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6091 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6092 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6093 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6094 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6095 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6096 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6097 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6098 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6099 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6100 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6101 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6102 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6103 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6104 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6105 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6106 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6107 | ASSERT_VK_SUCCESS(err); |
| 6108 | |
| 6109 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6110 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6111 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6112 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6113 | alloc_info.descriptorPool = ds_pool; |
| 6114 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6115 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6116 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6117 | ASSERT_VK_SUCCESS(err); |
| 6118 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6119 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6120 | pipe_ms_state_ci.sType = |
| 6121 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6122 | pipe_ms_state_ci.pNext = NULL; |
| 6123 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6124 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6125 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6126 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6127 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6128 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6129 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6130 | pipeline_layout_ci.pNext = NULL; |
| 6131 | pipeline_layout_ci.setLayoutCount = 1; |
| 6132 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6133 | |
| 6134 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6136 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6137 | ASSERT_VK_SUCCESS(err); |
| 6138 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6139 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6140 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6141 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6142 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6143 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6144 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6145 | VkPipelineObj pipe(m_device); |
| 6146 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6147 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6148 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6149 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6150 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6151 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6152 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6153 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6154 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6155 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6156 | // Render triangle (the error should trigger on the attempt to draw). |
| 6157 | Draw(3, 1, 0, 0); |
| 6158 | |
| 6159 | // Finalize recording of the command buffer |
| 6160 | EndCommandBuffer(); |
| 6161 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6162 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6163 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6164 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6165 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6166 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6167 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6168 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6169 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6170 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6171 | // number of color attachments. In this case, we don't add any color |
| 6172 | // blend attachments even though we have a color attachment. |
| 6173 | VkResult err; |
| 6174 | |
| 6175 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6176 | "Render pass subpass 0 mismatch with blending state defined and blend state attachment"); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6177 | |
| 6178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6179 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6180 | VkDescriptorPoolSize ds_type_count = {}; |
| 6181 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6182 | ds_type_count.descriptorCount = 1; |
| 6183 | |
| 6184 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6185 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6186 | ds_pool_ci.pNext = NULL; |
| 6187 | ds_pool_ci.maxSets = 1; |
| 6188 | ds_pool_ci.poolSizeCount = 1; |
| 6189 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6190 | |
| 6191 | VkDescriptorPool ds_pool; |
| 6192 | err = |
| 6193 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6194 | ASSERT_VK_SUCCESS(err); |
| 6195 | |
| 6196 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6197 | dsl_binding.binding = 0; |
| 6198 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6199 | dsl_binding.descriptorCount = 1; |
| 6200 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6201 | dsl_binding.pImmutableSamplers = NULL; |
| 6202 | |
| 6203 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6204 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6205 | ds_layout_ci.pNext = NULL; |
| 6206 | ds_layout_ci.bindingCount = 1; |
| 6207 | ds_layout_ci.pBindings = &dsl_binding; |
| 6208 | |
| 6209 | VkDescriptorSetLayout ds_layout; |
| 6210 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6211 | &ds_layout); |
| 6212 | ASSERT_VK_SUCCESS(err); |
| 6213 | |
| 6214 | VkDescriptorSet descriptorSet; |
| 6215 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6216 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6217 | alloc_info.descriptorSetCount = 1; |
| 6218 | alloc_info.descriptorPool = ds_pool; |
| 6219 | alloc_info.pSetLayouts = &ds_layout; |
| 6220 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6221 | &descriptorSet); |
| 6222 | ASSERT_VK_SUCCESS(err); |
| 6223 | |
| 6224 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6225 | pipe_ms_state_ci.sType = |
| 6226 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6227 | pipe_ms_state_ci.pNext = NULL; |
| 6228 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6229 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6230 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6231 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6232 | |
| 6233 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6234 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6235 | pipeline_layout_ci.pNext = NULL; |
| 6236 | pipeline_layout_ci.setLayoutCount = 1; |
| 6237 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6238 | |
| 6239 | VkPipelineLayout pipeline_layout; |
| 6240 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6241 | &pipeline_layout); |
| 6242 | ASSERT_VK_SUCCESS(err); |
| 6243 | |
| 6244 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6245 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6246 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6247 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6248 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6249 | // but add it to be able to run on more devices |
| 6250 | VkPipelineObj pipe(m_device); |
| 6251 | pipe.AddShader(&vs); |
| 6252 | pipe.AddShader(&fs); |
| 6253 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6254 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6255 | |
| 6256 | BeginCommandBuffer(); |
| 6257 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6258 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6259 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6260 | // Render triangle (the error should trigger on the attempt to draw). |
| 6261 | Draw(3, 1, 0, 0); |
| 6262 | |
| 6263 | // Finalize recording of the command buffer |
| 6264 | EndCommandBuffer(); |
| 6265 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6266 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6267 | |
| 6268 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6269 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6270 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6271 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6273 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6274 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6275 | // to issuing a Draw |
| 6276 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6277 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6278 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6279 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6280 | "vkCmdClearAttachments() issued on CB object "); |
| 6281 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6283 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6284 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6285 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6286 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6287 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6288 | |
| 6289 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6290 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6291 | ds_pool_ci.pNext = NULL; |
| 6292 | ds_pool_ci.maxSets = 1; |
| 6293 | ds_pool_ci.poolSizeCount = 1; |
| 6294 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6295 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6296 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6297 | err = |
| 6298 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6299 | ASSERT_VK_SUCCESS(err); |
| 6300 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6301 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6302 | dsl_binding.binding = 0; |
| 6303 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6304 | dsl_binding.descriptorCount = 1; |
| 6305 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6306 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6307 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6308 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6309 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6310 | ds_layout_ci.pNext = NULL; |
| 6311 | ds_layout_ci.bindingCount = 1; |
| 6312 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6313 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6314 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6315 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6316 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6317 | ASSERT_VK_SUCCESS(err); |
| 6318 | |
| 6319 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6320 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6321 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6322 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6323 | alloc_info.descriptorPool = ds_pool; |
| 6324 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6325 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6326 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6327 | ASSERT_VK_SUCCESS(err); |
| 6328 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6329 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6330 | pipe_ms_state_ci.sType = |
| 6331 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6332 | pipe_ms_state_ci.pNext = NULL; |
| 6333 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6334 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6335 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6336 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6337 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6338 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6339 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6340 | pipeline_layout_ci.pNext = NULL; |
| 6341 | pipeline_layout_ci.setLayoutCount = 1; |
| 6342 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6343 | |
| 6344 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6345 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6346 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6347 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6349 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6350 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6351 | // 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] | 6352 | // on more devices |
| 6353 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6354 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6355 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6356 | VkPipelineObj pipe(m_device); |
| 6357 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6358 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6359 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6360 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6361 | |
| 6362 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6363 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6364 | // Main thing we care about for this test is that the VkImage obj we're |
| 6365 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6366 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6367 | VkClearAttachment color_attachment; |
| 6368 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6369 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6370 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6371 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6372 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6373 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6374 | VkClearRect clear_rect = { |
| 6375 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6377 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6378 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6379 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6380 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6381 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6382 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6383 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6384 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6385 | } |
| 6386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6387 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6388 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6391 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6392 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6393 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6395 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6396 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6397 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6398 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6399 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6400 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6401 | |
| 6402 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6403 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6404 | ds_pool_ci.pNext = NULL; |
| 6405 | ds_pool_ci.maxSets = 1; |
| 6406 | ds_pool_ci.poolSizeCount = 1; |
| 6407 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6408 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6409 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6410 | err = |
| 6411 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6412 | ASSERT_VK_SUCCESS(err); |
| 6413 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6414 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6415 | dsl_binding.binding = 0; |
| 6416 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6417 | dsl_binding.descriptorCount = 1; |
| 6418 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6419 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6420 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6421 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6422 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6423 | ds_layout_ci.pNext = NULL; |
| 6424 | ds_layout_ci.bindingCount = 1; |
| 6425 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6426 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6427 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6428 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6429 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6430 | ASSERT_VK_SUCCESS(err); |
| 6431 | |
| 6432 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6433 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6434 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6435 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6436 | alloc_info.descriptorPool = ds_pool; |
| 6437 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6438 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6439 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6440 | ASSERT_VK_SUCCESS(err); |
| 6441 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6442 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6443 | pipe_ms_state_ci.sType = |
| 6444 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6445 | pipe_ms_state_ci.pNext = NULL; |
| 6446 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6447 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6448 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6449 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6450 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6451 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6452 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6453 | pipeline_layout_ci.pNext = NULL; |
| 6454 | pipeline_layout_ci.setLayoutCount = 1; |
| 6455 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6456 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6458 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6459 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6460 | ASSERT_VK_SUCCESS(err); |
| 6461 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6462 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6463 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6464 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6465 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6466 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6467 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6468 | VkPipelineObj pipe(m_device); |
| 6469 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6470 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6471 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6472 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6473 | pipe.SetViewport(m_viewports); |
| 6474 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6475 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6476 | |
| 6477 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6479 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6480 | // Don't care about actual data, just need to get to draw to flag error |
| 6481 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6482 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6483 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6484 | 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] | 6485 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6486 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6487 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6488 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6489 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6492 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6493 | #endif // DRAW_STATE_TESTS |
| 6494 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6495 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6496 | #if GTEST_IS_THREADSAFE |
| 6497 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6498 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6499 | VkEvent event; |
| 6500 | bool bailout; |
| 6501 | }; |
| 6502 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6503 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6504 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6506 | for (int i = 0; i < 10000; i++) { |
| 6507 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6508 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6509 | if (data->bailout) { |
| 6510 | break; |
| 6511 | } |
| 6512 | } |
| 6513 | return NULL; |
| 6514 | } |
| 6515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6516 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6517 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6518 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6519 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6520 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6521 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6523 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6524 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6525 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6526 | // Calls AllocateCommandBuffers |
| 6527 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6528 | |
| 6529 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6530 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6531 | |
| 6532 | VkEventCreateInfo event_info; |
| 6533 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6534 | VkResult err; |
| 6535 | |
| 6536 | memset(&event_info, 0, sizeof(event_info)); |
| 6537 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6538 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6539 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6540 | ASSERT_VK_SUCCESS(err); |
| 6541 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6542 | err = vkResetEvent(device(), event); |
| 6543 | ASSERT_VK_SUCCESS(err); |
| 6544 | |
| 6545 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6546 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6547 | data.event = event; |
| 6548 | data.bailout = false; |
| 6549 | m_errorMonitor->SetBailout(&data.bailout); |
| 6550 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6551 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6552 | // Add many entries to command buffer from this thread at the same time. |
| 6553 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6554 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6555 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6556 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6557 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6558 | m_errorMonitor->SetBailout(NULL); |
| 6559 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6560 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6561 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6562 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6563 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6564 | #endif // GTEST_IS_THREADSAFE |
| 6565 | #endif // THREADING_TESTS |
| 6566 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6567 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6568 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6569 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6570 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6571 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6572 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6573 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6574 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6575 | VkShaderModule module; |
| 6576 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6577 | struct icd_spv_header spv; |
| 6578 | |
| 6579 | spv.magic = ICD_SPV_MAGIC; |
| 6580 | spv.version = ICD_SPV_VERSION; |
| 6581 | spv.gen_magic = 0; |
| 6582 | |
| 6583 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6584 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6586 | moduleCreateInfo.codeSize = 4; |
| 6587 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6588 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6589 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6590 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6591 | } |
| 6592 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6594 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6595 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6596 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6597 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6598 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6599 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6600 | VkShaderModule module; |
| 6601 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6602 | struct icd_spv_header spv; |
| 6603 | |
| 6604 | spv.magic = ~ICD_SPV_MAGIC; |
| 6605 | spv.version = ICD_SPV_VERSION; |
| 6606 | spv.gen_magic = 0; |
| 6607 | |
| 6608 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6609 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6610 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6611 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6612 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6613 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6614 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6615 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6616 | } |
| 6617 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6618 | #if 0 |
| 6619 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6620 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6621 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6622 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6623 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6624 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6625 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6626 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6627 | VkShaderModule module; |
| 6628 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6629 | struct icd_spv_header spv; |
| 6630 | |
| 6631 | spv.magic = ICD_SPV_MAGIC; |
| 6632 | spv.version = ~ICD_SPV_VERSION; |
| 6633 | spv.gen_magic = 0; |
| 6634 | |
| 6635 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6636 | moduleCreateInfo.pNext = NULL; |
| 6637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6638 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6639 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6640 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6641 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6642 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6643 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6644 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6645 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6647 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6648 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6649 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6650 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6653 | |
| 6654 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6655 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6656 | "\n" |
| 6657 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6658 | "out gl_PerVertex {\n" |
| 6659 | " vec4 gl_Position;\n" |
| 6660 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6661 | "void main(){\n" |
| 6662 | " gl_Position = vec4(1);\n" |
| 6663 | " x = 0;\n" |
| 6664 | "}\n"; |
| 6665 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6666 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6667 | "\n" |
| 6668 | "layout(location=0) out vec4 color;\n" |
| 6669 | "void main(){\n" |
| 6670 | " color = vec4(1);\n" |
| 6671 | "}\n"; |
| 6672 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6673 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6674 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6675 | |
| 6676 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6677 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6678 | pipe.AddShader(&vs); |
| 6679 | pipe.AddShader(&fs); |
| 6680 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6681 | VkDescriptorSetObj descriptorSet(m_device); |
| 6682 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6683 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6684 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6685 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6686 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6687 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6688 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6689 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6691 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6692 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6693 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6694 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6695 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6696 | |
| 6697 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6698 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6699 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6700 | "out gl_PerVertex {\n" |
| 6701 | " vec4 gl_Position;\n" |
| 6702 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6703 | "void main(){\n" |
| 6704 | " gl_Position = vec4(1);\n" |
| 6705 | "}\n"; |
| 6706 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6707 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6708 | "\n" |
| 6709 | "layout(location=0) in float x;\n" |
| 6710 | "layout(location=0) out vec4 color;\n" |
| 6711 | "void main(){\n" |
| 6712 | " color = vec4(x);\n" |
| 6713 | "}\n"; |
| 6714 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6715 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6716 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6717 | |
| 6718 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6719 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6720 | pipe.AddShader(&vs); |
| 6721 | pipe.AddShader(&fs); |
| 6722 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6723 | VkDescriptorSetObj descriptorSet(m_device); |
| 6724 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6725 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6726 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6727 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6728 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6729 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6730 | } |
| 6731 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6732 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6733 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6734 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6735 | |
| 6736 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6737 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6738 | |
| 6739 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6740 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6741 | "\n" |
| 6742 | "out gl_PerVertex {\n" |
| 6743 | " vec4 gl_Position;\n" |
| 6744 | "};\n" |
| 6745 | "void main(){\n" |
| 6746 | " gl_Position = vec4(1);\n" |
| 6747 | "}\n"; |
| 6748 | char const *fsSource = |
| 6749 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6750 | "\n" |
| 6751 | "in block { layout(location=0) float x; } ins;\n" |
| 6752 | "layout(location=0) out vec4 color;\n" |
| 6753 | "void main(){\n" |
| 6754 | " color = vec4(ins.x);\n" |
| 6755 | "}\n"; |
| 6756 | |
| 6757 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6758 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6759 | |
| 6760 | VkPipelineObj pipe(m_device); |
| 6761 | pipe.AddColorAttachment(); |
| 6762 | pipe.AddShader(&vs); |
| 6763 | pipe.AddShader(&fs); |
| 6764 | |
| 6765 | VkDescriptorSetObj descriptorSet(m_device); |
| 6766 | descriptorSet.AppendDummy(); |
| 6767 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6768 | |
| 6769 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6770 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6771 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6772 | } |
| 6773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6774 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6775 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6776 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6777 | "output arr[2] of float32' vs 'ptr to " |
| 6778 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6779 | |
| 6780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6781 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6782 | |
| 6783 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6784 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6785 | "\n" |
| 6786 | "layout(location=0) out float x[2];\n" |
| 6787 | "out gl_PerVertex {\n" |
| 6788 | " vec4 gl_Position;\n" |
| 6789 | "};\n" |
| 6790 | "void main(){\n" |
| 6791 | " x[0] = 0; x[1] = 0;\n" |
| 6792 | " gl_Position = vec4(1);\n" |
| 6793 | "}\n"; |
| 6794 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6795 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6796 | "\n" |
| 6797 | "layout(location=0) in float x[3];\n" |
| 6798 | "layout(location=0) out vec4 color;\n" |
| 6799 | "void main(){\n" |
| 6800 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 6801 | "}\n"; |
| 6802 | |
| 6803 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6804 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6805 | |
| 6806 | VkPipelineObj pipe(m_device); |
| 6807 | pipe.AddColorAttachment(); |
| 6808 | pipe.AddShader(&vs); |
| 6809 | pipe.AddShader(&fs); |
| 6810 | |
| 6811 | VkDescriptorSetObj descriptorSet(m_device); |
| 6812 | descriptorSet.AppendDummy(); |
| 6813 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6814 | |
| 6815 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6816 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6817 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6818 | } |
| 6819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6820 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6821 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6822 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6823 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6825 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6826 | |
| 6827 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6828 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6829 | "\n" |
| 6830 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6831 | "out gl_PerVertex {\n" |
| 6832 | " vec4 gl_Position;\n" |
| 6833 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6834 | "void main(){\n" |
| 6835 | " x = 0;\n" |
| 6836 | " gl_Position = vec4(1);\n" |
| 6837 | "}\n"; |
| 6838 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6839 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6840 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6841 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6842 | "layout(location=0) out vec4 color;\n" |
| 6843 | "void main(){\n" |
| 6844 | " color = vec4(x);\n" |
| 6845 | "}\n"; |
| 6846 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6847 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6848 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6849 | |
| 6850 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6851 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6852 | pipe.AddShader(&vs); |
| 6853 | pipe.AddShader(&fs); |
| 6854 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6855 | VkDescriptorSetObj descriptorSet(m_device); |
| 6856 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6857 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6858 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6859 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6860 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6861 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6862 | } |
| 6863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6864 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6865 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6866 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6867 | |
| 6868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6869 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6870 | |
| 6871 | char const *vsSource = |
| 6872 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6873 | "\n" |
| 6874 | "out block { layout(location=0) int x; } outs;\n" |
| 6875 | "out gl_PerVertex {\n" |
| 6876 | " vec4 gl_Position;\n" |
| 6877 | "};\n" |
| 6878 | "void main(){\n" |
| 6879 | " outs.x = 0;\n" |
| 6880 | " gl_Position = vec4(1);\n" |
| 6881 | "}\n"; |
| 6882 | char const *fsSource = |
| 6883 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6884 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6885 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6886 | "layout(location=0) out vec4 color;\n" |
| 6887 | "void main(){\n" |
| 6888 | " color = vec4(ins.x);\n" |
| 6889 | "}\n"; |
| 6890 | |
| 6891 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6892 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6893 | |
| 6894 | VkPipelineObj pipe(m_device); |
| 6895 | pipe.AddColorAttachment(); |
| 6896 | pipe.AddShader(&vs); |
| 6897 | pipe.AddShader(&fs); |
| 6898 | |
| 6899 | VkDescriptorSetObj descriptorSet(m_device); |
| 6900 | descriptorSet.AppendDummy(); |
| 6901 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6902 | |
| 6903 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6904 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6905 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6906 | } |
| 6907 | |
| 6908 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 6909 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6910 | "location 0.0 which is not written by vertex shader"); |
| 6911 | |
| 6912 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6913 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6914 | |
| 6915 | char const *vsSource = |
| 6916 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6917 | "\n" |
| 6918 | "out block { layout(location=1) float x; } outs;\n" |
| 6919 | "out gl_PerVertex {\n" |
| 6920 | " vec4 gl_Position;\n" |
| 6921 | "};\n" |
| 6922 | "void main(){\n" |
| 6923 | " outs.x = 0;\n" |
| 6924 | " gl_Position = vec4(1);\n" |
| 6925 | "}\n"; |
| 6926 | char const *fsSource = |
| 6927 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6928 | "\n" |
| 6929 | "in block { layout(location=0) float x; } ins;\n" |
| 6930 | "layout(location=0) out vec4 color;\n" |
| 6931 | "void main(){\n" |
| 6932 | " color = vec4(ins.x);\n" |
| 6933 | "}\n"; |
| 6934 | |
| 6935 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6936 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6937 | |
| 6938 | VkPipelineObj pipe(m_device); |
| 6939 | pipe.AddColorAttachment(); |
| 6940 | pipe.AddShader(&vs); |
| 6941 | pipe.AddShader(&fs); |
| 6942 | |
| 6943 | VkDescriptorSetObj descriptorSet(m_device); |
| 6944 | descriptorSet.AppendDummy(); |
| 6945 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6946 | |
| 6947 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6948 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6949 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6950 | } |
| 6951 | |
| 6952 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 6953 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6954 | "location 0.1 which is not written by vertex shader"); |
| 6955 | |
| 6956 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6957 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6958 | |
| 6959 | char const *vsSource = |
| 6960 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6961 | "\n" |
| 6962 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 6963 | "out gl_PerVertex {\n" |
| 6964 | " vec4 gl_Position;\n" |
| 6965 | "};\n" |
| 6966 | "void main(){\n" |
| 6967 | " outs.x = 0;\n" |
| 6968 | " gl_Position = vec4(1);\n" |
| 6969 | "}\n"; |
| 6970 | char const *fsSource = |
| 6971 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6972 | "\n" |
| 6973 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 6974 | "layout(location=0) out vec4 color;\n" |
| 6975 | "void main(){\n" |
| 6976 | " color = vec4(ins.x);\n" |
| 6977 | "}\n"; |
| 6978 | |
| 6979 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6980 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6981 | |
| 6982 | VkPipelineObj pipe(m_device); |
| 6983 | pipe.AddColorAttachment(); |
| 6984 | pipe.AddShader(&vs); |
| 6985 | pipe.AddShader(&fs); |
| 6986 | |
| 6987 | VkDescriptorSetObj descriptorSet(m_device); |
| 6988 | descriptorSet.AppendDummy(); |
| 6989 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6990 | |
| 6991 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6992 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6993 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6994 | } |
| 6995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6996 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6998 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6999 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7001 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7002 | |
| 7003 | VkVertexInputBindingDescription input_binding; |
| 7004 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7005 | |
| 7006 | VkVertexInputAttributeDescription input_attrib; |
| 7007 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7008 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7009 | |
| 7010 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7011 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7012 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7013 | "out gl_PerVertex {\n" |
| 7014 | " vec4 gl_Position;\n" |
| 7015 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7016 | "void main(){\n" |
| 7017 | " gl_Position = vec4(1);\n" |
| 7018 | "}\n"; |
| 7019 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7020 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7021 | "\n" |
| 7022 | "layout(location=0) out vec4 color;\n" |
| 7023 | "void main(){\n" |
| 7024 | " color = vec4(1);\n" |
| 7025 | "}\n"; |
| 7026 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7027 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7028 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7029 | |
| 7030 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7031 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7032 | pipe.AddShader(&vs); |
| 7033 | pipe.AddShader(&fs); |
| 7034 | |
| 7035 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7036 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7037 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7038 | VkDescriptorSetObj descriptorSet(m_device); |
| 7039 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7040 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7041 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7042 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7043 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7044 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7045 | } |
| 7046 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7047 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7048 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7049 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7050 | |
| 7051 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7052 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7053 | |
| 7054 | VkVertexInputBindingDescription input_binding; |
| 7055 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7056 | |
| 7057 | VkVertexInputAttributeDescription input_attrib; |
| 7058 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7059 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7060 | |
| 7061 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7062 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7063 | "\n" |
| 7064 | "layout(location=1) in float x;\n" |
| 7065 | "out gl_PerVertex {\n" |
| 7066 | " vec4 gl_Position;\n" |
| 7067 | "};\n" |
| 7068 | "void main(){\n" |
| 7069 | " gl_Position = vec4(x);\n" |
| 7070 | "}\n"; |
| 7071 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7072 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7073 | "\n" |
| 7074 | "layout(location=0) out vec4 color;\n" |
| 7075 | "void main(){\n" |
| 7076 | " color = vec4(1);\n" |
| 7077 | "}\n"; |
| 7078 | |
| 7079 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7080 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7081 | |
| 7082 | VkPipelineObj pipe(m_device); |
| 7083 | pipe.AddColorAttachment(); |
| 7084 | pipe.AddShader(&vs); |
| 7085 | pipe.AddShader(&fs); |
| 7086 | |
| 7087 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7088 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7089 | |
| 7090 | VkDescriptorSetObj descriptorSet(m_device); |
| 7091 | descriptorSet.AppendDummy(); |
| 7092 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7093 | |
| 7094 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7096 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7097 | } |
| 7098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7099 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7100 | m_errorMonitor->SetDesiredFailureMsg( |
| 7101 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7102 | "VS consumes input at location 0 but not provided"); |
| 7103 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7106 | |
| 7107 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7108 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7109 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7110 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7111 | "out gl_PerVertex {\n" |
| 7112 | " vec4 gl_Position;\n" |
| 7113 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7114 | "void main(){\n" |
| 7115 | " gl_Position = x;\n" |
| 7116 | "}\n"; |
| 7117 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7118 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7119 | "\n" |
| 7120 | "layout(location=0) out vec4 color;\n" |
| 7121 | "void main(){\n" |
| 7122 | " color = vec4(1);\n" |
| 7123 | "}\n"; |
| 7124 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7125 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7126 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7127 | |
| 7128 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7129 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7130 | pipe.AddShader(&vs); |
| 7131 | pipe.AddShader(&fs); |
| 7132 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7133 | VkDescriptorSetObj descriptorSet(m_device); |
| 7134 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7135 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7136 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7137 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7138 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7139 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7140 | } |
| 7141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7142 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7143 | m_errorMonitor->SetDesiredFailureMsg( |
| 7144 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7145 | "location 0 does not match VS input type"); |
| 7146 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7147 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7148 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7149 | |
| 7150 | VkVertexInputBindingDescription input_binding; |
| 7151 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7152 | |
| 7153 | VkVertexInputAttributeDescription input_attrib; |
| 7154 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7155 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7156 | |
| 7157 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7158 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7159 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7160 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7161 | "out gl_PerVertex {\n" |
| 7162 | " vec4 gl_Position;\n" |
| 7163 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7164 | "void main(){\n" |
| 7165 | " gl_Position = vec4(x);\n" |
| 7166 | "}\n"; |
| 7167 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7168 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7169 | "\n" |
| 7170 | "layout(location=0) out vec4 color;\n" |
| 7171 | "void main(){\n" |
| 7172 | " color = vec4(1);\n" |
| 7173 | "}\n"; |
| 7174 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7175 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7176 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7177 | |
| 7178 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7179 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7180 | pipe.AddShader(&vs); |
| 7181 | pipe.AddShader(&fs); |
| 7182 | |
| 7183 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7184 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7185 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7186 | VkDescriptorSetObj descriptorSet(m_device); |
| 7187 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7188 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7189 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7190 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7191 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7192 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7193 | } |
| 7194 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7195 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7196 | m_errorMonitor->SetDesiredFailureMsg( |
| 7197 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7198 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7199 | |
| 7200 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7201 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7202 | |
| 7203 | char const *vsSource = |
| 7204 | "#version 450\n" |
| 7205 | "\n" |
| 7206 | "out gl_PerVertex {\n" |
| 7207 | " vec4 gl_Position;\n" |
| 7208 | "};\n" |
| 7209 | "void main(){\n" |
| 7210 | " gl_Position = vec4(1);\n" |
| 7211 | "}\n"; |
| 7212 | char const *fsSource = |
| 7213 | "#version 450\n" |
| 7214 | "\n" |
| 7215 | "layout(location=0) out vec4 color;\n" |
| 7216 | "void main(){\n" |
| 7217 | " color = vec4(1);\n" |
| 7218 | "}\n"; |
| 7219 | |
| 7220 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7221 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7222 | |
| 7223 | VkPipelineObj pipe(m_device); |
| 7224 | pipe.AddColorAttachment(); |
| 7225 | pipe.AddShader(&vs); |
| 7226 | pipe.AddShader(&vs); |
| 7227 | pipe.AddShader(&fs); |
| 7228 | |
| 7229 | VkDescriptorSetObj descriptorSet(m_device); |
| 7230 | descriptorSet.AppendDummy(); |
| 7231 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7232 | |
| 7233 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7234 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7235 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7236 | } |
| 7237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7238 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7239 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7240 | |
| 7241 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7242 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7243 | |
| 7244 | VkVertexInputBindingDescription input_binding; |
| 7245 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7246 | |
| 7247 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7248 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7249 | |
| 7250 | for (int i = 0; i < 2; i++) { |
| 7251 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7252 | input_attribs[i].location = i; |
| 7253 | } |
| 7254 | |
| 7255 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7256 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7257 | "\n" |
| 7258 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7259 | "out gl_PerVertex {\n" |
| 7260 | " vec4 gl_Position;\n" |
| 7261 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7262 | "void main(){\n" |
| 7263 | " gl_Position = x[0] + x[1];\n" |
| 7264 | "}\n"; |
| 7265 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7266 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7267 | "\n" |
| 7268 | "layout(location=0) out vec4 color;\n" |
| 7269 | "void main(){\n" |
| 7270 | " color = vec4(1);\n" |
| 7271 | "}\n"; |
| 7272 | |
| 7273 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7274 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7275 | |
| 7276 | VkPipelineObj pipe(m_device); |
| 7277 | pipe.AddColorAttachment(); |
| 7278 | pipe.AddShader(&vs); |
| 7279 | pipe.AddShader(&fs); |
| 7280 | |
| 7281 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7282 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7283 | |
| 7284 | VkDescriptorSetObj descriptorSet(m_device); |
| 7285 | descriptorSet.AppendDummy(); |
| 7286 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7287 | |
| 7288 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7289 | |
| 7290 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7291 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7292 | } |
| 7293 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7294 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7295 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7296 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7297 | |
| 7298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7299 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7300 | |
| 7301 | VkVertexInputBindingDescription input_binding; |
| 7302 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7303 | |
| 7304 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7305 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7306 | |
| 7307 | for (int i = 0; i < 2; i++) { |
| 7308 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7309 | input_attribs[i].location = i; |
| 7310 | } |
| 7311 | |
| 7312 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7313 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7314 | "\n" |
| 7315 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7316 | "out gl_PerVertex {\n" |
| 7317 | " vec4 gl_Position;\n" |
| 7318 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7319 | "void main(){\n" |
| 7320 | " gl_Position = x[0] + x[1];\n" |
| 7321 | "}\n"; |
| 7322 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7323 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7324 | "\n" |
| 7325 | "layout(location=0) out vec4 color;\n" |
| 7326 | "void main(){\n" |
| 7327 | " color = vec4(1);\n" |
| 7328 | "}\n"; |
| 7329 | |
| 7330 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7331 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7332 | |
| 7333 | VkPipelineObj pipe(m_device); |
| 7334 | pipe.AddColorAttachment(); |
| 7335 | pipe.AddShader(&vs); |
| 7336 | pipe.AddShader(&fs); |
| 7337 | |
| 7338 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7339 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7340 | |
| 7341 | VkDescriptorSetObj descriptorSet(m_device); |
| 7342 | descriptorSet.AppendDummy(); |
| 7343 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7344 | |
| 7345 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7346 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7347 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7348 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7349 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7350 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7351 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7352 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7353 | |
| 7354 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7355 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7356 | |
| 7357 | char const *vsSource = |
| 7358 | "#version 450\n" |
| 7359 | "out gl_PerVertex {\n" |
| 7360 | " vec4 gl_Position;\n" |
| 7361 | "};\n" |
| 7362 | "void main(){\n" |
| 7363 | " gl_Position = vec4(0);\n" |
| 7364 | "}\n"; |
| 7365 | char const *fsSource = |
| 7366 | "#version 450\n" |
| 7367 | "\n" |
| 7368 | "layout(location=0) out vec4 color;\n" |
| 7369 | "void main(){\n" |
| 7370 | " color = vec4(1);\n" |
| 7371 | "}\n"; |
| 7372 | |
| 7373 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7374 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7375 | |
| 7376 | VkPipelineObj pipe(m_device); |
| 7377 | pipe.AddColorAttachment(); |
| 7378 | pipe.AddShader(&vs); |
| 7379 | pipe.AddShader(&fs); |
| 7380 | |
| 7381 | VkDescriptorSetObj descriptorSet(m_device); |
| 7382 | descriptorSet.AppendDummy(); |
| 7383 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7384 | |
| 7385 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7386 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7387 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7388 | } |
| 7389 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7390 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7391 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7392 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7393 | |
| 7394 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7395 | |
| 7396 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7397 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7398 | |
| 7399 | char const *vsSource = |
| 7400 | "#version 450\n" |
| 7401 | "out gl_PerVertex {\n" |
| 7402 | " vec4 gl_Position;\n" |
| 7403 | "};\n" |
| 7404 | "layout(location=0) out vec3 x;\n" |
| 7405 | "layout(location=1) out ivec3 y;\n" |
| 7406 | "layout(location=2) out vec3 z;\n" |
| 7407 | "void main(){\n" |
| 7408 | " gl_Position = vec4(0);\n" |
| 7409 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7410 | "}\n"; |
| 7411 | char const *fsSource = |
| 7412 | "#version 450\n" |
| 7413 | "\n" |
| 7414 | "layout(location=0) out vec4 color;\n" |
| 7415 | "layout(location=0) in float x;\n" |
| 7416 | "layout(location=1) flat in int y;\n" |
| 7417 | "layout(location=2) in vec2 z;\n" |
| 7418 | "void main(){\n" |
| 7419 | " color = vec4(1 + x + y + z.x);\n" |
| 7420 | "}\n"; |
| 7421 | |
| 7422 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7423 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7424 | |
| 7425 | VkPipelineObj pipe(m_device); |
| 7426 | pipe.AddColorAttachment(); |
| 7427 | pipe.AddShader(&vs); |
| 7428 | pipe.AddShader(&fs); |
| 7429 | |
| 7430 | VkDescriptorSetObj descriptorSet(m_device); |
| 7431 | descriptorSet.AppendDummy(); |
| 7432 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7433 | |
| 7434 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7435 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7436 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7437 | } |
| 7438 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7439 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7440 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7441 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7442 | |
| 7443 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7444 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7445 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7446 | if (!m_device->phy().features().tessellationShader) { |
| 7447 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7448 | return; |
| 7449 | } |
| 7450 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7451 | char const *vsSource = |
| 7452 | "#version 450\n" |
| 7453 | "void main(){}\n"; |
| 7454 | char const *tcsSource = |
| 7455 | "#version 450\n" |
| 7456 | "layout(location=0) out int x[];\n" |
| 7457 | "layout(vertices=3) out;\n" |
| 7458 | "void main(){\n" |
| 7459 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7460 | " gl_TessLevelInner[0] = 1;\n" |
| 7461 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7462 | "}\n"; |
| 7463 | char const *tesSource = |
| 7464 | "#version 450\n" |
| 7465 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7466 | "layout(location=0) in int x[];\n" |
| 7467 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7468 | "void main(){\n" |
| 7469 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7470 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7471 | "}\n"; |
| 7472 | char const *fsSource = |
| 7473 | "#version 450\n" |
| 7474 | "layout(location=0) out vec4 color;\n" |
| 7475 | "void main(){\n" |
| 7476 | " color = vec4(1);\n" |
| 7477 | "}\n"; |
| 7478 | |
| 7479 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7480 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7481 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7482 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7483 | |
| 7484 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7485 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7486 | nullptr, |
| 7487 | 0, |
| 7488 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7489 | VK_FALSE}; |
| 7490 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7491 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7492 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7493 | nullptr, |
| 7494 | 0, |
| 7495 | 3}; |
| 7496 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7497 | VkPipelineObj pipe(m_device); |
| 7498 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7499 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7500 | pipe.AddColorAttachment(); |
| 7501 | pipe.AddShader(&vs); |
| 7502 | pipe.AddShader(&tcs); |
| 7503 | pipe.AddShader(&tes); |
| 7504 | pipe.AddShader(&fs); |
| 7505 | |
| 7506 | VkDescriptorSetObj descriptorSet(m_device); |
| 7507 | descriptorSet.AppendDummy(); |
| 7508 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7509 | |
| 7510 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7511 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7512 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7513 | } |
| 7514 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7515 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7516 | { |
| 7517 | m_errorMonitor->ExpectSuccess(); |
| 7518 | |
| 7519 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7520 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7521 | |
| 7522 | if (!m_device->phy().features().geometryShader) { |
| 7523 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7524 | return; |
| 7525 | } |
| 7526 | |
| 7527 | char const *vsSource = |
| 7528 | "#version 450\n" |
| 7529 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7530 | "void main(){\n" |
| 7531 | " vs_out.x = vec4(1);\n" |
| 7532 | "}\n"; |
| 7533 | char const *gsSource = |
| 7534 | "#version 450\n" |
| 7535 | "layout(triangles) in;\n" |
| 7536 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7537 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7538 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7539 | "void main() {\n" |
| 7540 | " gl_Position = gs_in[0].x;\n" |
| 7541 | " EmitVertex();\n" |
| 7542 | "}\n"; |
| 7543 | char const *fsSource = |
| 7544 | "#version 450\n" |
| 7545 | "layout(location=0) out vec4 color;\n" |
| 7546 | "void main(){\n" |
| 7547 | " color = vec4(1);\n" |
| 7548 | "}\n"; |
| 7549 | |
| 7550 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7551 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7552 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7553 | |
| 7554 | VkPipelineObj pipe(m_device); |
| 7555 | pipe.AddColorAttachment(); |
| 7556 | pipe.AddShader(&vs); |
| 7557 | pipe.AddShader(&gs); |
| 7558 | pipe.AddShader(&fs); |
| 7559 | |
| 7560 | VkDescriptorSetObj descriptorSet(m_device); |
| 7561 | descriptorSet.AppendDummy(); |
| 7562 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7563 | |
| 7564 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7565 | |
| 7566 | m_errorMonitor->VerifyNotFound(); |
| 7567 | } |
| 7568 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7569 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7570 | { |
| 7571 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7572 | "is per-vertex in tessellation control shader stage " |
| 7573 | "but per-patch in tessellation evaluation shader stage"); |
| 7574 | |
| 7575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7576 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7577 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7578 | if (!m_device->phy().features().tessellationShader) { |
| 7579 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7580 | return; |
| 7581 | } |
| 7582 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7583 | char const *vsSource = |
| 7584 | "#version 450\n" |
| 7585 | "void main(){}\n"; |
| 7586 | char const *tcsSource = |
| 7587 | "#version 450\n" |
| 7588 | "layout(location=0) out int x[];\n" |
| 7589 | "layout(vertices=3) out;\n" |
| 7590 | "void main(){\n" |
| 7591 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7592 | " gl_TessLevelInner[0] = 1;\n" |
| 7593 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7594 | "}\n"; |
| 7595 | char const *tesSource = |
| 7596 | "#version 450\n" |
| 7597 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7598 | "layout(location=0) patch in int x;\n" |
| 7599 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7600 | "void main(){\n" |
| 7601 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7602 | " gl_Position.w = x;\n" |
| 7603 | "}\n"; |
| 7604 | char const *fsSource = |
| 7605 | "#version 450\n" |
| 7606 | "layout(location=0) out vec4 color;\n" |
| 7607 | "void main(){\n" |
| 7608 | " color = vec4(1);\n" |
| 7609 | "}\n"; |
| 7610 | |
| 7611 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7612 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7613 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7614 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7615 | |
| 7616 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7617 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7618 | nullptr, |
| 7619 | 0, |
| 7620 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7621 | VK_FALSE}; |
| 7622 | |
| 7623 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7624 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7625 | nullptr, |
| 7626 | 0, |
| 7627 | 3}; |
| 7628 | |
| 7629 | VkPipelineObj pipe(m_device); |
| 7630 | pipe.SetInputAssembly(&iasci); |
| 7631 | pipe.SetTessellation(&tsci); |
| 7632 | pipe.AddColorAttachment(); |
| 7633 | pipe.AddShader(&vs); |
| 7634 | pipe.AddShader(&tcs); |
| 7635 | pipe.AddShader(&tes); |
| 7636 | pipe.AddShader(&fs); |
| 7637 | |
| 7638 | VkDescriptorSetObj descriptorSet(m_device); |
| 7639 | descriptorSet.AppendDummy(); |
| 7640 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7641 | |
| 7642 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7643 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7644 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7645 | } |
| 7646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7647 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7648 | m_errorMonitor->SetDesiredFailureMsg( |
| 7649 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7650 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7651 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7653 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7654 | |
| 7655 | /* Two binding descriptions for binding 0 */ |
| 7656 | VkVertexInputBindingDescription input_bindings[2]; |
| 7657 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7658 | |
| 7659 | VkVertexInputAttributeDescription input_attrib; |
| 7660 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7661 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7662 | |
| 7663 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7664 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7665 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7666 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7667 | "out gl_PerVertex {\n" |
| 7668 | " vec4 gl_Position;\n" |
| 7669 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7670 | "void main(){\n" |
| 7671 | " gl_Position = vec4(x);\n" |
| 7672 | "}\n"; |
| 7673 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7674 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7675 | "\n" |
| 7676 | "layout(location=0) out vec4 color;\n" |
| 7677 | "void main(){\n" |
| 7678 | " color = vec4(1);\n" |
| 7679 | "}\n"; |
| 7680 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7681 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7682 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7683 | |
| 7684 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7685 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7686 | pipe.AddShader(&vs); |
| 7687 | pipe.AddShader(&fs); |
| 7688 | |
| 7689 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7690 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7691 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7692 | VkDescriptorSetObj descriptorSet(m_device); |
| 7693 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7694 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7695 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7696 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7697 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7698 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7699 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7700 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7701 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7702 | m_errorMonitor->ExpectSuccess(); |
| 7703 | |
| 7704 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7705 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7706 | |
| 7707 | if (!m_device->phy().features().tessellationShader) { |
| 7708 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7709 | return; |
| 7710 | } |
| 7711 | |
| 7712 | VkVertexInputBindingDescription input_bindings[1]; |
| 7713 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7714 | |
| 7715 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7716 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7717 | input_attribs[0].location = 0; |
| 7718 | input_attribs[0].offset = 0; |
| 7719 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7720 | input_attribs[1].location = 2; |
| 7721 | input_attribs[1].offset = 32; |
| 7722 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7723 | input_attribs[2].location = 4; |
| 7724 | input_attribs[2].offset = 64; |
| 7725 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7726 | input_attribs[3].location = 6; |
| 7727 | input_attribs[3].offset = 96; |
| 7728 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7729 | |
| 7730 | char const *vsSource = |
| 7731 | "#version 450\n" |
| 7732 | "\n" |
| 7733 | "layout(location=0) in dmat4 x;\n" |
| 7734 | "out gl_PerVertex {\n" |
| 7735 | " vec4 gl_Position;\n" |
| 7736 | "};\n" |
| 7737 | "void main(){\n" |
| 7738 | " gl_Position = vec4(x[0][0]);\n" |
| 7739 | "}\n"; |
| 7740 | char const *fsSource = |
| 7741 | "#version 450\n" |
| 7742 | "\n" |
| 7743 | "layout(location=0) out vec4 color;\n" |
| 7744 | "void main(){\n" |
| 7745 | " color = vec4(1);\n" |
| 7746 | "}\n"; |
| 7747 | |
| 7748 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7749 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7750 | |
| 7751 | VkPipelineObj pipe(m_device); |
| 7752 | pipe.AddColorAttachment(); |
| 7753 | pipe.AddShader(&vs); |
| 7754 | pipe.AddShader(&fs); |
| 7755 | |
| 7756 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 7757 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 7758 | |
| 7759 | VkDescriptorSetObj descriptorSet(m_device); |
| 7760 | descriptorSet.AppendDummy(); |
| 7761 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7762 | |
| 7763 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7764 | |
| 7765 | m_errorMonitor->VerifyNotFound(); |
| 7766 | } |
| 7767 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7768 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7769 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7770 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7771 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7772 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7773 | |
| 7774 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7775 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7776 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7777 | "out gl_PerVertex {\n" |
| 7778 | " vec4 gl_Position;\n" |
| 7779 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7780 | "void main(){\n" |
| 7781 | " gl_Position = vec4(1);\n" |
| 7782 | "}\n"; |
| 7783 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7784 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7785 | "\n" |
| 7786 | "void main(){\n" |
| 7787 | "}\n"; |
| 7788 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7789 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7790 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7791 | |
| 7792 | VkPipelineObj pipe(m_device); |
| 7793 | pipe.AddShader(&vs); |
| 7794 | pipe.AddShader(&fs); |
| 7795 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7796 | /* set up CB 0, not written */ |
| 7797 | pipe.AddColorAttachment(); |
| 7798 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7799 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7800 | VkDescriptorSetObj descriptorSet(m_device); |
| 7801 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7802 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7803 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7804 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7805 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7806 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7807 | } |
| 7808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7809 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7810 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7811 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7812 | "FS writes to output location 1 with no matching attachment"); |
| 7813 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7814 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7815 | |
| 7816 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7817 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7818 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7819 | "out gl_PerVertex {\n" |
| 7820 | " vec4 gl_Position;\n" |
| 7821 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7822 | "void main(){\n" |
| 7823 | " gl_Position = vec4(1);\n" |
| 7824 | "}\n"; |
| 7825 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7826 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7827 | "\n" |
| 7828 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7829 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7830 | "void main(){\n" |
| 7831 | " x = vec4(1);\n" |
| 7832 | " y = vec4(1);\n" |
| 7833 | "}\n"; |
| 7834 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7835 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7836 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7837 | |
| 7838 | VkPipelineObj pipe(m_device); |
| 7839 | pipe.AddShader(&vs); |
| 7840 | pipe.AddShader(&fs); |
| 7841 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7842 | /* set up CB 0, not written */ |
| 7843 | pipe.AddColorAttachment(); |
| 7844 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7845 | /* FS writes CB 1, but we don't configure it */ |
| 7846 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7847 | VkDescriptorSetObj descriptorSet(m_device); |
| 7848 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7849 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7850 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7851 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7852 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7853 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7854 | } |
| 7855 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7856 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7857 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7858 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7859 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7860 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7861 | |
| 7862 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7863 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7864 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7865 | "out gl_PerVertex {\n" |
| 7866 | " vec4 gl_Position;\n" |
| 7867 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7868 | "void main(){\n" |
| 7869 | " gl_Position = vec4(1);\n" |
| 7870 | "}\n"; |
| 7871 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7872 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7873 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7874 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7875 | "void main(){\n" |
| 7876 | " x = ivec4(1);\n" |
| 7877 | "}\n"; |
| 7878 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7879 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7880 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7881 | |
| 7882 | VkPipelineObj pipe(m_device); |
| 7883 | pipe.AddShader(&vs); |
| 7884 | pipe.AddShader(&fs); |
| 7885 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7886 | /* set up CB 0; type is UNORM by default */ |
| 7887 | pipe.AddColorAttachment(); |
| 7888 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7889 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7890 | VkDescriptorSetObj descriptorSet(m_device); |
| 7891 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7892 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7893 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7894 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7895 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7896 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7897 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 7898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7899 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7900 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7901 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7902 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7903 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7904 | |
| 7905 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7906 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7907 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7908 | "out gl_PerVertex {\n" |
| 7909 | " vec4 gl_Position;\n" |
| 7910 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7911 | "void main(){\n" |
| 7912 | " gl_Position = vec4(1);\n" |
| 7913 | "}\n"; |
| 7914 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7915 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7916 | "\n" |
| 7917 | "layout(location=0) out vec4 x;\n" |
| 7918 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 7919 | "void main(){\n" |
| 7920 | " x = vec4(bar.y);\n" |
| 7921 | "}\n"; |
| 7922 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7923 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7924 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7925 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7926 | VkPipelineObj pipe(m_device); |
| 7927 | pipe.AddShader(&vs); |
| 7928 | pipe.AddShader(&fs); |
| 7929 | |
| 7930 | /* set up CB 0; type is UNORM by default */ |
| 7931 | pipe.AddColorAttachment(); |
| 7932 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7933 | |
| 7934 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7935 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7936 | |
| 7937 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7938 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7939 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7940 | } |
| 7941 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7942 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 7943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7944 | "not declared in layout"); |
| 7945 | |
| 7946 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7947 | |
| 7948 | char const *vsSource = |
| 7949 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7950 | "\n" |
| 7951 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 7952 | "out gl_PerVertex {\n" |
| 7953 | " vec4 gl_Position;\n" |
| 7954 | "};\n" |
| 7955 | "void main(){\n" |
| 7956 | " gl_Position = vec4(consts.x);\n" |
| 7957 | "}\n"; |
| 7958 | char const *fsSource = |
| 7959 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7960 | "\n" |
| 7961 | "layout(location=0) out vec4 x;\n" |
| 7962 | "void main(){\n" |
| 7963 | " x = vec4(1);\n" |
| 7964 | "}\n"; |
| 7965 | |
| 7966 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7967 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7968 | |
| 7969 | VkPipelineObj pipe(m_device); |
| 7970 | pipe.AddShader(&vs); |
| 7971 | pipe.AddShader(&fs); |
| 7972 | |
| 7973 | /* set up CB 0; type is UNORM by default */ |
| 7974 | pipe.AddColorAttachment(); |
| 7975 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7976 | |
| 7977 | VkDescriptorSetObj descriptorSet(m_device); |
| 7978 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7979 | |
| 7980 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7981 | |
| 7982 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7983 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7984 | } |
| 7985 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7986 | #endif // SHADER_CHECKER_TESTS |
| 7987 | |
| 7988 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7989 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7990 | m_errorMonitor->SetDesiredFailureMsg( |
| 7991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7992 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7993 | |
| 7994 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7995 | |
| 7996 | // Create an image |
| 7997 | VkImage image; |
| 7998 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7999 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8000 | const int32_t tex_width = 32; |
| 8001 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8002 | |
| 8003 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8004 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8005 | image_create_info.pNext = NULL; |
| 8006 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8007 | image_create_info.format = tex_format; |
| 8008 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8009 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8010 | image_create_info.extent.depth = 1; |
| 8011 | image_create_info.mipLevels = 1; |
| 8012 | image_create_info.arrayLayers = 1; |
| 8013 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8014 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8015 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8016 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8017 | |
| 8018 | // Introduce error by sending down a bogus width extent |
| 8019 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8020 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8021 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8022 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8023 | } |
| 8024 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8025 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8026 | m_errorMonitor->SetDesiredFailureMsg( |
| 8027 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8028 | "CreateImage extents is 0 for at least one required dimension"); |
| 8029 | |
| 8030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8031 | |
| 8032 | // Create an image |
| 8033 | VkImage image; |
| 8034 | |
| 8035 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8036 | const int32_t tex_width = 32; |
| 8037 | const int32_t tex_height = 32; |
| 8038 | |
| 8039 | VkImageCreateInfo image_create_info = {}; |
| 8040 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8041 | image_create_info.pNext = NULL; |
| 8042 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8043 | image_create_info.format = tex_format; |
| 8044 | image_create_info.extent.width = tex_width; |
| 8045 | image_create_info.extent.height = tex_height; |
| 8046 | image_create_info.extent.depth = 1; |
| 8047 | image_create_info.mipLevels = 1; |
| 8048 | image_create_info.arrayLayers = 1; |
| 8049 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8050 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8051 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8052 | image_create_info.flags = 0; |
| 8053 | |
| 8054 | // Introduce error by sending down a bogus width extent |
| 8055 | image_create_info.extent.width = 0; |
| 8056 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8057 | |
| 8058 | m_errorMonitor->VerifyFound(); |
| 8059 | } |
| 8060 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8061 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8062 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8063 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8064 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8065 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8066 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8067 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8068 | |
| 8069 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8070 | vk_testing::Buffer buffer; |
| 8071 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8072 | |
| 8073 | BeginCommandBuffer(); |
| 8074 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8075 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8076 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8077 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8078 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8079 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8080 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8081 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8082 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8083 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8084 | EndCommandBuffer(); |
| 8085 | } |
| 8086 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8087 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8088 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8089 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8090 | |
| 8091 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8092 | |
| 8093 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8094 | vk_testing::Buffer buffer; |
| 8095 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8096 | |
| 8097 | BeginCommandBuffer(); |
| 8098 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8099 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8100 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8101 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8102 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8103 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8104 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8105 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8106 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8107 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8108 | m_errorMonitor->VerifyFound(); |
| 8109 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8110 | EndCommandBuffer(); |
| 8111 | } |
| 8112 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8113 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8114 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8115 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8116 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8117 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8119 | m_errorMonitor->SetDesiredFailureMsg( |
| 8120 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8121 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8122 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8124 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8125 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8126 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8127 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8128 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8129 | const int32_t tex_width = 32; |
| 8130 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8131 | |
| 8132 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8133 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8134 | image_create_info.pNext = NULL; |
| 8135 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8136 | image_create_info.format = tex_format; |
| 8137 | image_create_info.extent.width = tex_width; |
| 8138 | image_create_info.extent.height = tex_height; |
| 8139 | image_create_info.extent.depth = 1; |
| 8140 | image_create_info.mipLevels = 1; |
| 8141 | image_create_info.arrayLayers = 1; |
| 8142 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8143 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8144 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8145 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8146 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8147 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8148 | ASSERT_VK_SUCCESS(err); |
| 8149 | |
| 8150 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8151 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8152 | image_view_create_info.image = image; |
| 8153 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8154 | image_view_create_info.format = tex_format; |
| 8155 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8156 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8157 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8158 | image_view_create_info.subresourceRange.aspectMask = |
| 8159 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8160 | |
| 8161 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8162 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8163 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8164 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8165 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8166 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8167 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8168 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8169 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8170 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8171 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8172 | "vkCreateImageView: Color image " |
| 8173 | "formats must have ONLY the " |
| 8174 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8175 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8176 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8177 | |
| 8178 | // 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] | 8179 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8181 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8182 | const int32_t tex_width = 32; |
| 8183 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8184 | |
| 8185 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8186 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8187 | image_create_info.pNext = NULL; |
| 8188 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8189 | image_create_info.format = tex_format; |
| 8190 | image_create_info.extent.width = tex_width; |
| 8191 | image_create_info.extent.height = tex_height; |
| 8192 | image_create_info.extent.depth = 1; |
| 8193 | image_create_info.mipLevels = 1; |
| 8194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8195 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8196 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8197 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8198 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8199 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8200 | ASSERT_VK_SUCCESS(err); |
| 8201 | |
| 8202 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8203 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8204 | image_view_create_info.image = image; |
| 8205 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8206 | image_view_create_info.format = tex_format; |
| 8207 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8208 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8209 | // Cause an error by setting an invalid image aspect |
| 8210 | image_view_create_info.subresourceRange.aspectMask = |
| 8211 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8212 | |
| 8213 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8214 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8215 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8216 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8217 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8218 | } |
| 8219 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8220 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8221 | VkResult err; |
| 8222 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8223 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8224 | m_errorMonitor->SetDesiredFailureMsg( |
| 8225 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8226 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8227 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8228 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8229 | |
| 8230 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8231 | VkImage srcImage; |
| 8232 | VkImage dstImage; |
| 8233 | VkDeviceMemory srcMem; |
| 8234 | VkDeviceMemory destMem; |
| 8235 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8236 | |
| 8237 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8238 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8239 | image_create_info.pNext = NULL; |
| 8240 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8241 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8242 | image_create_info.extent.width = 32; |
| 8243 | image_create_info.extent.height = 32; |
| 8244 | image_create_info.extent.depth = 1; |
| 8245 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8246 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8247 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8248 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8249 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8250 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8252 | err = |
| 8253 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8254 | ASSERT_VK_SUCCESS(err); |
| 8255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | err = |
| 8257 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8258 | ASSERT_VK_SUCCESS(err); |
| 8259 | |
| 8260 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8261 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8262 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8263 | memAlloc.pNext = NULL; |
| 8264 | memAlloc.allocationSize = 0; |
| 8265 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8266 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8267 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8268 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8269 | pass = |
| 8270 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8271 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8272 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8273 | ASSERT_VK_SUCCESS(err); |
| 8274 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8275 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8276 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8277 | pass = |
| 8278 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8279 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8280 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8281 | ASSERT_VK_SUCCESS(err); |
| 8282 | |
| 8283 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8284 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8285 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8286 | ASSERT_VK_SUCCESS(err); |
| 8287 | |
| 8288 | BeginCommandBuffer(); |
| 8289 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8290 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8291 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8292 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8293 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8294 | copyRegion.srcOffset.x = 0; |
| 8295 | copyRegion.srcOffset.y = 0; |
| 8296 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8297 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8298 | copyRegion.dstSubresource.mipLevel = 0; |
| 8299 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8300 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8301 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8302 | copyRegion.dstOffset.x = 0; |
| 8303 | copyRegion.dstOffset.y = 0; |
| 8304 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8305 | copyRegion.extent.width = 1; |
| 8306 | copyRegion.extent.height = 1; |
| 8307 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8308 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8309 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8310 | EndCommandBuffer(); |
| 8311 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8312 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8313 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8314 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8315 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8316 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8317 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8318 | } |
| 8319 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8320 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8321 | VkResult err; |
| 8322 | bool pass; |
| 8323 | |
| 8324 | // Create color images with different format sizes and try to copy between them |
| 8325 | m_errorMonitor->SetDesiredFailureMsg( |
| 8326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8327 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8328 | |
| 8329 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8330 | |
| 8331 | // Create two images of different types and try to copy between them |
| 8332 | VkImage srcImage; |
| 8333 | VkImage dstImage; |
| 8334 | VkDeviceMemory srcMem; |
| 8335 | VkDeviceMemory destMem; |
| 8336 | VkMemoryRequirements memReqs; |
| 8337 | |
| 8338 | VkImageCreateInfo image_create_info = {}; |
| 8339 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8340 | image_create_info.pNext = NULL; |
| 8341 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8342 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8343 | image_create_info.extent.width = 32; |
| 8344 | image_create_info.extent.height = 32; |
| 8345 | image_create_info.extent.depth = 1; |
| 8346 | image_create_info.mipLevels = 1; |
| 8347 | image_create_info.arrayLayers = 1; |
| 8348 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8349 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8350 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8351 | image_create_info.flags = 0; |
| 8352 | |
| 8353 | err = |
| 8354 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8355 | ASSERT_VK_SUCCESS(err); |
| 8356 | |
| 8357 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8358 | // Introduce failure by creating second image with a different-sized format. |
| 8359 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8360 | |
| 8361 | err = |
| 8362 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8363 | ASSERT_VK_SUCCESS(err); |
| 8364 | |
| 8365 | // Allocate memory |
| 8366 | VkMemoryAllocateInfo memAlloc = {}; |
| 8367 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8368 | memAlloc.pNext = NULL; |
| 8369 | memAlloc.allocationSize = 0; |
| 8370 | memAlloc.memoryTypeIndex = 0; |
| 8371 | |
| 8372 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 8373 | memAlloc.allocationSize = memReqs.size; |
| 8374 | pass = |
| 8375 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8376 | ASSERT_TRUE(pass); |
| 8377 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 8378 | ASSERT_VK_SUCCESS(err); |
| 8379 | |
| 8380 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 8381 | memAlloc.allocationSize = memReqs.size; |
| 8382 | pass = |
| 8383 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8384 | ASSERT_TRUE(pass); |
| 8385 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 8386 | ASSERT_VK_SUCCESS(err); |
| 8387 | |
| 8388 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8389 | ASSERT_VK_SUCCESS(err); |
| 8390 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 8391 | ASSERT_VK_SUCCESS(err); |
| 8392 | |
| 8393 | BeginCommandBuffer(); |
| 8394 | VkImageCopy copyRegion; |
| 8395 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8396 | copyRegion.srcSubresource.mipLevel = 0; |
| 8397 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8398 | copyRegion.srcSubresource.layerCount = 0; |
| 8399 | copyRegion.srcOffset.x = 0; |
| 8400 | copyRegion.srcOffset.y = 0; |
| 8401 | copyRegion.srcOffset.z = 0; |
| 8402 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8403 | copyRegion.dstSubresource.mipLevel = 0; |
| 8404 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8405 | copyRegion.dstSubresource.layerCount = 0; |
| 8406 | copyRegion.dstOffset.x = 0; |
| 8407 | copyRegion.dstOffset.y = 0; |
| 8408 | copyRegion.dstOffset.z = 0; |
| 8409 | copyRegion.extent.width = 1; |
| 8410 | copyRegion.extent.height = 1; |
| 8411 | copyRegion.extent.depth = 1; |
| 8412 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8413 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8414 | EndCommandBuffer(); |
| 8415 | |
| 8416 | m_errorMonitor->VerifyFound(); |
| 8417 | |
| 8418 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 8419 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 8420 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8421 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8422 | } |
| 8423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8424 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 8425 | VkResult err; |
| 8426 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8427 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8428 | // 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] | 8429 | m_errorMonitor->SetDesiredFailureMsg( |
| 8430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8431 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8432 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8433 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8434 | |
| 8435 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8436 | VkImage srcImage; |
| 8437 | VkImage dstImage; |
| 8438 | VkDeviceMemory srcMem; |
| 8439 | VkDeviceMemory destMem; |
| 8440 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8441 | |
| 8442 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8443 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8444 | image_create_info.pNext = NULL; |
| 8445 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8446 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8447 | image_create_info.extent.width = 32; |
| 8448 | image_create_info.extent.height = 32; |
| 8449 | image_create_info.extent.depth = 1; |
| 8450 | image_create_info.mipLevels = 1; |
| 8451 | image_create_info.arrayLayers = 1; |
| 8452 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8453 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8454 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_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 | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8461 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8462 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8463 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8464 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8465 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8466 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8468 | err = |
| 8469 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8470 | ASSERT_VK_SUCCESS(err); |
| 8471 | |
| 8472 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8473 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8474 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8475 | memAlloc.pNext = NULL; |
| 8476 | memAlloc.allocationSize = 0; |
| 8477 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8478 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8479 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8480 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8481 | pass = |
| 8482 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8483 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8484 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8485 | ASSERT_VK_SUCCESS(err); |
| 8486 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8487 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8488 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8489 | pass = |
| 8490 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8491 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8492 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8493 | ASSERT_VK_SUCCESS(err); |
| 8494 | |
| 8495 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8496 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8497 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8498 | ASSERT_VK_SUCCESS(err); |
| 8499 | |
| 8500 | BeginCommandBuffer(); |
| 8501 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8502 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8503 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8504 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8505 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8506 | copyRegion.srcOffset.x = 0; |
| 8507 | copyRegion.srcOffset.y = 0; |
| 8508 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8509 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8510 | copyRegion.dstSubresource.mipLevel = 0; |
| 8511 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8512 | copyRegion.dstSubresource.layerCount = 0; |
| 8513 | copyRegion.dstOffset.x = 0; |
| 8514 | copyRegion.dstOffset.y = 0; |
| 8515 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8516 | copyRegion.extent.width = 1; |
| 8517 | copyRegion.extent.height = 1; |
| 8518 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8519 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8520 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8521 | EndCommandBuffer(); |
| 8522 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8523 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8524 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8525 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8526 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8527 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8528 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8529 | } |
| 8530 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8531 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 8532 | VkResult err; |
| 8533 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8535 | m_errorMonitor->SetDesiredFailureMsg( |
| 8536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8537 | "vkCmdResolveImage called with source sample count less than 2."); |
| 8538 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8539 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8540 | |
| 8541 | // 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] | 8542 | VkImage srcImage; |
| 8543 | VkImage dstImage; |
| 8544 | VkDeviceMemory srcMem; |
| 8545 | VkDeviceMemory destMem; |
| 8546 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8547 | |
| 8548 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8549 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8550 | image_create_info.pNext = NULL; |
| 8551 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8552 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8553 | image_create_info.extent.width = 32; |
| 8554 | image_create_info.extent.height = 1; |
| 8555 | image_create_info.extent.depth = 1; |
| 8556 | image_create_info.mipLevels = 1; |
| 8557 | image_create_info.arrayLayers = 1; |
| 8558 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8559 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8560 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8561 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8563 | err = |
| 8564 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8565 | ASSERT_VK_SUCCESS(err); |
| 8566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8567 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8568 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8570 | err = |
| 8571 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8572 | ASSERT_VK_SUCCESS(err); |
| 8573 | |
| 8574 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8575 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8576 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8577 | memAlloc.pNext = NULL; |
| 8578 | memAlloc.allocationSize = 0; |
| 8579 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8580 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8581 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8582 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8583 | pass = |
| 8584 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8585 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8586 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8587 | ASSERT_VK_SUCCESS(err); |
| 8588 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8589 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8590 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8591 | pass = |
| 8592 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8593 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8594 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8595 | ASSERT_VK_SUCCESS(err); |
| 8596 | |
| 8597 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8598 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8599 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8600 | ASSERT_VK_SUCCESS(err); |
| 8601 | |
| 8602 | BeginCommandBuffer(); |
| 8603 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8604 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8605 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8606 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8607 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8608 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8609 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8610 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8611 | resolveRegion.srcOffset.x = 0; |
| 8612 | resolveRegion.srcOffset.y = 0; |
| 8613 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8614 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8615 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8616 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8617 | resolveRegion.dstSubresource.layerCount = 0; |
| 8618 | resolveRegion.dstOffset.x = 0; |
| 8619 | resolveRegion.dstOffset.y = 0; |
| 8620 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8621 | resolveRegion.extent.width = 1; |
| 8622 | resolveRegion.extent.height = 1; |
| 8623 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8624 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8625 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8626 | EndCommandBuffer(); |
| 8627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8628 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8629 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8630 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8631 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8632 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8633 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8634 | } |
| 8635 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8636 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 8637 | VkResult err; |
| 8638 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8640 | m_errorMonitor->SetDesiredFailureMsg( |
| 8641 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8642 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 8643 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8644 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8645 | |
| 8646 | // 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] | 8647 | VkImage srcImage; |
| 8648 | VkImage dstImage; |
| 8649 | VkDeviceMemory srcMem; |
| 8650 | VkDeviceMemory destMem; |
| 8651 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8652 | |
| 8653 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8654 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8655 | image_create_info.pNext = NULL; |
| 8656 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8657 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8658 | image_create_info.extent.width = 32; |
| 8659 | image_create_info.extent.height = 1; |
| 8660 | image_create_info.extent.depth = 1; |
| 8661 | image_create_info.mipLevels = 1; |
| 8662 | image_create_info.arrayLayers = 1; |
| 8663 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8664 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8665 | // Note: Some implementations expect color attachment usage for any |
| 8666 | // multisample surface |
| 8667 | image_create_info.usage = |
| 8668 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8669 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8671 | err = |
| 8672 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8673 | ASSERT_VK_SUCCESS(err); |
| 8674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8675 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8676 | // Note: Some implementations expect color attachment usage for any |
| 8677 | // multisample surface |
| 8678 | image_create_info.usage = |
| 8679 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
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, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8683 | ASSERT_VK_SUCCESS(err); |
| 8684 | |
| 8685 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8686 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8687 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8688 | memAlloc.pNext = NULL; |
| 8689 | memAlloc.allocationSize = 0; |
| 8690 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8691 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8692 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8693 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8694 | pass = |
| 8695 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8696 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8697 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8698 | ASSERT_VK_SUCCESS(err); |
| 8699 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8700 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8701 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8702 | pass = |
| 8703 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8704 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8705 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8706 | ASSERT_VK_SUCCESS(err); |
| 8707 | |
| 8708 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8709 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8710 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8711 | ASSERT_VK_SUCCESS(err); |
| 8712 | |
| 8713 | BeginCommandBuffer(); |
| 8714 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8715 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8716 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8717 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8718 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8719 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8720 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8721 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8722 | resolveRegion.srcOffset.x = 0; |
| 8723 | resolveRegion.srcOffset.y = 0; |
| 8724 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8725 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8726 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8727 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8728 | resolveRegion.dstSubresource.layerCount = 0; |
| 8729 | resolveRegion.dstOffset.x = 0; |
| 8730 | resolveRegion.dstOffset.y = 0; |
| 8731 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8732 | resolveRegion.extent.width = 1; |
| 8733 | resolveRegion.extent.height = 1; |
| 8734 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8735 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8736 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8737 | EndCommandBuffer(); |
| 8738 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8739 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8740 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8741 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8742 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8743 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8744 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8745 | } |
| 8746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8747 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 8748 | VkResult err; |
| 8749 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8750 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8751 | m_errorMonitor->SetDesiredFailureMsg( |
| 8752 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8753 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 8754 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8755 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8756 | |
| 8757 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8758 | VkImage srcImage; |
| 8759 | VkImage dstImage; |
| 8760 | VkDeviceMemory srcMem; |
| 8761 | VkDeviceMemory destMem; |
| 8762 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8763 | |
| 8764 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8765 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8766 | image_create_info.pNext = NULL; |
| 8767 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8768 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8769 | image_create_info.extent.width = 32; |
| 8770 | image_create_info.extent.height = 1; |
| 8771 | image_create_info.extent.depth = 1; |
| 8772 | image_create_info.mipLevels = 1; |
| 8773 | image_create_info.arrayLayers = 1; |
| 8774 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8775 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8776 | // Note: Some implementations expect color attachment usage for any |
| 8777 | // multisample surface |
| 8778 | image_create_info.usage = |
| 8779 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8780 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8782 | err = |
| 8783 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8784 | ASSERT_VK_SUCCESS(err); |
| 8785 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8786 | // Set format to something other than source image |
| 8787 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 8788 | // Note: Some implementations expect color attachment usage for any |
| 8789 | // multisample surface |
| 8790 | image_create_info.usage = |
| 8791 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8792 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8794 | err = |
| 8795 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8796 | ASSERT_VK_SUCCESS(err); |
| 8797 | |
| 8798 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8799 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8800 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8801 | memAlloc.pNext = NULL; |
| 8802 | memAlloc.allocationSize = 0; |
| 8803 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8804 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8805 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8806 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8807 | pass = |
| 8808 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8809 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8810 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8811 | ASSERT_VK_SUCCESS(err); |
| 8812 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8813 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8814 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8815 | pass = |
| 8816 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8817 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8818 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8819 | ASSERT_VK_SUCCESS(err); |
| 8820 | |
| 8821 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8822 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8823 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8824 | ASSERT_VK_SUCCESS(err); |
| 8825 | |
| 8826 | BeginCommandBuffer(); |
| 8827 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8828 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8829 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8830 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8831 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8832 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8833 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8834 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8835 | resolveRegion.srcOffset.x = 0; |
| 8836 | resolveRegion.srcOffset.y = 0; |
| 8837 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8838 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8839 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8840 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8841 | resolveRegion.dstSubresource.layerCount = 0; |
| 8842 | resolveRegion.dstOffset.x = 0; |
| 8843 | resolveRegion.dstOffset.y = 0; |
| 8844 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8845 | resolveRegion.extent.width = 1; |
| 8846 | resolveRegion.extent.height = 1; |
| 8847 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8848 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8849 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8850 | EndCommandBuffer(); |
| 8851 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8852 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8853 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8854 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8855 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8856 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8857 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8858 | } |
| 8859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8860 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 8861 | VkResult err; |
| 8862 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8864 | m_errorMonitor->SetDesiredFailureMsg( |
| 8865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8866 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 8867 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8869 | |
| 8870 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8871 | VkImage srcImage; |
| 8872 | VkImage dstImage; |
| 8873 | VkDeviceMemory srcMem; |
| 8874 | VkDeviceMemory destMem; |
| 8875 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8876 | |
| 8877 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8878 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8879 | image_create_info.pNext = NULL; |
| 8880 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8881 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8882 | image_create_info.extent.width = 32; |
| 8883 | image_create_info.extent.height = 1; |
| 8884 | image_create_info.extent.depth = 1; |
| 8885 | image_create_info.mipLevels = 1; |
| 8886 | image_create_info.arrayLayers = 1; |
| 8887 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8888 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8889 | // Note: Some implementations expect color attachment usage for any |
| 8890 | // multisample surface |
| 8891 | image_create_info.usage = |
| 8892 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8893 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8895 | err = |
| 8896 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8897 | ASSERT_VK_SUCCESS(err); |
| 8898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8899 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8900 | // Note: Some implementations expect color attachment usage for any |
| 8901 | // multisample surface |
| 8902 | image_create_info.usage = |
| 8903 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8904 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8905 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8906 | err = |
| 8907 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8908 | ASSERT_VK_SUCCESS(err); |
| 8909 | |
| 8910 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8911 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8912 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8913 | memAlloc.pNext = NULL; |
| 8914 | memAlloc.allocationSize = 0; |
| 8915 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8916 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8917 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8918 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8919 | pass = |
| 8920 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8921 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8922 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8923 | ASSERT_VK_SUCCESS(err); |
| 8924 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8925 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8926 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8927 | pass = |
| 8928 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8929 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8930 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8931 | ASSERT_VK_SUCCESS(err); |
| 8932 | |
| 8933 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8934 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8935 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8936 | ASSERT_VK_SUCCESS(err); |
| 8937 | |
| 8938 | BeginCommandBuffer(); |
| 8939 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8940 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8941 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8942 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8943 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8944 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8945 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8946 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8947 | resolveRegion.srcOffset.x = 0; |
| 8948 | resolveRegion.srcOffset.y = 0; |
| 8949 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8950 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8951 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8952 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8953 | resolveRegion.dstSubresource.layerCount = 0; |
| 8954 | resolveRegion.dstOffset.x = 0; |
| 8955 | resolveRegion.dstOffset.y = 0; |
| 8956 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8957 | resolveRegion.extent.width = 1; |
| 8958 | resolveRegion.extent.height = 1; |
| 8959 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8960 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8961 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8962 | EndCommandBuffer(); |
| 8963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8964 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8965 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8966 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8967 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8968 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8969 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8970 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8972 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8973 | // 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] | 8974 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 8975 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8976 | // The image format check comes 2nd in validation so we trigger it first, |
| 8977 | // 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] | 8978 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8979 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8980 | m_errorMonitor->SetDesiredFailureMsg( |
| 8981 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8982 | "Combination depth/stencil image formats can have only the "); |
| 8983 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8985 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8986 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8987 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8988 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8989 | |
| 8990 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8991 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8992 | ds_pool_ci.pNext = NULL; |
| 8993 | ds_pool_ci.maxSets = 1; |
| 8994 | ds_pool_ci.poolSizeCount = 1; |
| 8995 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8996 | |
| 8997 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8998 | err = |
| 8999 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9000 | ASSERT_VK_SUCCESS(err); |
| 9001 | |
| 9002 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9003 | dsl_binding.binding = 0; |
| 9004 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9005 | dsl_binding.descriptorCount = 1; |
| 9006 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9007 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9008 | |
| 9009 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9010 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9011 | ds_layout_ci.pNext = NULL; |
| 9012 | ds_layout_ci.bindingCount = 1; |
| 9013 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9014 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9015 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9016 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9017 | ASSERT_VK_SUCCESS(err); |
| 9018 | |
| 9019 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9020 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9021 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9022 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9023 | alloc_info.descriptorPool = ds_pool; |
| 9024 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9025 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9026 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9027 | ASSERT_VK_SUCCESS(err); |
| 9028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9029 | VkImage image_bad; |
| 9030 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9031 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9032 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9033 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9034 | const int32_t tex_width = 32; |
| 9035 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9036 | |
| 9037 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9038 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9039 | image_create_info.pNext = NULL; |
| 9040 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9041 | image_create_info.format = tex_format_bad; |
| 9042 | image_create_info.extent.width = tex_width; |
| 9043 | image_create_info.extent.height = tex_height; |
| 9044 | image_create_info.extent.depth = 1; |
| 9045 | image_create_info.mipLevels = 1; |
| 9046 | image_create_info.arrayLayers = 1; |
| 9047 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9048 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9049 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9050 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9051 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9053 | err = |
| 9054 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9055 | ASSERT_VK_SUCCESS(err); |
| 9056 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9057 | image_create_info.usage = |
| 9058 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9059 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9060 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9061 | ASSERT_VK_SUCCESS(err); |
| 9062 | |
| 9063 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9064 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9065 | image_view_create_info.image = image_bad; |
| 9066 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9067 | image_view_create_info.format = tex_format_bad; |
| 9068 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9069 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9070 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9071 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9072 | image_view_create_info.subresourceRange.aspectMask = |
| 9073 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9074 | |
| 9075 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9076 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9077 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9078 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9079 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9080 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9081 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9082 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9083 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9084 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9085 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9086 | #endif // IMAGE_TESTS |
| 9087 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9088 | int main(int argc, char **argv) { |
| 9089 | int result; |
| 9090 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9091 | #ifdef ANDROID |
| 9092 | int vulkanSupport = InitVulkan(); |
| 9093 | if (vulkanSupport == 0) |
| 9094 | return 1; |
| 9095 | #endif |
| 9096 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9097 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9098 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9099 | |
| 9100 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9101 | |
| 9102 | result = RUN_ALL_TESTS(); |
| 9103 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9104 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9105 | return result; |
| 9106 | } |