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(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1326 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1327 | #endif // MEM_TRACKER_TESTS |
| 1328 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1329 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1330 | |
| 1331 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1332 | VkResult err; |
| 1333 | |
| 1334 | TEST_DESCRIPTION( |
| 1335 | "Create a fence and destroy its device without first destroying the fence."); |
| 1336 | |
| 1337 | // Note that we have to create a new device since destroying the |
| 1338 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1339 | // will destroy the errorMonitor. |
| 1340 | |
| 1341 | m_errorMonitor->SetDesiredFailureMsg( |
| 1342 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1343 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1344 | |
| 1345 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1346 | |
| 1347 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1348 | m_device->queue_props; |
| 1349 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1350 | queue_info.reserve(queue_props.size()); |
| 1351 | std::vector<std::vector<float>> queue_priorities; |
| 1352 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1353 | VkDeviceQueueCreateInfo qi = {}; |
| 1354 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1355 | qi.pNext = NULL; |
| 1356 | qi.queueFamilyIndex = i; |
| 1357 | qi.queueCount = queue_props[i].queueCount; |
| 1358 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1359 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1360 | queue_info.push_back(qi); |
| 1361 | } |
| 1362 | |
| 1363 | std::vector<const char *> device_layer_names; |
| 1364 | std::vector<const char *> device_extension_names; |
| 1365 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1366 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1367 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1368 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1369 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1370 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1371 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1372 | |
| 1373 | // The sacrificial device object |
| 1374 | VkDevice testDevice; |
| 1375 | VkDeviceCreateInfo device_create_info = {}; |
| 1376 | auto features = m_device->phy().features(); |
| 1377 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1378 | device_create_info.pNext = NULL; |
| 1379 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1380 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1381 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1382 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1383 | device_create_info.pEnabledFeatures = &features; |
| 1384 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1385 | ASSERT_VK_SUCCESS(err); |
| 1386 | |
| 1387 | VkFence fence; |
| 1388 | VkFenceCreateInfo fence_create_info = {}; |
| 1389 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1390 | fence_create_info.pNext = NULL; |
| 1391 | fence_create_info.flags = 0; |
| 1392 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1393 | ASSERT_VK_SUCCESS(err); |
| 1394 | |
| 1395 | // Induce failure by not calling vkDestroyFence |
| 1396 | vkDestroyDevice(testDevice, NULL); |
| 1397 | m_errorMonitor->VerifyFound(); |
| 1398 | } |
| 1399 | |
| 1400 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1401 | |
| 1402 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1403 | "attempt to delete them from another."); |
| 1404 | |
| 1405 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1406 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1407 | |
| 1408 | VkCommandPool command_pool_one; |
| 1409 | VkCommandPool command_pool_two; |
| 1410 | |
| 1411 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1412 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1413 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1414 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1415 | |
| 1416 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1417 | &command_pool_one); |
| 1418 | |
| 1419 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1420 | &command_pool_two); |
| 1421 | |
| 1422 | VkCommandBuffer command_buffer[9]; |
| 1423 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1424 | command_buffer_allocate_info.sType = |
| 1425 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1426 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1427 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1428 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1429 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1430 | command_buffer); |
| 1431 | |
| 1432 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1433 | &command_buffer[3]); |
| 1434 | |
| 1435 | m_errorMonitor->VerifyFound(); |
| 1436 | |
| 1437 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1438 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1439 | } |
| 1440 | |
| 1441 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1442 | VkResult err; |
| 1443 | |
| 1444 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1445 | "attempt to delete them from another."); |
| 1446 | |
| 1447 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1448 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1449 | |
| 1450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1451 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1452 | |
| 1453 | VkDescriptorPoolSize ds_type_count = {}; |
| 1454 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1455 | ds_type_count.descriptorCount = 1; |
| 1456 | |
| 1457 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1458 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1459 | ds_pool_ci.pNext = NULL; |
| 1460 | ds_pool_ci.flags = 0; |
| 1461 | ds_pool_ci.maxSets = 1; |
| 1462 | ds_pool_ci.poolSizeCount = 1; |
| 1463 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1464 | |
| 1465 | VkDescriptorPool ds_pool_one; |
| 1466 | err = |
| 1467 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1468 | ASSERT_VK_SUCCESS(err); |
| 1469 | |
| 1470 | // Create a second descriptor pool |
| 1471 | VkDescriptorPool ds_pool_two; |
| 1472 | err = |
| 1473 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1474 | ASSERT_VK_SUCCESS(err); |
| 1475 | |
| 1476 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1477 | dsl_binding.binding = 0; |
| 1478 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1479 | dsl_binding.descriptorCount = 1; |
| 1480 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1481 | dsl_binding.pImmutableSamplers = NULL; |
| 1482 | |
| 1483 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1484 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1485 | ds_layout_ci.pNext = NULL; |
| 1486 | ds_layout_ci.bindingCount = 1; |
| 1487 | ds_layout_ci.pBindings = &dsl_binding; |
| 1488 | |
| 1489 | VkDescriptorSetLayout ds_layout; |
| 1490 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1491 | &ds_layout); |
| 1492 | ASSERT_VK_SUCCESS(err); |
| 1493 | |
| 1494 | VkDescriptorSet descriptorSet; |
| 1495 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1496 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1497 | alloc_info.descriptorSetCount = 1; |
| 1498 | alloc_info.descriptorPool = ds_pool_one; |
| 1499 | alloc_info.pSetLayouts = &ds_layout; |
| 1500 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1501 | &descriptorSet); |
| 1502 | ASSERT_VK_SUCCESS(err); |
| 1503 | |
| 1504 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1505 | |
| 1506 | m_errorMonitor->VerifyFound(); |
| 1507 | |
| 1508 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1509 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1510 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1511 | } |
| 1512 | |
| 1513 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1515 | "Invalid VkImage Object "); |
| 1516 | |
| 1517 | TEST_DESCRIPTION( |
| 1518 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1519 | |
| 1520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1521 | |
| 1522 | // Pass bogus handle into GetImageMemoryRequirements |
| 1523 | VkMemoryRequirements mem_reqs; |
| 1524 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1525 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1526 | |
| 1527 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1528 | |
| 1529 | m_errorMonitor->VerifyFound(); |
| 1530 | } |
| 1531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1532 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1533 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1534 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1535 | TEST_DESCRIPTION( |
| 1536 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1537 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1538 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1539 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1540 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1543 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1544 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1545 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1546 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1547 | |
| 1548 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1549 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1550 | ds_pool_ci.pNext = NULL; |
| 1551 | ds_pool_ci.maxSets = 1; |
| 1552 | ds_pool_ci.poolSizeCount = 1; |
| 1553 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1554 | |
| 1555 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1556 | err = |
| 1557 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1558 | ASSERT_VK_SUCCESS(err); |
| 1559 | |
| 1560 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1561 | dsl_binding.binding = 0; |
| 1562 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1563 | dsl_binding.descriptorCount = 1; |
| 1564 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1565 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1566 | |
| 1567 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1568 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1569 | ds_layout_ci.pNext = NULL; |
| 1570 | ds_layout_ci.bindingCount = 1; |
| 1571 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1572 | |
| 1573 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1574 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1575 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1576 | ASSERT_VK_SUCCESS(err); |
| 1577 | |
| 1578 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1579 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1580 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1581 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1582 | alloc_info.descriptorPool = ds_pool; |
| 1583 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1584 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1585 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1586 | ASSERT_VK_SUCCESS(err); |
| 1587 | |
| 1588 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1589 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1590 | pipeline_layout_ci.pNext = NULL; |
| 1591 | pipeline_layout_ci.setLayoutCount = 1; |
| 1592 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1593 | |
| 1594 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1595 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1596 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1597 | ASSERT_VK_SUCCESS(err); |
| 1598 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1599 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1600 | |
| 1601 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1602 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1603 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1604 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1605 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1606 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1607 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1608 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1609 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1610 | } |
| 1611 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1612 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1613 | VkResult err; |
| 1614 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1615 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1616 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1617 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1618 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1620 | |
| 1621 | // 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] | 1622 | VkImage image; |
| 1623 | VkDeviceMemory mem; |
| 1624 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1626 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1627 | const int32_t tex_width = 32; |
| 1628 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1629 | |
| 1630 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1631 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1632 | image_create_info.pNext = NULL; |
| 1633 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1634 | image_create_info.format = tex_format; |
| 1635 | image_create_info.extent.width = tex_width; |
| 1636 | image_create_info.extent.height = tex_height; |
| 1637 | image_create_info.extent.depth = 1; |
| 1638 | image_create_info.mipLevels = 1; |
| 1639 | image_create_info.arrayLayers = 1; |
| 1640 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1641 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1642 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1643 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1644 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1645 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1646 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1647 | mem_alloc.pNext = NULL; |
| 1648 | mem_alloc.allocationSize = 0; |
| 1649 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1650 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1651 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1652 | ASSERT_VK_SUCCESS(err); |
| 1653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1654 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1655 | |
| 1656 | mem_alloc.allocationSize = mem_reqs.size; |
| 1657 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1658 | pass = |
| 1659 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1660 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1661 | |
| 1662 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1663 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1664 | ASSERT_VK_SUCCESS(err); |
| 1665 | |
| 1666 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1667 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1668 | |
| 1669 | // Try to bind free memory that has been freed |
| 1670 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1671 | // This may very well return an error. |
| 1672 | (void)err; |
| 1673 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1674 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1675 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1676 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1677 | } |
| 1678 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1679 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1680 | VkResult err; |
| 1681 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1682 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1684 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1685 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1688 | // Create an image object, allocate memory, destroy the object and then try |
| 1689 | // to bind it |
| 1690 | VkImage image; |
| 1691 | VkDeviceMemory mem; |
| 1692 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1694 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1695 | const int32_t tex_width = 32; |
| 1696 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1697 | |
| 1698 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1699 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1700 | image_create_info.pNext = NULL; |
| 1701 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1702 | image_create_info.format = tex_format; |
| 1703 | image_create_info.extent.width = tex_width; |
| 1704 | image_create_info.extent.height = tex_height; |
| 1705 | image_create_info.extent.depth = 1; |
| 1706 | image_create_info.mipLevels = 1; |
| 1707 | image_create_info.arrayLayers = 1; |
| 1708 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1709 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1710 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1711 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1712 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1713 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1714 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1715 | mem_alloc.pNext = NULL; |
| 1716 | mem_alloc.allocationSize = 0; |
| 1717 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1718 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1719 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1720 | ASSERT_VK_SUCCESS(err); |
| 1721 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1722 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1723 | |
| 1724 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1725 | pass = |
| 1726 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1727 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1728 | |
| 1729 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1730 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1731 | ASSERT_VK_SUCCESS(err); |
| 1732 | |
| 1733 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1734 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1735 | ASSERT_VK_SUCCESS(err); |
| 1736 | |
| 1737 | // Now Try to bind memory to this destroyed object |
| 1738 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1739 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1740 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1741 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1742 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1743 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1744 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1745 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1746 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1747 | #endif // OBJ_TRACKER_TESTS |
| 1748 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1749 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1750 | |
| 1751 | // This is a positive test. No errors should be generated. |
| 1752 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1753 | |
| 1754 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1755 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1756 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1757 | if ((m_device->queue_props.empty()) || |
| 1758 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1759 | return; |
| 1760 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1761 | m_errorMonitor->ExpectSuccess(); |
| 1762 | |
| 1763 | VkSemaphore semaphore; |
| 1764 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1765 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1766 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1767 | &semaphore); |
| 1768 | |
| 1769 | VkCommandPool command_pool; |
| 1770 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1771 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1772 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1773 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1774 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1775 | &command_pool); |
| 1776 | |
| 1777 | VkCommandBuffer command_buffer[2]; |
| 1778 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1779 | command_buffer_allocate_info.sType = |
| 1780 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1781 | command_buffer_allocate_info.commandPool = command_pool; |
| 1782 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1783 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1784 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1785 | command_buffer); |
| 1786 | |
| 1787 | VkQueue queue = VK_NULL_HANDLE; |
| 1788 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1789 | 1, &queue); |
| 1790 | |
| 1791 | { |
| 1792 | VkCommandBufferBeginInfo begin_info{}; |
| 1793 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1794 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1795 | |
| 1796 | vkCmdPipelineBarrier(command_buffer[0], |
| 1797 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1798 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1799 | 0, nullptr, 0, nullptr); |
| 1800 | |
| 1801 | VkViewport viewport{}; |
| 1802 | viewport.maxDepth = 1.0f; |
| 1803 | viewport.minDepth = 0.0f; |
| 1804 | viewport.width = 512; |
| 1805 | viewport.height = 512; |
| 1806 | viewport.x = 0; |
| 1807 | viewport.y = 0; |
| 1808 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1809 | vkEndCommandBuffer(command_buffer[0]); |
| 1810 | } |
| 1811 | { |
| 1812 | VkCommandBufferBeginInfo begin_info{}; |
| 1813 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1814 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1815 | |
| 1816 | VkViewport viewport{}; |
| 1817 | viewport.maxDepth = 1.0f; |
| 1818 | viewport.minDepth = 0.0f; |
| 1819 | viewport.width = 512; |
| 1820 | viewport.height = 512; |
| 1821 | viewport.x = 0; |
| 1822 | viewport.y = 0; |
| 1823 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1824 | vkEndCommandBuffer(command_buffer[1]); |
| 1825 | } |
| 1826 | { |
| 1827 | VkSubmitInfo submit_info{}; |
| 1828 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1829 | submit_info.commandBufferCount = 1; |
| 1830 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1831 | submit_info.signalSemaphoreCount = 1; |
| 1832 | submit_info.pSignalSemaphores = &semaphore; |
| 1833 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1834 | } |
| 1835 | { |
| 1836 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1837 | VkSubmitInfo submit_info{}; |
| 1838 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1839 | submit_info.commandBufferCount = 1; |
| 1840 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1841 | submit_info.waitSemaphoreCount = 1; |
| 1842 | submit_info.pWaitSemaphores = &semaphore; |
| 1843 | submit_info.pWaitDstStageMask = flags; |
| 1844 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1845 | } |
| 1846 | |
| 1847 | vkQueueWaitIdle(m_device->m_queue); |
| 1848 | |
| 1849 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1850 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1851 | &command_buffer[0]); |
| 1852 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1853 | |
| 1854 | m_errorMonitor->VerifyNotFound(); |
| 1855 | } |
| 1856 | |
| 1857 | // This is a positive test. No errors should be generated. |
| 1858 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1859 | |
| 1860 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1861 | "submitted on separate queues, the second having a fence" |
| 1862 | "followed by a QueueWaitIdle."); |
| 1863 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1864 | if ((m_device->queue_props.empty()) || |
| 1865 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1866 | return; |
| 1867 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1868 | m_errorMonitor->ExpectSuccess(); |
| 1869 | |
| 1870 | VkFence fence; |
| 1871 | VkFenceCreateInfo fence_create_info{}; |
| 1872 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1873 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1874 | |
| 1875 | VkSemaphore semaphore; |
| 1876 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1877 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1878 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1879 | &semaphore); |
| 1880 | |
| 1881 | VkCommandPool command_pool; |
| 1882 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1883 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1884 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1885 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1886 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1887 | &command_pool); |
| 1888 | |
| 1889 | VkCommandBuffer command_buffer[2]; |
| 1890 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1891 | command_buffer_allocate_info.sType = |
| 1892 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1893 | command_buffer_allocate_info.commandPool = command_pool; |
| 1894 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1895 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1896 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1897 | command_buffer); |
| 1898 | |
| 1899 | VkQueue queue = VK_NULL_HANDLE; |
| 1900 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1901 | 1, &queue); |
| 1902 | |
| 1903 | { |
| 1904 | VkCommandBufferBeginInfo begin_info{}; |
| 1905 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1906 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1907 | |
| 1908 | vkCmdPipelineBarrier(command_buffer[0], |
| 1909 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1910 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1911 | 0, nullptr, 0, nullptr); |
| 1912 | |
| 1913 | VkViewport viewport{}; |
| 1914 | viewport.maxDepth = 1.0f; |
| 1915 | viewport.minDepth = 0.0f; |
| 1916 | viewport.width = 512; |
| 1917 | viewport.height = 512; |
| 1918 | viewport.x = 0; |
| 1919 | viewport.y = 0; |
| 1920 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1921 | vkEndCommandBuffer(command_buffer[0]); |
| 1922 | } |
| 1923 | { |
| 1924 | VkCommandBufferBeginInfo begin_info{}; |
| 1925 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1926 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1927 | |
| 1928 | VkViewport viewport{}; |
| 1929 | viewport.maxDepth = 1.0f; |
| 1930 | viewport.minDepth = 0.0f; |
| 1931 | viewport.width = 512; |
| 1932 | viewport.height = 512; |
| 1933 | viewport.x = 0; |
| 1934 | viewport.y = 0; |
| 1935 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1936 | vkEndCommandBuffer(command_buffer[1]); |
| 1937 | } |
| 1938 | { |
| 1939 | VkSubmitInfo submit_info{}; |
| 1940 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1941 | submit_info.commandBufferCount = 1; |
| 1942 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1943 | submit_info.signalSemaphoreCount = 1; |
| 1944 | submit_info.pSignalSemaphores = &semaphore; |
| 1945 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1946 | } |
| 1947 | { |
| 1948 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1949 | VkSubmitInfo submit_info{}; |
| 1950 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1951 | submit_info.commandBufferCount = 1; |
| 1952 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1953 | submit_info.waitSemaphoreCount = 1; |
| 1954 | submit_info.pWaitSemaphores = &semaphore; |
| 1955 | submit_info.pWaitDstStageMask = flags; |
| 1956 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1957 | } |
| 1958 | |
| 1959 | vkQueueWaitIdle(m_device->m_queue); |
| 1960 | |
| 1961 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1962 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1963 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1964 | &command_buffer[0]); |
| 1965 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1966 | |
| 1967 | m_errorMonitor->VerifyNotFound(); |
| 1968 | } |
| 1969 | |
| 1970 | // This is a positive test. No errors should be generated. |
| 1971 | TEST_F(VkLayerTest, |
| 1972 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 1973 | |
| 1974 | TEST_DESCRIPTION( |
| 1975 | "Two command buffers, each in a separate QueueSubmit call " |
| 1976 | "submitted on separate queues, the second having a fence" |
| 1977 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 1978 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1979 | if ((m_device->queue_props.empty()) || |
| 1980 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1981 | return; |
| 1982 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1983 | m_errorMonitor->ExpectSuccess(); |
| 1984 | |
| 1985 | VkFence fence; |
| 1986 | VkFenceCreateInfo fence_create_info{}; |
| 1987 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1988 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1989 | |
| 1990 | VkSemaphore semaphore; |
| 1991 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1992 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1993 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1994 | &semaphore); |
| 1995 | |
| 1996 | VkCommandPool command_pool; |
| 1997 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1998 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1999 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2000 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2001 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2002 | &command_pool); |
| 2003 | |
| 2004 | VkCommandBuffer command_buffer[2]; |
| 2005 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2006 | command_buffer_allocate_info.sType = |
| 2007 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2008 | command_buffer_allocate_info.commandPool = command_pool; |
| 2009 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2010 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2011 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2012 | command_buffer); |
| 2013 | |
| 2014 | VkQueue queue = VK_NULL_HANDLE; |
| 2015 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2016 | 1, &queue); |
| 2017 | |
| 2018 | { |
| 2019 | VkCommandBufferBeginInfo begin_info{}; |
| 2020 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2021 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2022 | |
| 2023 | vkCmdPipelineBarrier(command_buffer[0], |
| 2024 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2025 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2026 | 0, nullptr, 0, nullptr); |
| 2027 | |
| 2028 | VkViewport viewport{}; |
| 2029 | viewport.maxDepth = 1.0f; |
| 2030 | viewport.minDepth = 0.0f; |
| 2031 | viewport.width = 512; |
| 2032 | viewport.height = 512; |
| 2033 | viewport.x = 0; |
| 2034 | viewport.y = 0; |
| 2035 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2036 | vkEndCommandBuffer(command_buffer[0]); |
| 2037 | } |
| 2038 | { |
| 2039 | VkCommandBufferBeginInfo begin_info{}; |
| 2040 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2041 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2042 | |
| 2043 | VkViewport viewport{}; |
| 2044 | viewport.maxDepth = 1.0f; |
| 2045 | viewport.minDepth = 0.0f; |
| 2046 | viewport.width = 512; |
| 2047 | viewport.height = 512; |
| 2048 | viewport.x = 0; |
| 2049 | viewport.y = 0; |
| 2050 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2051 | vkEndCommandBuffer(command_buffer[1]); |
| 2052 | } |
| 2053 | { |
| 2054 | VkSubmitInfo submit_info{}; |
| 2055 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2056 | submit_info.commandBufferCount = 1; |
| 2057 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2058 | submit_info.signalSemaphoreCount = 1; |
| 2059 | submit_info.pSignalSemaphores = &semaphore; |
| 2060 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2061 | } |
| 2062 | { |
| 2063 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2064 | VkSubmitInfo submit_info{}; |
| 2065 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2066 | submit_info.commandBufferCount = 1; |
| 2067 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2068 | submit_info.waitSemaphoreCount = 1; |
| 2069 | submit_info.pWaitSemaphores = &semaphore; |
| 2070 | submit_info.pWaitDstStageMask = flags; |
| 2071 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2072 | } |
| 2073 | |
| 2074 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2075 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2076 | |
| 2077 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2078 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2079 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2080 | &command_buffer[0]); |
| 2081 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2082 | |
| 2083 | m_errorMonitor->VerifyNotFound(); |
| 2084 | } |
| 2085 | |
| 2086 | // This is a positive test. No errors should be generated. |
| 2087 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2088 | |
| 2089 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2090 | "submitted on separate queues, the second having a fence, " |
| 2091 | "followed by a WaitForFences call."); |
| 2092 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2093 | if ((m_device->queue_props.empty()) || |
| 2094 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2095 | return; |
| 2096 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2097 | m_errorMonitor->ExpectSuccess(); |
| 2098 | |
| 2099 | VkFence fence; |
| 2100 | VkFenceCreateInfo fence_create_info{}; |
| 2101 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2102 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2103 | |
| 2104 | VkSemaphore semaphore; |
| 2105 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2106 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2107 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2108 | &semaphore); |
| 2109 | |
| 2110 | VkCommandPool command_pool; |
| 2111 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2112 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2113 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2114 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2115 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2116 | &command_pool); |
| 2117 | |
| 2118 | VkCommandBuffer command_buffer[2]; |
| 2119 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2120 | command_buffer_allocate_info.sType = |
| 2121 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2122 | command_buffer_allocate_info.commandPool = command_pool; |
| 2123 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2124 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2125 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2126 | command_buffer); |
| 2127 | |
| 2128 | VkQueue queue = VK_NULL_HANDLE; |
| 2129 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2130 | 1, &queue); |
| 2131 | |
| 2132 | |
| 2133 | { |
| 2134 | VkCommandBufferBeginInfo begin_info{}; |
| 2135 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2136 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2137 | |
| 2138 | vkCmdPipelineBarrier(command_buffer[0], |
| 2139 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2140 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2141 | 0, nullptr, 0, nullptr); |
| 2142 | |
| 2143 | VkViewport viewport{}; |
| 2144 | viewport.maxDepth = 1.0f; |
| 2145 | viewport.minDepth = 0.0f; |
| 2146 | viewport.width = 512; |
| 2147 | viewport.height = 512; |
| 2148 | viewport.x = 0; |
| 2149 | viewport.y = 0; |
| 2150 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2151 | vkEndCommandBuffer(command_buffer[0]); |
| 2152 | } |
| 2153 | { |
| 2154 | VkCommandBufferBeginInfo begin_info{}; |
| 2155 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2156 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2157 | |
| 2158 | VkViewport viewport{}; |
| 2159 | viewport.maxDepth = 1.0f; |
| 2160 | viewport.minDepth = 0.0f; |
| 2161 | viewport.width = 512; |
| 2162 | viewport.height = 512; |
| 2163 | viewport.x = 0; |
| 2164 | viewport.y = 0; |
| 2165 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2166 | vkEndCommandBuffer(command_buffer[1]); |
| 2167 | } |
| 2168 | { |
| 2169 | VkSubmitInfo submit_info{}; |
| 2170 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2171 | submit_info.commandBufferCount = 1; |
| 2172 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2173 | submit_info.signalSemaphoreCount = 1; |
| 2174 | submit_info.pSignalSemaphores = &semaphore; |
| 2175 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2176 | } |
| 2177 | { |
| 2178 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2179 | VkSubmitInfo submit_info{}; |
| 2180 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2181 | submit_info.commandBufferCount = 1; |
| 2182 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2183 | submit_info.waitSemaphoreCount = 1; |
| 2184 | submit_info.pWaitSemaphores = &semaphore; |
| 2185 | submit_info.pWaitDstStageMask = flags; |
| 2186 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2187 | } |
| 2188 | |
| 2189 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2190 | |
| 2191 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2192 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2193 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2194 | &command_buffer[0]); |
| 2195 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2196 | |
| 2197 | m_errorMonitor->VerifyNotFound(); |
| 2198 | } |
| 2199 | |
| 2200 | // This is a positive test. No errors should be generated. |
| 2201 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2202 | |
| 2203 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2204 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2205 | "second having a fence, " |
| 2206 | "followed by a WaitForFences call."); |
| 2207 | |
| 2208 | m_errorMonitor->ExpectSuccess(); |
| 2209 | |
| 2210 | VkFence fence; |
| 2211 | VkFenceCreateInfo fence_create_info{}; |
| 2212 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2213 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2214 | |
| 2215 | VkSemaphore semaphore; |
| 2216 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2217 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2218 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2219 | &semaphore); |
| 2220 | |
| 2221 | VkCommandPool command_pool; |
| 2222 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2223 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2224 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2225 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2226 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2227 | &command_pool); |
| 2228 | |
| 2229 | VkCommandBuffer command_buffer[2]; |
| 2230 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2231 | command_buffer_allocate_info.sType = |
| 2232 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2233 | command_buffer_allocate_info.commandPool = command_pool; |
| 2234 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2235 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2236 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2237 | command_buffer); |
| 2238 | |
| 2239 | { |
| 2240 | VkCommandBufferBeginInfo begin_info{}; |
| 2241 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2242 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2243 | |
| 2244 | vkCmdPipelineBarrier(command_buffer[0], |
| 2245 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2246 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2247 | 0, nullptr, 0, nullptr); |
| 2248 | |
| 2249 | VkViewport viewport{}; |
| 2250 | viewport.maxDepth = 1.0f; |
| 2251 | viewport.minDepth = 0.0f; |
| 2252 | viewport.width = 512; |
| 2253 | viewport.height = 512; |
| 2254 | viewport.x = 0; |
| 2255 | viewport.y = 0; |
| 2256 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2257 | vkEndCommandBuffer(command_buffer[0]); |
| 2258 | } |
| 2259 | { |
| 2260 | VkCommandBufferBeginInfo begin_info{}; |
| 2261 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2262 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2263 | |
| 2264 | VkViewport viewport{}; |
| 2265 | viewport.maxDepth = 1.0f; |
| 2266 | viewport.minDepth = 0.0f; |
| 2267 | viewport.width = 512; |
| 2268 | viewport.height = 512; |
| 2269 | viewport.x = 0; |
| 2270 | viewport.y = 0; |
| 2271 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2272 | vkEndCommandBuffer(command_buffer[1]); |
| 2273 | } |
| 2274 | { |
| 2275 | VkSubmitInfo submit_info{}; |
| 2276 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2277 | submit_info.commandBufferCount = 1; |
| 2278 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2279 | submit_info.signalSemaphoreCount = 1; |
| 2280 | submit_info.pSignalSemaphores = &semaphore; |
| 2281 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2282 | } |
| 2283 | { |
| 2284 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2285 | VkSubmitInfo submit_info{}; |
| 2286 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2287 | submit_info.commandBufferCount = 1; |
| 2288 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2289 | submit_info.waitSemaphoreCount = 1; |
| 2290 | submit_info.pWaitSemaphores = &semaphore; |
| 2291 | submit_info.pWaitDstStageMask = flags; |
| 2292 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2293 | } |
| 2294 | |
| 2295 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2296 | |
| 2297 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2298 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2299 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2300 | &command_buffer[0]); |
| 2301 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2302 | |
| 2303 | m_errorMonitor->VerifyNotFound(); |
| 2304 | } |
| 2305 | |
| 2306 | // This is a positive test. No errors should be generated. |
| 2307 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2308 | |
| 2309 | TEST_DESCRIPTION( |
| 2310 | "Two command buffers, each in a separate QueueSubmit call " |
| 2311 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2312 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2313 | |
| 2314 | m_errorMonitor->ExpectSuccess(); |
| 2315 | |
| 2316 | VkFence fence; |
| 2317 | VkFenceCreateInfo fence_create_info{}; |
| 2318 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2319 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2320 | |
| 2321 | VkCommandPool command_pool; |
| 2322 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2323 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2324 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2325 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2326 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2327 | &command_pool); |
| 2328 | |
| 2329 | VkCommandBuffer command_buffer[2]; |
| 2330 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2331 | command_buffer_allocate_info.sType = |
| 2332 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2333 | command_buffer_allocate_info.commandPool = command_pool; |
| 2334 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2335 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2336 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2337 | command_buffer); |
| 2338 | |
| 2339 | { |
| 2340 | VkCommandBufferBeginInfo begin_info{}; |
| 2341 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2342 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2343 | |
| 2344 | vkCmdPipelineBarrier(command_buffer[0], |
| 2345 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2346 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2347 | 0, nullptr, 0, nullptr); |
| 2348 | |
| 2349 | VkViewport viewport{}; |
| 2350 | viewport.maxDepth = 1.0f; |
| 2351 | viewport.minDepth = 0.0f; |
| 2352 | viewport.width = 512; |
| 2353 | viewport.height = 512; |
| 2354 | viewport.x = 0; |
| 2355 | viewport.y = 0; |
| 2356 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2357 | vkEndCommandBuffer(command_buffer[0]); |
| 2358 | } |
| 2359 | { |
| 2360 | VkCommandBufferBeginInfo begin_info{}; |
| 2361 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2362 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2363 | |
| 2364 | VkViewport viewport{}; |
| 2365 | viewport.maxDepth = 1.0f; |
| 2366 | viewport.minDepth = 0.0f; |
| 2367 | viewport.width = 512; |
| 2368 | viewport.height = 512; |
| 2369 | viewport.x = 0; |
| 2370 | viewport.y = 0; |
| 2371 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2372 | vkEndCommandBuffer(command_buffer[1]); |
| 2373 | } |
| 2374 | { |
| 2375 | VkSubmitInfo submit_info{}; |
| 2376 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2377 | submit_info.commandBufferCount = 1; |
| 2378 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2379 | submit_info.signalSemaphoreCount = 0; |
| 2380 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2381 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2382 | } |
| 2383 | { |
| 2384 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2385 | VkSubmitInfo submit_info{}; |
| 2386 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2387 | submit_info.commandBufferCount = 1; |
| 2388 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2389 | submit_info.waitSemaphoreCount = 0; |
| 2390 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2391 | submit_info.pWaitDstStageMask = flags; |
| 2392 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2393 | } |
| 2394 | |
| 2395 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2396 | |
| 2397 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2398 | |
| 2399 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2400 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2401 | &command_buffer[0]); |
| 2402 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2403 | |
| 2404 | m_errorMonitor->VerifyNotFound(); |
| 2405 | } |
| 2406 | |
| 2407 | // This is a positive test. No errors should be generated. |
| 2408 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2409 | |
| 2410 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2411 | "on the same queue, the second having a fence, followed " |
| 2412 | "by a WaitForFences call."); |
| 2413 | |
| 2414 | m_errorMonitor->ExpectSuccess(); |
| 2415 | |
| 2416 | VkFence fence; |
| 2417 | VkFenceCreateInfo fence_create_info{}; |
| 2418 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2419 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2420 | |
| 2421 | VkCommandPool command_pool; |
| 2422 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2423 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2424 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2425 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2426 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2427 | &command_pool); |
| 2428 | |
| 2429 | VkCommandBuffer command_buffer[2]; |
| 2430 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2431 | command_buffer_allocate_info.sType = |
| 2432 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2433 | command_buffer_allocate_info.commandPool = command_pool; |
| 2434 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2435 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2436 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2437 | command_buffer); |
| 2438 | |
| 2439 | { |
| 2440 | VkCommandBufferBeginInfo begin_info{}; |
| 2441 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2442 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2443 | |
| 2444 | vkCmdPipelineBarrier(command_buffer[0], |
| 2445 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2446 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2447 | 0, nullptr, 0, nullptr); |
| 2448 | |
| 2449 | VkViewport viewport{}; |
| 2450 | viewport.maxDepth = 1.0f; |
| 2451 | viewport.minDepth = 0.0f; |
| 2452 | viewport.width = 512; |
| 2453 | viewport.height = 512; |
| 2454 | viewport.x = 0; |
| 2455 | viewport.y = 0; |
| 2456 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2457 | vkEndCommandBuffer(command_buffer[0]); |
| 2458 | } |
| 2459 | { |
| 2460 | VkCommandBufferBeginInfo begin_info{}; |
| 2461 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2462 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2463 | |
| 2464 | VkViewport viewport{}; |
| 2465 | viewport.maxDepth = 1.0f; |
| 2466 | viewport.minDepth = 0.0f; |
| 2467 | viewport.width = 512; |
| 2468 | viewport.height = 512; |
| 2469 | viewport.x = 0; |
| 2470 | viewport.y = 0; |
| 2471 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2472 | vkEndCommandBuffer(command_buffer[1]); |
| 2473 | } |
| 2474 | { |
| 2475 | VkSubmitInfo submit_info{}; |
| 2476 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2477 | submit_info.commandBufferCount = 1; |
| 2478 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2479 | submit_info.signalSemaphoreCount = 0; |
| 2480 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2481 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2482 | } |
| 2483 | { |
| 2484 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2485 | VkSubmitInfo submit_info{}; |
| 2486 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2487 | submit_info.commandBufferCount = 1; |
| 2488 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2489 | submit_info.waitSemaphoreCount = 0; |
| 2490 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2491 | submit_info.pWaitDstStageMask = flags; |
| 2492 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2493 | } |
| 2494 | |
| 2495 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2496 | |
| 2497 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2498 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2499 | &command_buffer[0]); |
| 2500 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2501 | |
| 2502 | m_errorMonitor->VerifyNotFound(); |
| 2503 | } |
| 2504 | |
| 2505 | // This is a positive test. No errors should be generated. |
| 2506 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2507 | |
| 2508 | TEST_DESCRIPTION( |
| 2509 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2510 | "QueueSubmit call followed by a WaitForFences call."); |
| 2511 | |
| 2512 | m_errorMonitor->ExpectSuccess(); |
| 2513 | |
| 2514 | VkFence fence; |
| 2515 | VkFenceCreateInfo fence_create_info{}; |
| 2516 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2517 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2518 | |
| 2519 | VkSemaphore semaphore; |
| 2520 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2521 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2522 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2523 | &semaphore); |
| 2524 | |
| 2525 | VkCommandPool command_pool; |
| 2526 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2527 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2528 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2529 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2530 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2531 | &command_pool); |
| 2532 | |
| 2533 | VkCommandBuffer command_buffer[2]; |
| 2534 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2535 | command_buffer_allocate_info.sType = |
| 2536 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2537 | command_buffer_allocate_info.commandPool = command_pool; |
| 2538 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2539 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2540 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2541 | command_buffer); |
| 2542 | |
| 2543 | { |
| 2544 | VkCommandBufferBeginInfo begin_info{}; |
| 2545 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2546 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2547 | |
| 2548 | vkCmdPipelineBarrier(command_buffer[0], |
| 2549 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2550 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2551 | 0, nullptr, 0, nullptr); |
| 2552 | |
| 2553 | VkViewport viewport{}; |
| 2554 | viewport.maxDepth = 1.0f; |
| 2555 | viewport.minDepth = 0.0f; |
| 2556 | viewport.width = 512; |
| 2557 | viewport.height = 512; |
| 2558 | viewport.x = 0; |
| 2559 | viewport.y = 0; |
| 2560 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2561 | vkEndCommandBuffer(command_buffer[0]); |
| 2562 | } |
| 2563 | { |
| 2564 | VkCommandBufferBeginInfo begin_info{}; |
| 2565 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2566 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2567 | |
| 2568 | VkViewport viewport{}; |
| 2569 | viewport.maxDepth = 1.0f; |
| 2570 | viewport.minDepth = 0.0f; |
| 2571 | viewport.width = 512; |
| 2572 | viewport.height = 512; |
| 2573 | viewport.x = 0; |
| 2574 | viewport.y = 0; |
| 2575 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2576 | vkEndCommandBuffer(command_buffer[1]); |
| 2577 | } |
| 2578 | { |
| 2579 | VkSubmitInfo submit_info[2]; |
| 2580 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2581 | |
| 2582 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2583 | submit_info[0].pNext = NULL; |
| 2584 | submit_info[0].commandBufferCount = 1; |
| 2585 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2586 | submit_info[0].signalSemaphoreCount = 1; |
| 2587 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2588 | submit_info[0].waitSemaphoreCount = 0; |
| 2589 | submit_info[0].pWaitSemaphores = NULL; |
| 2590 | submit_info[0].pWaitDstStageMask = 0; |
| 2591 | |
| 2592 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2593 | submit_info[1].pNext = NULL; |
| 2594 | submit_info[1].commandBufferCount = 1; |
| 2595 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2596 | submit_info[1].waitSemaphoreCount = 1; |
| 2597 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2598 | submit_info[1].pWaitDstStageMask = flags; |
| 2599 | submit_info[1].signalSemaphoreCount = 0; |
| 2600 | submit_info[1].pSignalSemaphores = NULL; |
| 2601 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2602 | } |
| 2603 | |
| 2604 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2605 | |
| 2606 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2607 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2608 | &command_buffer[0]); |
| 2609 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2610 | |
| 2611 | m_errorMonitor->VerifyNotFound(); |
| 2612 | } |
| 2613 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2614 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2615 | TEST_DESCRIPTION( |
| 2616 | "Run a series of simple draw calls to validate all the different " |
| 2617 | "failure cases that can occur when dynamic state is required but not " |
| 2618 | "correctly bound." |
| 2619 | "Here are the different dynamic state cases verified by this test:\n" |
| 2620 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2621 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2622 | "Mask\n-Stencil Reference"); |
| 2623 | |
| 2624 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2625 | m_errorMonitor->SetDesiredFailureMsg( |
| 2626 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2627 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2628 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2629 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2630 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2631 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2632 | m_errorMonitor->SetDesiredFailureMsg( |
| 2633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2634 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2635 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2636 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2637 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2638 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2639 | m_errorMonitor->SetDesiredFailureMsg( |
| 2640 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2641 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2642 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2643 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2644 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2645 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | m_errorMonitor->SetDesiredFailureMsg( |
| 2647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2648 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2649 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2650 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2651 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2652 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2653 | m_errorMonitor->SetDesiredFailureMsg( |
| 2654 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2655 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2656 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2657 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2658 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2659 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2660 | m_errorMonitor->SetDesiredFailureMsg( |
| 2661 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2662 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2663 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2664 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2665 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2666 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2667 | m_errorMonitor->SetDesiredFailureMsg( |
| 2668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2669 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2670 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2671 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2672 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2673 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2674 | m_errorMonitor->SetDesiredFailureMsg( |
| 2675 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2676 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2677 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2678 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2679 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2680 | } |
| 2681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2682 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2683 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2685 | m_errorMonitor->SetDesiredFailureMsg( |
| 2686 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2687 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2688 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2689 | |
| 2690 | VkFenceCreateInfo fenceInfo = {}; |
| 2691 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2692 | fenceInfo.pNext = NULL; |
| 2693 | fenceInfo.flags = 0; |
| 2694 | |
| 2695 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2696 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2697 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2699 | // We luck out b/c by default the framework creates CB w/ the |
| 2700 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2701 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2702 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2703 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2704 | EndCommandBuffer(); |
| 2705 | |
| 2706 | testFence.init(*m_device, fenceInfo); |
| 2707 | |
| 2708 | // Bypass framework since it does the waits automatically |
| 2709 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2710 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2711 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2712 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2713 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2714 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2715 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2716 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2717 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2718 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2719 | submit_info.pSignalSemaphores = NULL; |
| 2720 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2721 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2722 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2725 | // submitted once |
| 2726 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2727 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2728 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2729 | } |
| 2730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2732 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2733 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2734 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2735 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2736 | "Unable to allocate 1 descriptors of " |
| 2737 | "type " |
| 2738 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2739 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2740 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2741 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2743 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2744 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2745 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2746 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2747 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2748 | |
| 2749 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2750 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2751 | ds_pool_ci.pNext = NULL; |
| 2752 | ds_pool_ci.flags = 0; |
| 2753 | ds_pool_ci.maxSets = 1; |
| 2754 | ds_pool_ci.poolSizeCount = 1; |
| 2755 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2756 | |
| 2757 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2758 | err = |
| 2759 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2760 | ASSERT_VK_SUCCESS(err); |
| 2761 | |
| 2762 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2763 | dsl_binding.binding = 0; |
| 2764 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2765 | dsl_binding.descriptorCount = 1; |
| 2766 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2767 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2768 | |
| 2769 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2770 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2771 | ds_layout_ci.pNext = NULL; |
| 2772 | ds_layout_ci.bindingCount = 1; |
| 2773 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2774 | |
| 2775 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2776 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2777 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2778 | ASSERT_VK_SUCCESS(err); |
| 2779 | |
| 2780 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2781 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2782 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2783 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2784 | alloc_info.descriptorPool = ds_pool; |
| 2785 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2787 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2788 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2789 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2790 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2791 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2792 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2793 | } |
| 2794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2795 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2796 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2797 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | m_errorMonitor->SetDesiredFailureMsg( |
| 2799 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2800 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2801 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2802 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2803 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2804 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2805 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2806 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2807 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2808 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2809 | |
| 2810 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2811 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2812 | ds_pool_ci.pNext = NULL; |
| 2813 | ds_pool_ci.maxSets = 1; |
| 2814 | ds_pool_ci.poolSizeCount = 1; |
| 2815 | ds_pool_ci.flags = 0; |
| 2816 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2817 | // app can only call vkResetDescriptorPool on this pool.; |
| 2818 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2819 | |
| 2820 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2821 | err = |
| 2822 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2823 | ASSERT_VK_SUCCESS(err); |
| 2824 | |
| 2825 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2826 | dsl_binding.binding = 0; |
| 2827 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2828 | dsl_binding.descriptorCount = 1; |
| 2829 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2830 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2831 | |
| 2832 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2833 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2834 | ds_layout_ci.pNext = NULL; |
| 2835 | ds_layout_ci.bindingCount = 1; |
| 2836 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2837 | |
| 2838 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2840 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2841 | ASSERT_VK_SUCCESS(err); |
| 2842 | |
| 2843 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2844 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2845 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2846 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2847 | alloc_info.descriptorPool = ds_pool; |
| 2848 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2849 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2850 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2851 | ASSERT_VK_SUCCESS(err); |
| 2852 | |
| 2853 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2854 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2855 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2856 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2857 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2858 | } |
| 2859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2860 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2861 | // Attempt to clear Descriptor Pool with bad object. |
| 2862 | // ObjectTracker should catch this. |
| 2863 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2864 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 2865 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 2866 | vkResetDescriptorPool(device(), badPool, 0); |
| 2867 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2868 | } |
| 2869 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2870 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2871 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2872 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2873 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2874 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 2875 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 2876 | VkResult err; |
| 2877 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2878 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2879 | |
| 2880 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2881 | |
| 2882 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2883 | layout_bindings[0].binding = 0; |
| 2884 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2885 | layout_bindings[0].descriptorCount = 1; |
| 2886 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2887 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2888 | |
| 2889 | VkDescriptorSetLayout descriptor_set_layout; |
| 2890 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2891 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2892 | dslci.pNext = NULL; |
| 2893 | dslci.bindingCount = 1; |
| 2894 | dslci.pBindings = layout_bindings; |
| 2895 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2896 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2897 | |
| 2898 | VkPipelineLayout pipeline_layout; |
| 2899 | VkPipelineLayoutCreateInfo plci = {}; |
| 2900 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2901 | plci.pNext = NULL; |
| 2902 | plci.setLayoutCount = 1; |
| 2903 | plci.pSetLayouts = &descriptor_set_layout; |
| 2904 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2906 | |
| 2907 | BeginCommandBuffer(); |
| 2908 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2909 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 2910 | m_errorMonitor->VerifyFound(); |
| 2911 | EndCommandBuffer(); |
| 2912 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 2913 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2914 | } |
| 2915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2916 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2917 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 2918 | // ObjectTracker should catch this. |
| 2919 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 2920 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2921 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 2922 | |
| 2923 | VkPipelineLayout pipeline_layout; |
| 2924 | VkPipelineLayoutCreateInfo plci = {}; |
| 2925 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2926 | plci.pNext = NULL; |
| 2927 | plci.setLayoutCount = 1; |
| 2928 | plci.pSetLayouts = &bad_layout; |
| 2929 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 2930 | |
| 2931 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2932 | } |
| 2933 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2934 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2935 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 2936 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2937 | // Create a valid cmd buffer |
| 2938 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2939 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 2940 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2941 | "Invalid VkPipeline Object 0xbaad6001"); |
| 2942 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2943 | BeginCommandBuffer(); |
| 2944 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2945 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 2946 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 2947 | |
| 2948 | // Now issue a draw call with no pipeline bound |
| 2949 | m_errorMonitor->SetDesiredFailureMsg( |
| 2950 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2951 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2952 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2953 | BeginCommandBuffer(); |
| 2954 | Draw(1, 0, 0, 0); |
| 2955 | m_errorMonitor->VerifyFound(); |
| 2956 | // Finally same check once more but with Dispatch/Compute |
| 2957 | m_errorMonitor->SetDesiredFailureMsg( |
| 2958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2959 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2960 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2961 | BeginCommandBuffer(); |
| 2962 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 2963 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2964 | } |
| 2965 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2966 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 2967 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 2968 | // CommandBuffer |
| 2969 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2970 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2972 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2973 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2974 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2975 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2976 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2977 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2978 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2979 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2980 | |
| 2981 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2982 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2983 | ds_pool_ci.pNext = NULL; |
| 2984 | ds_pool_ci.maxSets = 1; |
| 2985 | ds_pool_ci.poolSizeCount = 1; |
| 2986 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2987 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2988 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2989 | err = |
| 2990 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2991 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2992 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2993 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2994 | dsl_binding.binding = 0; |
| 2995 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2996 | dsl_binding.descriptorCount = 1; |
| 2997 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2998 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2999 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3000 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3001 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3002 | ds_layout_ci.pNext = NULL; |
| 3003 | ds_layout_ci.bindingCount = 1; |
| 3004 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3005 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3006 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3007 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3008 | ASSERT_VK_SUCCESS(err); |
| 3009 | |
| 3010 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3011 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3012 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3013 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3014 | alloc_info.descriptorPool = ds_pool; |
| 3015 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3016 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3017 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3018 | ASSERT_VK_SUCCESS(err); |
| 3019 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3020 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3021 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3022 | pipeline_layout_ci.pNext = NULL; |
| 3023 | pipeline_layout_ci.setLayoutCount = 1; |
| 3024 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3025 | |
| 3026 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3027 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3028 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3029 | ASSERT_VK_SUCCESS(err); |
| 3030 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3031 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3032 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3033 | // 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] | 3034 | // on more devices |
| 3035 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3036 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3037 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3038 | VkPipelineObj pipe(m_device); |
| 3039 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3040 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3041 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3042 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3043 | |
| 3044 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3045 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3046 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3047 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3048 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3049 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3050 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3051 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3052 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3053 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3054 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3055 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3056 | } |
| 3057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3058 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3059 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3060 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3062 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3063 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3064 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3065 | |
| 3066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3067 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3068 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3069 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3070 | |
| 3071 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3072 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3073 | ds_pool_ci.pNext = NULL; |
| 3074 | ds_pool_ci.maxSets = 1; |
| 3075 | ds_pool_ci.poolSizeCount = 1; |
| 3076 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3077 | |
| 3078 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3079 | err = |
| 3080 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3081 | ASSERT_VK_SUCCESS(err); |
| 3082 | |
| 3083 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3084 | dsl_binding.binding = 0; |
| 3085 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3086 | dsl_binding.descriptorCount = 1; |
| 3087 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3088 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3089 | |
| 3090 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3091 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3092 | ds_layout_ci.pNext = NULL; |
| 3093 | ds_layout_ci.bindingCount = 1; |
| 3094 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3095 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3096 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3097 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3098 | ASSERT_VK_SUCCESS(err); |
| 3099 | |
| 3100 | VkDescriptorSet descriptorSet; |
| 3101 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3102 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3103 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3104 | alloc_info.descriptorPool = ds_pool; |
| 3105 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3106 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3107 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3108 | ASSERT_VK_SUCCESS(err); |
| 3109 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3110 | VkBufferView view = |
| 3111 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3112 | VkWriteDescriptorSet descriptor_write; |
| 3113 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3114 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3115 | descriptor_write.dstSet = descriptorSet; |
| 3116 | descriptor_write.dstBinding = 0; |
| 3117 | descriptor_write.descriptorCount = 1; |
| 3118 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3119 | descriptor_write.pTexelBufferView = &view; |
| 3120 | |
| 3121 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3122 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3123 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3124 | |
| 3125 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3126 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3127 | } |
| 3128 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3129 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3130 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3131 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3132 | // 1. No dynamicOffset supplied |
| 3133 | // 2. Too many dynamicOffsets supplied |
| 3134 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3135 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3136 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3137 | " requires 1 dynamicOffsets, but only " |
| 3138 | "0 dynamicOffsets are left in " |
| 3139 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3140 | |
| 3141 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3142 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3143 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3144 | |
| 3145 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3146 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3147 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3148 | |
| 3149 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3150 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3151 | ds_pool_ci.pNext = NULL; |
| 3152 | ds_pool_ci.maxSets = 1; |
| 3153 | ds_pool_ci.poolSizeCount = 1; |
| 3154 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3155 | |
| 3156 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3157 | err = |
| 3158 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3159 | ASSERT_VK_SUCCESS(err); |
| 3160 | |
| 3161 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3162 | dsl_binding.binding = 0; |
| 3163 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3164 | dsl_binding.descriptorCount = 1; |
| 3165 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3166 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3167 | |
| 3168 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3169 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3170 | ds_layout_ci.pNext = NULL; |
| 3171 | ds_layout_ci.bindingCount = 1; |
| 3172 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3173 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3175 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3176 | ASSERT_VK_SUCCESS(err); |
| 3177 | |
| 3178 | VkDescriptorSet descriptorSet; |
| 3179 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3180 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3181 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3182 | alloc_info.descriptorPool = ds_pool; |
| 3183 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3184 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3185 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3186 | ASSERT_VK_SUCCESS(err); |
| 3187 | |
| 3188 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3189 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3190 | pipeline_layout_ci.pNext = NULL; |
| 3191 | pipeline_layout_ci.setLayoutCount = 1; |
| 3192 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3193 | |
| 3194 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3195 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3196 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3197 | ASSERT_VK_SUCCESS(err); |
| 3198 | |
| 3199 | // Create a buffer to update the descriptor with |
| 3200 | uint32_t qfi = 0; |
| 3201 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3202 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3203 | buffCI.size = 1024; |
| 3204 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3205 | buffCI.queueFamilyIndexCount = 1; |
| 3206 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3207 | |
| 3208 | VkBuffer dyub; |
| 3209 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3210 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3211 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3212 | // error |
| 3213 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3214 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3215 | mem_alloc.pNext = NULL; |
| 3216 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 3217 | mem_alloc.memoryTypeIndex = 0; |
| 3218 | |
| 3219 | VkMemoryRequirements memReqs; |
| 3220 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 3221 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 3222 | 0); |
| 3223 | if (!pass) { |
| 3224 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3225 | return; |
| 3226 | } |
| 3227 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3228 | VkDeviceMemory mem; |
| 3229 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3230 | ASSERT_VK_SUCCESS(err); |
| 3231 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3232 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3233 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3234 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3235 | buffInfo.buffer = dyub; |
| 3236 | buffInfo.offset = 0; |
| 3237 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3238 | |
| 3239 | VkWriteDescriptorSet descriptor_write; |
| 3240 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3241 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3242 | descriptor_write.dstSet = descriptorSet; |
| 3243 | descriptor_write.dstBinding = 0; |
| 3244 | descriptor_write.descriptorCount = 1; |
| 3245 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3246 | descriptor_write.pBufferInfo = &buffInfo; |
| 3247 | |
| 3248 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3249 | |
| 3250 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3252 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3253 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3254 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3255 | uint32_t pDynOff[2] = {512, 756}; |
| 3256 | // 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] | 3257 | m_errorMonitor->SetDesiredFailureMsg( |
| 3258 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3259 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3260 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3261 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3262 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3263 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3264 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3265 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3266 | " dynamic offset 512 combined with " |
| 3267 | "offset 0 and range 1024 that " |
| 3268 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3269 | // Create PSO to be used for draw-time errors below |
| 3270 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3271 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3272 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3273 | "out gl_PerVertex { \n" |
| 3274 | " vec4 gl_Position;\n" |
| 3275 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3276 | "void main(){\n" |
| 3277 | " gl_Position = vec4(1);\n" |
| 3278 | "}\n"; |
| 3279 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3280 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3281 | "\n" |
| 3282 | "layout(location=0) out vec4 x;\n" |
| 3283 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3284 | "void main(){\n" |
| 3285 | " x = vec4(bar.y);\n" |
| 3286 | "}\n"; |
| 3287 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3288 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3289 | VkPipelineObj pipe(m_device); |
| 3290 | pipe.AddShader(&vs); |
| 3291 | pipe.AddShader(&fs); |
| 3292 | pipe.AddColorAttachment(); |
| 3293 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3294 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3295 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3296 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3297 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3298 | // /w range 1024 & size 1024 |
| 3299 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3300 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3301 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3302 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3303 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3304 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3305 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3306 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3307 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3308 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3309 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3310 | } |
| 3311 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3312 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3313 | // Hit push constant error cases: |
| 3314 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3315 | // 2. Incorrectly set push constant size to 0 |
| 3316 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3317 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3318 | VkResult err; |
| 3319 | m_errorMonitor->SetDesiredFailureMsg( |
| 3320 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3321 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3322 | |
| 3323 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3324 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3325 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3326 | |
| 3327 | VkPushConstantRange pc_range = {}; |
| 3328 | pc_range.size = 0xFFFFFFFFu; |
| 3329 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3330 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3331 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3332 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3333 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3334 | |
| 3335 | VkPipelineLayout pipeline_layout; |
| 3336 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3337 | &pipeline_layout); |
| 3338 | |
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 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3341 | pc_range.size = 0; |
| 3342 | m_errorMonitor->SetDesiredFailureMsg( |
| 3343 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3344 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3345 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3346 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3347 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3348 | pc_range.size = 1; |
| 3349 | m_errorMonitor->SetDesiredFailureMsg( |
| 3350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3351 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3352 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3353 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3354 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3355 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3356 | m_errorMonitor->SetDesiredFailureMsg( |
| 3357 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3358 | "vkCmdPushConstants() call has push constants with offset "); |
| 3359 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3360 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3361 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3362 | &pipeline_layout); |
| 3363 | ASSERT_VK_SUCCESS(err); |
| 3364 | BeginCommandBuffer(); |
| 3365 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3366 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3367 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3368 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3369 | } |
| 3370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3371 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3372 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3373 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3374 | |
| 3375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3376 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3377 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3378 | |
| 3379 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3380 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3381 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3382 | ds_type_count[0].descriptorCount = 10; |
| 3383 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3384 | ds_type_count[1].descriptorCount = 2; |
| 3385 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3386 | ds_type_count[2].descriptorCount = 2; |
| 3387 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3388 | ds_type_count[3].descriptorCount = 5; |
| 3389 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3390 | // type |
| 3391 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3392 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3393 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3394 | |
| 3395 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3396 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3397 | ds_pool_ci.pNext = NULL; |
| 3398 | ds_pool_ci.maxSets = 5; |
| 3399 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3400 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3401 | |
| 3402 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3403 | err = |
| 3404 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3405 | ASSERT_VK_SUCCESS(err); |
| 3406 | |
| 3407 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3408 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3409 | dsl_binding[0].binding = 0; |
| 3410 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3411 | dsl_binding[0].descriptorCount = 5; |
| 3412 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3413 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3414 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3415 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3416 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | dsl_fs_stage_only.binding = 0; |
| 3418 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3419 | dsl_fs_stage_only.descriptorCount = 5; |
| 3420 | dsl_fs_stage_only.stageFlags = |
| 3421 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3422 | // bind time |
| 3423 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3424 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3425 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3426 | ds_layout_ci.pNext = NULL; |
| 3427 | ds_layout_ci.bindingCount = 1; |
| 3428 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3429 | static const uint32_t NUM_LAYOUTS = 4; |
| 3430 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3431 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3432 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3433 | // layout for error case |
| 3434 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3435 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3436 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3437 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3438 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3439 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3440 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3441 | dsl_binding[0].binding = 0; |
| 3442 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3443 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3444 | dsl_binding[1].binding = 1; |
| 3445 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3446 | dsl_binding[1].descriptorCount = 2; |
| 3447 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3448 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3449 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3450 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3451 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3452 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3453 | ASSERT_VK_SUCCESS(err); |
| 3454 | dsl_binding[0].binding = 0; |
| 3455 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3456 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3457 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3458 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3459 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3460 | ASSERT_VK_SUCCESS(err); |
| 3461 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3462 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3463 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3464 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3465 | ASSERT_VK_SUCCESS(err); |
| 3466 | |
| 3467 | static const uint32_t NUM_SETS = 4; |
| 3468 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3469 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3470 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3471 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3472 | alloc_info.descriptorPool = ds_pool; |
| 3473 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3474 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3475 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3476 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3477 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3478 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3479 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3480 | err = |
| 3481 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3482 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3483 | |
| 3484 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3485 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3486 | pipeline_layout_ci.pNext = NULL; |
| 3487 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3488 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3489 | |
| 3490 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3491 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3492 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3493 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3494 | // Create pipelineLayout with only one setLayout |
| 3495 | pipeline_layout_ci.setLayoutCount = 1; |
| 3496 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3497 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3498 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3499 | ASSERT_VK_SUCCESS(err); |
| 3500 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3501 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3502 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3503 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3504 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3505 | ASSERT_VK_SUCCESS(err); |
| 3506 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3507 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3508 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3509 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3510 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3511 | ASSERT_VK_SUCCESS(err); |
| 3512 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3513 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3514 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3515 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3516 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3517 | ASSERT_VK_SUCCESS(err); |
| 3518 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3519 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3520 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3521 | pl_bad_s0[1] = ds_layout[1]; |
| 3522 | pipeline_layout_ci.setLayoutCount = 2; |
| 3523 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3524 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3525 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3526 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3527 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3528 | |
| 3529 | // Create a buffer to update the descriptor with |
| 3530 | uint32_t qfi = 0; |
| 3531 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3532 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3533 | buffCI.size = 1024; |
| 3534 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3535 | buffCI.queueFamilyIndexCount = 1; |
| 3536 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3537 | |
| 3538 | VkBuffer dyub; |
| 3539 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3540 | ASSERT_VK_SUCCESS(err); |
| 3541 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3542 | static const uint32_t NUM_BUFFS = 5; |
| 3543 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3544 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3545 | buffInfo[i].buffer = dyub; |
| 3546 | buffInfo[i].offset = 0; |
| 3547 | buffInfo[i].range = 1024; |
| 3548 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3549 | VkImage image; |
| 3550 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3551 | const int32_t tex_width = 32; |
| 3552 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3553 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3554 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3555 | image_create_info.pNext = NULL; |
| 3556 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3557 | image_create_info.format = tex_format; |
| 3558 | image_create_info.extent.width = tex_width; |
| 3559 | image_create_info.extent.height = tex_height; |
| 3560 | image_create_info.extent.depth = 1; |
| 3561 | image_create_info.mipLevels = 1; |
| 3562 | image_create_info.arrayLayers = 1; |
| 3563 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3564 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3565 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3566 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3567 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3568 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3570 | VkMemoryRequirements memReqs; |
| 3571 | VkDeviceMemory imageMem; |
| 3572 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3573 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3574 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3575 | memAlloc.pNext = NULL; |
| 3576 | memAlloc.allocationSize = 0; |
| 3577 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3578 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3579 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3580 | pass = |
| 3581 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3582 | ASSERT_TRUE(pass); |
| 3583 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3584 | ASSERT_VK_SUCCESS(err); |
| 3585 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3586 | ASSERT_VK_SUCCESS(err); |
| 3587 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3588 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3589 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3590 | image_view_create_info.image = image; |
| 3591 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3592 | image_view_create_info.format = tex_format; |
| 3593 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3594 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3595 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3596 | image_view_create_info.subresourceRange.aspectMask = |
| 3597 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3598 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3599 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3601 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3602 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3603 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3604 | imageInfo[0].imageView = view; |
| 3605 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3606 | imageInfo[1].imageView = view; |
| 3607 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3608 | imageInfo[2].imageView = view; |
| 3609 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3610 | imageInfo[3].imageView = view; |
| 3611 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3612 | |
| 3613 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3614 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3615 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3616 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3617 | descriptor_write[0].dstBinding = 0; |
| 3618 | descriptor_write[0].descriptorCount = 5; |
| 3619 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3620 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3621 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3622 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3623 | descriptor_write[1].dstBinding = 0; |
| 3624 | descriptor_write[1].descriptorCount = 2; |
| 3625 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3626 | descriptor_write[1].pImageInfo = imageInfo; |
| 3627 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3628 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3629 | descriptor_write[2].dstBinding = 1; |
| 3630 | descriptor_write[2].descriptorCount = 2; |
| 3631 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3632 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3633 | |
| 3634 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3635 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3636 | // Create PSO to be used for draw-time errors below |
| 3637 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3638 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3639 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3640 | "out gl_PerVertex {\n" |
| 3641 | " vec4 gl_Position;\n" |
| 3642 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3643 | "void main(){\n" |
| 3644 | " gl_Position = vec4(1);\n" |
| 3645 | "}\n"; |
| 3646 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3647 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3648 | "\n" |
| 3649 | "layout(location=0) out vec4 x;\n" |
| 3650 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3651 | "void main(){\n" |
| 3652 | " x = vec4(bar.y);\n" |
| 3653 | "}\n"; |
| 3654 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3655 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3656 | VkPipelineObj pipe(m_device); |
| 3657 | pipe.AddShader(&vs); |
| 3658 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3659 | pipe.AddColorAttachment(); |
| 3660 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3661 | |
| 3662 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3664 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3665 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3666 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3667 | // of PSO |
| 3668 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3669 | // cmd_pipeline.c |
| 3670 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3671 | // cmd_bind_graphics_pipeline() |
| 3672 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3673 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3674 | // First cause various verify_layout_compatibility() fails |
| 3675 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3676 | // verify_set_layout_compatibility fail cases: |
| 3677 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3679 | " due to: invalid VkPipelineLayout "); |
| 3680 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3681 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3682 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3683 | &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 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3687 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3688 | " attempting to bind set to index 1"); |
| 3689 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3690 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3691 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3692 | m_errorMonitor->VerifyFound(); |
| 3693 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3694 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3695 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3696 | // descriptors |
| 3697 | m_errorMonitor->SetDesiredFailureMsg( |
| 3698 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3699 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3700 | vkCmdBindDescriptorSets( |
| 3701 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3702 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3703 | m_errorMonitor->VerifyFound(); |
| 3704 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3705 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3706 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3707 | m_errorMonitor->SetDesiredFailureMsg( |
| 3708 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3709 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3710 | vkCmdBindDescriptorSets( |
| 3711 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3712 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3713 | m_errorMonitor->VerifyFound(); |
| 3714 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3715 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3716 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3717 | m_errorMonitor->SetDesiredFailureMsg( |
| 3718 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3719 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | vkCmdBindDescriptorSets( |
| 3721 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3722 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3723 | m_errorMonitor->VerifyFound(); |
| 3724 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3725 | // Cause INFO messages due to disturbing previously bound Sets |
| 3726 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3727 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3728 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3729 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3730 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3731 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3732 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3733 | " previously bound as set #0 was disturbed "); |
| 3734 | vkCmdBindDescriptorSets( |
| 3735 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3736 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3737 | m_errorMonitor->VerifyFound(); |
| 3738 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3739 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3740 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3741 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3742 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3743 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3744 | " newly bound as set #0 so set #1 and " |
| 3745 | "any subsequent sets were disturbed "); |
| 3746 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3747 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3748 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3749 | m_errorMonitor->VerifyFound(); |
| 3750 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3751 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3752 | // 1. Error due to not binding required set (we actually use same code as |
| 3753 | // above to disturb set0) |
| 3754 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3755 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3756 | 2, &descriptorSet[0], 0, NULL); |
| 3757 | vkCmdBindDescriptorSets( |
| 3758 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3759 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3760 | m_errorMonitor->SetDesiredFailureMsg( |
| 3761 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3762 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3763 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3764 | m_errorMonitor->VerifyFound(); |
| 3765 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3766 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3767 | // 2. Error due to bound set not being compatible with PSO's |
| 3768 | // VkPipelineLayout (diff stageFlags in this case) |
| 3769 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3770 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3771 | 2, &descriptorSet[0], 0, NULL); |
| 3772 | m_errorMonitor->SetDesiredFailureMsg( |
| 3773 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3774 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3775 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3776 | m_errorMonitor->VerifyFound(); |
| 3777 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3778 | // Remaining clean-up |
| 3779 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3780 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3781 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3782 | } |
| 3783 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 3784 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 3785 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3786 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3787 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3788 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3789 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3790 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3791 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3792 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3793 | m_errorMonitor->SetDesiredFailureMsg( |
| 3794 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3795 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3796 | |
| 3797 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3798 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3799 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3800 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3801 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3802 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3803 | } |
| 3804 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3805 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3806 | VkResult err; |
| 3807 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3809 | m_errorMonitor->SetDesiredFailureMsg( |
| 3810 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3811 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3812 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3813 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3814 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3815 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3816 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3817 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3818 | cmd.commandPool = m_commandPool; |
| 3819 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3820 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3821 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3822 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3823 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3824 | |
| 3825 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3826 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3827 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3828 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3829 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3830 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3831 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3832 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3833 | |
| 3834 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3835 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3836 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3837 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3838 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3839 | } |
| 3840 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3841 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3842 | // Cause error due to Begin while recording CB |
| 3843 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3844 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3845 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3847 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3848 | |
| 3849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3850 | |
| 3851 | // Calls AllocateCommandBuffers |
| 3852 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3853 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3854 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3855 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3856 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3857 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3858 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3859 | cmd_buf_info.pNext = NULL; |
| 3860 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3861 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3862 | |
| 3863 | // Begin CB to transition to recording state |
| 3864 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3865 | // Can't re-begin. This should trigger error |
| 3866 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3867 | m_errorMonitor->VerifyFound(); |
| 3868 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3869 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3870 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3871 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3872 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3873 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3874 | m_errorMonitor->VerifyFound(); |
| 3875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3876 | m_errorMonitor->SetDesiredFailureMsg( |
| 3877 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3878 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3879 | // Transition CB to RECORDED state |
| 3880 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3881 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3882 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3883 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3884 | } |
| 3885 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3886 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3887 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3888 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3890 | m_errorMonitor->SetDesiredFailureMsg( |
| 3891 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3892 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3893 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3895 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3896 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3897 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3898 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3899 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3900 | |
| 3901 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3902 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3903 | ds_pool_ci.pNext = NULL; |
| 3904 | ds_pool_ci.maxSets = 1; |
| 3905 | ds_pool_ci.poolSizeCount = 1; |
| 3906 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3907 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3908 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3909 | err = |
| 3910 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3911 | ASSERT_VK_SUCCESS(err); |
| 3912 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3913 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3914 | dsl_binding.binding = 0; |
| 3915 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3916 | dsl_binding.descriptorCount = 1; |
| 3917 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3918 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3919 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3920 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3921 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3922 | ds_layout_ci.pNext = NULL; |
| 3923 | ds_layout_ci.bindingCount = 1; |
| 3924 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3925 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3926 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3927 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3928 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3929 | ASSERT_VK_SUCCESS(err); |
| 3930 | |
| 3931 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3932 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3933 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3934 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3935 | alloc_info.descriptorPool = ds_pool; |
| 3936 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3938 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3939 | ASSERT_VK_SUCCESS(err); |
| 3940 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3941 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3942 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3943 | pipeline_layout_ci.setLayoutCount = 1; |
| 3944 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3945 | |
| 3946 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3947 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3948 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3949 | ASSERT_VK_SUCCESS(err); |
| 3950 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3951 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3952 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3953 | |
| 3954 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3955 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3956 | vp_state_ci.scissorCount = 1; |
| 3957 | vp_state_ci.pScissors = ≻ |
| 3958 | vp_state_ci.viewportCount = 1; |
| 3959 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3960 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3961 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3962 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3963 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3964 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3965 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3966 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3967 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3968 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3969 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3970 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3971 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3972 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3973 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3974 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3975 | gp_ci.layout = pipeline_layout; |
| 3976 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3977 | |
| 3978 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3979 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3980 | pc_ci.initialDataSize = 0; |
| 3981 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3982 | |
| 3983 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3984 | VkPipelineCache pipelineCache; |
| 3985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3986 | err = |
| 3987 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3988 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3990 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3991 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3992 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3993 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3994 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3995 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3996 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3997 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3998 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3999 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 4000 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 4001 | { |
| 4002 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4003 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4004 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4006 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 4007 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4008 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4011 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4012 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4013 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4014 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4015 | |
| 4016 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4017 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4018 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4019 | ds_pool_ci.poolSizeCount = 1; |
| 4020 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4021 | |
| 4022 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4023 | err = vkCreateDescriptorPool(m_device->device(), |
| 4024 | 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] | 4025 | ASSERT_VK_SUCCESS(err); |
| 4026 | |
| 4027 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4028 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4029 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4030 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4031 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4032 | dsl_binding.pImmutableSamplers = NULL; |
| 4033 | |
| 4034 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4035 | ds_layout_ci.sType = |
| 4036 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4037 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4038 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4039 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4040 | |
| 4041 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4042 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4043 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4044 | ASSERT_VK_SUCCESS(err); |
| 4045 | |
| 4046 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4047 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4048 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4049 | ASSERT_VK_SUCCESS(err); |
| 4050 | |
| 4051 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4052 | pipeline_layout_ci.sType = |
| 4053 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4054 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4055 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4056 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4057 | |
| 4058 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4059 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4060 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4061 | ASSERT_VK_SUCCESS(err); |
| 4062 | |
| 4063 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4064 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4065 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4066 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4067 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4068 | // 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] | 4069 | VkShaderObj |
| 4070 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4071 | this); |
| 4072 | VkShaderObj |
| 4073 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4074 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4076 | shaderStages[0].sType = |
| 4077 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4078 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4079 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4080 | shaderStages[1].sType = |
| 4081 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4082 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4083 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4084 | shaderStages[2].sType = |
| 4085 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4086 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4087 | shaderStages[2].shader = te.handle(); |
| 4088 | |
| 4089 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | iaCI.sType = |
| 4091 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4092 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4093 | |
| 4094 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4095 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4096 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4097 | |
| 4098 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4099 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4100 | gp_ci.pNext = NULL; |
| 4101 | gp_ci.stageCount = 3; |
| 4102 | gp_ci.pStages = shaderStages; |
| 4103 | gp_ci.pVertexInputState = NULL; |
| 4104 | gp_ci.pInputAssemblyState = &iaCI; |
| 4105 | gp_ci.pTessellationState = &tsCI; |
| 4106 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4107 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4108 | gp_ci.pMultisampleState = NULL; |
| 4109 | gp_ci.pDepthStencilState = NULL; |
| 4110 | gp_ci.pColorBlendState = NULL; |
| 4111 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4112 | gp_ci.layout = pipeline_layout; |
| 4113 | gp_ci.renderPass = renderPass(); |
| 4114 | |
| 4115 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4116 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4117 | pc_ci.pNext = NULL; |
| 4118 | pc_ci.initialSize = 0; |
| 4119 | pc_ci.initialData = 0; |
| 4120 | pc_ci.maxSize = 0; |
| 4121 | |
| 4122 | VkPipeline pipeline; |
| 4123 | VkPipelineCache pipelineCache; |
| 4124 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4125 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4126 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4127 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4128 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4129 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4130 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4131 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4132 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4133 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4134 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4135 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4136 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4137 | } |
| 4138 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4139 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4141 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4143 | m_errorMonitor->SetDesiredFailureMsg( |
| 4144 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4145 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4146 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4147 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4148 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4149 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4150 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4151 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4152 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4153 | |
| 4154 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4155 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4156 | ds_pool_ci.maxSets = 1; |
| 4157 | ds_pool_ci.poolSizeCount = 1; |
| 4158 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4159 | |
| 4160 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | err = |
| 4162 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4163 | ASSERT_VK_SUCCESS(err); |
| 4164 | |
| 4165 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4166 | dsl_binding.binding = 0; |
| 4167 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4168 | dsl_binding.descriptorCount = 1; |
| 4169 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4170 | |
| 4171 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4172 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4173 | ds_layout_ci.bindingCount = 1; |
| 4174 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4175 | |
| 4176 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4177 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4178 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4179 | ASSERT_VK_SUCCESS(err); |
| 4180 | |
| 4181 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4182 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4183 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4184 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4185 | alloc_info.descriptorPool = ds_pool; |
| 4186 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4187 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4188 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4189 | ASSERT_VK_SUCCESS(err); |
| 4190 | |
| 4191 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4192 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4193 | pipeline_layout_ci.setLayoutCount = 1; |
| 4194 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4195 | |
| 4196 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4197 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4198 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4199 | ASSERT_VK_SUCCESS(err); |
| 4200 | |
| 4201 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4202 | |
| 4203 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4204 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4205 | vp_state_ci.scissorCount = 0; |
| 4206 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4207 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4208 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4209 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4210 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4211 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4212 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4213 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4214 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4215 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4216 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4217 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4218 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4219 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4221 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4222 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4223 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4224 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4225 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4226 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4227 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4228 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4229 | |
| 4230 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4231 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4232 | gp_ci.stageCount = 2; |
| 4233 | gp_ci.pStages = shaderStages; |
| 4234 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4235 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4236 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4237 | gp_ci.layout = pipeline_layout; |
| 4238 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4239 | |
| 4240 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4242 | |
| 4243 | VkPipeline pipeline; |
| 4244 | VkPipelineCache pipelineCache; |
| 4245 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4246 | err = |
| 4247 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4248 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4249 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4250 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4251 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4252 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4253 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4254 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4255 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4256 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4257 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4258 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4259 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4260 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4261 | // 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] | 4262 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4263 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4264 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4265 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4266 | m_errorMonitor->SetDesiredFailureMsg( |
| 4267 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4268 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4269 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4270 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4271 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4272 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4273 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4274 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4275 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4276 | |
| 4277 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4278 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4279 | ds_pool_ci.maxSets = 1; |
| 4280 | ds_pool_ci.poolSizeCount = 1; |
| 4281 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4282 | |
| 4283 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4284 | err = |
| 4285 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4286 | ASSERT_VK_SUCCESS(err); |
| 4287 | |
| 4288 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4289 | dsl_binding.binding = 0; |
| 4290 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4291 | dsl_binding.descriptorCount = 1; |
| 4292 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4293 | |
| 4294 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4295 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4296 | ds_layout_ci.bindingCount = 1; |
| 4297 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4298 | |
| 4299 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4300 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4301 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4302 | ASSERT_VK_SUCCESS(err); |
| 4303 | |
| 4304 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4305 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4306 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4307 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4308 | alloc_info.descriptorPool = ds_pool; |
| 4309 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4310 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4311 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4312 | ASSERT_VK_SUCCESS(err); |
| 4313 | |
| 4314 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4316 | pipeline_layout_ci.setLayoutCount = 1; |
| 4317 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4318 | |
| 4319 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4320 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4321 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4322 | ASSERT_VK_SUCCESS(err); |
| 4323 | |
| 4324 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4325 | // Set scissor as dynamic to avoid second error |
| 4326 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4328 | dyn_state_ci.dynamicStateCount = 1; |
| 4329 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4330 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4331 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4332 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4334 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4335 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4336 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4337 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4338 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4339 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4340 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4341 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4342 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4343 | |
| 4344 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4345 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4346 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4347 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4348 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4349 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4350 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4351 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4352 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4353 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4354 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4355 | gp_ci.stageCount = 2; |
| 4356 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4357 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4358 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4359 | // should cause validation error |
| 4360 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4361 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4362 | gp_ci.layout = pipeline_layout; |
| 4363 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4364 | |
| 4365 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4366 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4367 | |
| 4368 | VkPipeline pipeline; |
| 4369 | VkPipelineCache pipelineCache; |
| 4370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4371 | err = |
| 4372 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4373 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4374 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4375 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4376 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4377 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4378 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4379 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4380 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4381 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4382 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4383 | } |
| 4384 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4385 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4386 | // count |
| 4387 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4388 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | m_errorMonitor->SetDesiredFailureMsg( |
| 4391 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4392 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4393 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4395 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4396 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4397 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4399 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4400 | |
| 4401 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4402 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4403 | ds_pool_ci.maxSets = 1; |
| 4404 | ds_pool_ci.poolSizeCount = 1; |
| 4405 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4406 | |
| 4407 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4408 | err = |
| 4409 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4410 | ASSERT_VK_SUCCESS(err); |
| 4411 | |
| 4412 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4413 | dsl_binding.binding = 0; |
| 4414 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4415 | dsl_binding.descriptorCount = 1; |
| 4416 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4417 | |
| 4418 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4420 | ds_layout_ci.bindingCount = 1; |
| 4421 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4422 | |
| 4423 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4424 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4425 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4426 | ASSERT_VK_SUCCESS(err); |
| 4427 | |
| 4428 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4429 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4430 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4431 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4432 | alloc_info.descriptorPool = ds_pool; |
| 4433 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4434 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4435 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4436 | ASSERT_VK_SUCCESS(err); |
| 4437 | |
| 4438 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4439 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4440 | pipeline_layout_ci.setLayoutCount = 1; |
| 4441 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4442 | |
| 4443 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4444 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4445 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4446 | ASSERT_VK_SUCCESS(err); |
| 4447 | |
| 4448 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4449 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4450 | vp_state_ci.viewportCount = 1; |
| 4451 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4452 | vp_state_ci.scissorCount = 1; |
| 4453 | vp_state_ci.pScissors = |
| 4454 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4455 | |
| 4456 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4457 | // Set scissor as dynamic to avoid that error |
| 4458 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4459 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4460 | dyn_state_ci.dynamicStateCount = 1; |
| 4461 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4462 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4463 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4464 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4465 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4466 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4467 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4468 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4469 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4470 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4471 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4472 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4473 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4474 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4475 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4476 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4477 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4478 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4479 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4480 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4481 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4482 | |
| 4483 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4484 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4485 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4486 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4487 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4488 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4489 | rs_ci.pNext = nullptr; |
| 4490 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4491 | VkPipelineColorBlendAttachmentState att = {}; |
| 4492 | att.blendEnable = VK_FALSE; |
| 4493 | att.colorWriteMask = 0xf; |
| 4494 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4495 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4496 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4497 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4498 | cb_ci.attachmentCount = 1; |
| 4499 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4500 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4501 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4502 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4503 | gp_ci.stageCount = 2; |
| 4504 | gp_ci.pStages = shaderStages; |
| 4505 | gp_ci.pVertexInputState = &vi_ci; |
| 4506 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4507 | gp_ci.pViewportState = &vp_state_ci; |
| 4508 | gp_ci.pRasterizationState = &rs_ci; |
| 4509 | gp_ci.pColorBlendState = &cb_ci; |
| 4510 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4511 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4512 | gp_ci.layout = pipeline_layout; |
| 4513 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4514 | |
| 4515 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4516 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4517 | |
| 4518 | VkPipeline pipeline; |
| 4519 | VkPipelineCache pipelineCache; |
| 4520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4521 | err = |
| 4522 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4523 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4524 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4525 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4526 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4527 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4528 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4529 | // 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] | 4530 | // First need to successfully create the PSO from above by setting |
| 4531 | // pViewports |
| 4532 | m_errorMonitor->SetDesiredFailureMsg( |
| 4533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4534 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4535 | "scissorCount is 1. These counts must match."); |
| 4536 | |
| 4537 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4538 | vp_state_ci.pViewports = &vp; |
| 4539 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4540 | &gp_ci, NULL, &pipeline); |
| 4541 | ASSERT_VK_SUCCESS(err); |
| 4542 | BeginCommandBuffer(); |
| 4543 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4544 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4545 | VkRect2D scissors[2] = {}; // don't care about data |
| 4546 | // Count of 2 doesn't match PSO count of 1 |
| 4547 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4548 | Draw(1, 0, 0, 0); |
| 4549 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4550 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4551 | |
| 4552 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4553 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4554 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4555 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4556 | } |
| 4557 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4558 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4559 | // viewportCount |
| 4560 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4561 | VkResult err; |
| 4562 | |
| 4563 | m_errorMonitor->SetDesiredFailureMsg( |
| 4564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4565 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4566 | |
| 4567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4569 | |
| 4570 | VkDescriptorPoolSize ds_type_count = {}; |
| 4571 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4572 | ds_type_count.descriptorCount = 1; |
| 4573 | |
| 4574 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4575 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4576 | ds_pool_ci.maxSets = 1; |
| 4577 | ds_pool_ci.poolSizeCount = 1; |
| 4578 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4579 | |
| 4580 | VkDescriptorPool ds_pool; |
| 4581 | err = |
| 4582 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4583 | ASSERT_VK_SUCCESS(err); |
| 4584 | |
| 4585 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4586 | dsl_binding.binding = 0; |
| 4587 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4588 | dsl_binding.descriptorCount = 1; |
| 4589 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4590 | |
| 4591 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4592 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4593 | ds_layout_ci.bindingCount = 1; |
| 4594 | ds_layout_ci.pBindings = &dsl_binding; |
| 4595 | |
| 4596 | VkDescriptorSetLayout ds_layout; |
| 4597 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4598 | &ds_layout); |
| 4599 | ASSERT_VK_SUCCESS(err); |
| 4600 | |
| 4601 | VkDescriptorSet descriptorSet; |
| 4602 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4603 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4604 | alloc_info.descriptorSetCount = 1; |
| 4605 | alloc_info.descriptorPool = ds_pool; |
| 4606 | alloc_info.pSetLayouts = &ds_layout; |
| 4607 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4608 | &descriptorSet); |
| 4609 | ASSERT_VK_SUCCESS(err); |
| 4610 | |
| 4611 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4612 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4613 | pipeline_layout_ci.setLayoutCount = 1; |
| 4614 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4615 | |
| 4616 | VkPipelineLayout pipeline_layout; |
| 4617 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4618 | &pipeline_layout); |
| 4619 | ASSERT_VK_SUCCESS(err); |
| 4620 | |
| 4621 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4622 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4623 | vp_state_ci.scissorCount = 1; |
| 4624 | vp_state_ci.pScissors = |
| 4625 | NULL; // Null scissor w/ count of 1 should cause error |
| 4626 | vp_state_ci.viewportCount = 1; |
| 4627 | vp_state_ci.pViewports = |
| 4628 | NULL; // vp is dynamic (below) so this won't cause error |
| 4629 | |
| 4630 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4631 | // Set scissor as dynamic to avoid that error |
| 4632 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4633 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4634 | dyn_state_ci.dynamicStateCount = 1; |
| 4635 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4636 | |
| 4637 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4638 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4639 | |
| 4640 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4641 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4642 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4643 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4644 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4645 | // but add it to be able to run on more devices |
| 4646 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4647 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4648 | |
| 4649 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4650 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4651 | vi_ci.pNext = nullptr; |
| 4652 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4653 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4654 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4655 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4656 | |
| 4657 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4658 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4659 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4660 | |
| 4661 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4662 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4663 | rs_ci.pNext = nullptr; |
| 4664 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4665 | VkPipelineColorBlendAttachmentState att = {}; |
| 4666 | att.blendEnable = VK_FALSE; |
| 4667 | att.colorWriteMask = 0xf; |
| 4668 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4669 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4670 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4671 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4672 | cb_ci.attachmentCount = 1; |
| 4673 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4674 | |
| 4675 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4676 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4677 | gp_ci.stageCount = 2; |
| 4678 | gp_ci.pStages = shaderStages; |
| 4679 | gp_ci.pVertexInputState = &vi_ci; |
| 4680 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4681 | gp_ci.pViewportState = &vp_state_ci; |
| 4682 | gp_ci.pRasterizationState = &rs_ci; |
| 4683 | gp_ci.pColorBlendState = &cb_ci; |
| 4684 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4685 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4686 | gp_ci.layout = pipeline_layout; |
| 4687 | gp_ci.renderPass = renderPass(); |
| 4688 | |
| 4689 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4690 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4691 | |
| 4692 | VkPipeline pipeline; |
| 4693 | VkPipelineCache pipelineCache; |
| 4694 | |
| 4695 | err = |
| 4696 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4697 | ASSERT_VK_SUCCESS(err); |
| 4698 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4699 | &gp_ci, NULL, &pipeline); |
| 4700 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4701 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4702 | |
| 4703 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4704 | // First need to successfully create the PSO from above by setting |
| 4705 | // pViewports |
| 4706 | m_errorMonitor->SetDesiredFailureMsg( |
| 4707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4708 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4709 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4710 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4711 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4712 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4714 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4715 | ASSERT_VK_SUCCESS(err); |
| 4716 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4717 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4718 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4719 | VkViewport viewports[2] = {}; // don't care about data |
| 4720 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4721 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4722 | Draw(1, 0, 0, 0); |
| 4723 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4724 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4725 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4726 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4727 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4728 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4729 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4730 | } |
| 4731 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4732 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4733 | VkResult err; |
| 4734 | |
| 4735 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4736 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4737 | |
| 4738 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4739 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4740 | |
| 4741 | VkDescriptorPoolSize ds_type_count = {}; |
| 4742 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4743 | ds_type_count.descriptorCount = 1; |
| 4744 | |
| 4745 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4746 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4747 | ds_pool_ci.maxSets = 1; |
| 4748 | ds_pool_ci.poolSizeCount = 1; |
| 4749 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4750 | |
| 4751 | VkDescriptorPool ds_pool; |
| 4752 | err = |
| 4753 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4754 | ASSERT_VK_SUCCESS(err); |
| 4755 | |
| 4756 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4757 | dsl_binding.binding = 0; |
| 4758 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4759 | dsl_binding.descriptorCount = 1; |
| 4760 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4761 | |
| 4762 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4763 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4764 | ds_layout_ci.bindingCount = 1; |
| 4765 | ds_layout_ci.pBindings = &dsl_binding; |
| 4766 | |
| 4767 | VkDescriptorSetLayout ds_layout; |
| 4768 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4769 | &ds_layout); |
| 4770 | ASSERT_VK_SUCCESS(err); |
| 4771 | |
| 4772 | VkDescriptorSet descriptorSet; |
| 4773 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4774 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4775 | alloc_info.descriptorSetCount = 1; |
| 4776 | alloc_info.descriptorPool = ds_pool; |
| 4777 | alloc_info.pSetLayouts = &ds_layout; |
| 4778 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4779 | &descriptorSet); |
| 4780 | ASSERT_VK_SUCCESS(err); |
| 4781 | |
| 4782 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4783 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4784 | pipeline_layout_ci.setLayoutCount = 1; |
| 4785 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4786 | |
| 4787 | VkPipelineLayout pipeline_layout; |
| 4788 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4789 | &pipeline_layout); |
| 4790 | ASSERT_VK_SUCCESS(err); |
| 4791 | |
| 4792 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4793 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4794 | vp_state_ci.scissorCount = 1; |
| 4795 | vp_state_ci.pScissors = NULL; |
| 4796 | vp_state_ci.viewportCount = 1; |
| 4797 | vp_state_ci.pViewports = NULL; |
| 4798 | |
| 4799 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4800 | VK_DYNAMIC_STATE_SCISSOR, |
| 4801 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4802 | // Set scissor as dynamic to avoid that error |
| 4803 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4804 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4805 | dyn_state_ci.dynamicStateCount = 2; |
| 4806 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4807 | |
| 4808 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4809 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4810 | |
| 4811 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4812 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4813 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4814 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4815 | this); // TODO - We shouldn't need a fragment shader |
| 4816 | // but add it to be able to run on more devices |
| 4817 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4818 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4819 | |
| 4820 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4821 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4822 | vi_ci.pNext = nullptr; |
| 4823 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4824 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4825 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4826 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4827 | |
| 4828 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4829 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4830 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4831 | |
| 4832 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4833 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4834 | rs_ci.pNext = nullptr; |
| 4835 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4836 | // Check too low (line width of -1.0f). |
| 4837 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4838 | |
| 4839 | VkPipelineColorBlendAttachmentState att = {}; |
| 4840 | att.blendEnable = VK_FALSE; |
| 4841 | att.colorWriteMask = 0xf; |
| 4842 | |
| 4843 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4844 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4845 | cb_ci.pNext = nullptr; |
| 4846 | cb_ci.attachmentCount = 1; |
| 4847 | cb_ci.pAttachments = &att; |
| 4848 | |
| 4849 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4850 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4851 | gp_ci.stageCount = 2; |
| 4852 | gp_ci.pStages = shaderStages; |
| 4853 | gp_ci.pVertexInputState = &vi_ci; |
| 4854 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4855 | gp_ci.pViewportState = &vp_state_ci; |
| 4856 | gp_ci.pRasterizationState = &rs_ci; |
| 4857 | gp_ci.pColorBlendState = &cb_ci; |
| 4858 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4859 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4860 | gp_ci.layout = pipeline_layout; |
| 4861 | gp_ci.renderPass = renderPass(); |
| 4862 | |
| 4863 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4864 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4865 | |
| 4866 | VkPipeline pipeline; |
| 4867 | VkPipelineCache pipelineCache; |
| 4868 | |
| 4869 | err = |
| 4870 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4871 | ASSERT_VK_SUCCESS(err); |
| 4872 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4873 | &gp_ci, NULL, &pipeline); |
| 4874 | |
| 4875 | m_errorMonitor->VerifyFound(); |
| 4876 | |
| 4877 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4878 | "Attempt to set lineWidth to 65536"); |
| 4879 | |
| 4880 | // Check too high (line width of 65536.0f). |
| 4881 | rs_ci.lineWidth = 65536.0f; |
| 4882 | |
| 4883 | err = |
| 4884 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4885 | ASSERT_VK_SUCCESS(err); |
| 4886 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4887 | &gp_ci, NULL, &pipeline); |
| 4888 | |
| 4889 | m_errorMonitor->VerifyFound(); |
| 4890 | |
| 4891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4892 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4893 | |
| 4894 | dyn_state_ci.dynamicStateCount = 3; |
| 4895 | |
| 4896 | rs_ci.lineWidth = 1.0f; |
| 4897 | |
| 4898 | err = |
| 4899 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4900 | ASSERT_VK_SUCCESS(err); |
| 4901 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4902 | &gp_ci, NULL, &pipeline); |
| 4903 | BeginCommandBuffer(); |
| 4904 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4905 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4906 | |
| 4907 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4908 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4909 | m_errorMonitor->VerifyFound(); |
| 4910 | |
| 4911 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4912 | "Attempt to set lineWidth to 65536"); |
| 4913 | |
| 4914 | // Check too high with dynamic setting. |
| 4915 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 4916 | m_errorMonitor->VerifyFound(); |
| 4917 | EndCommandBuffer(); |
| 4918 | |
| 4919 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4920 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4921 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4922 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4923 | } |
| 4924 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4925 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4926 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4927 | m_errorMonitor->SetDesiredFailureMsg( |
| 4928 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4929 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4930 | |
| 4931 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4932 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4933 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4934 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4935 | // Don't care about RenderPass handle b/c error should be flagged before |
| 4936 | // that |
| 4937 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 4938 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4939 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4940 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4941 | } |
| 4942 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4943 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4944 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4945 | m_errorMonitor->SetDesiredFailureMsg( |
| 4946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4947 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4948 | |
| 4949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4950 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4951 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4952 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4953 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 4954 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4955 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4956 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 4957 | rp_begin.pNext = NULL; |
| 4958 | rp_begin.renderPass = renderPass(); |
| 4959 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4961 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 4962 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4964 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4965 | } |
| 4966 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4967 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4968 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4969 | m_errorMonitor->SetDesiredFailureMsg( |
| 4970 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4971 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4972 | |
| 4973 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4974 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4975 | |
| 4976 | // Renderpass is started here |
| 4977 | BeginCommandBuffer(); |
| 4978 | |
| 4979 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4980 | vk_testing::Buffer dstBuffer; |
| 4981 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4982 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4983 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4984 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4985 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4986 | } |
| 4987 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4988 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4989 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4990 | m_errorMonitor->SetDesiredFailureMsg( |
| 4991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4992 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4993 | |
| 4994 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4996 | |
| 4997 | // Renderpass is started here |
| 4998 | BeginCommandBuffer(); |
| 4999 | |
| 5000 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5001 | vk_testing::Buffer dstBuffer; |
| 5002 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5003 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5004 | VkDeviceSize dstOffset = 0; |
| 5005 | VkDeviceSize dataSize = 1024; |
| 5006 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5009 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5010 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5011 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5012 | } |
| 5013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5014 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5015 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5016 | m_errorMonitor->SetDesiredFailureMsg( |
| 5017 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5018 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5019 | |
| 5020 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5021 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5022 | |
| 5023 | // Renderpass is started here |
| 5024 | BeginCommandBuffer(); |
| 5025 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5026 | VkClearColorValue clear_color; |
| 5027 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5028 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5029 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5030 | const int32_t tex_width = 32; |
| 5031 | const int32_t tex_height = 32; |
| 5032 | VkImageCreateInfo image_create_info = {}; |
| 5033 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5034 | image_create_info.pNext = NULL; |
| 5035 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5036 | image_create_info.format = tex_format; |
| 5037 | image_create_info.extent.width = tex_width; |
| 5038 | image_create_info.extent.height = tex_height; |
| 5039 | image_create_info.extent.depth = 1; |
| 5040 | image_create_info.mipLevels = 1; |
| 5041 | image_create_info.arrayLayers = 1; |
| 5042 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5043 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5044 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5045 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5046 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5047 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5048 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5050 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5051 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5053 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5054 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5055 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5056 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5057 | } |
| 5058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5059 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5060 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5061 | m_errorMonitor->SetDesiredFailureMsg( |
| 5062 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5063 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5064 | |
| 5065 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5066 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5067 | |
| 5068 | // Renderpass is started here |
| 5069 | BeginCommandBuffer(); |
| 5070 | |
| 5071 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5072 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5073 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5074 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5075 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5076 | image_create_info.extent.width = 64; |
| 5077 | image_create_info.extent.height = 64; |
| 5078 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5079 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5080 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5081 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5082 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5083 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5085 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5086 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5087 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5088 | vkCmdClearDepthStencilImage( |
| 5089 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5090 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5091 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5092 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5093 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5094 | } |
| 5095 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5096 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5097 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5098 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5099 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5100 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5101 | "vkCmdClearAttachments: This call " |
| 5102 | "must be issued inside an active " |
| 5103 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5104 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5105 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5106 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5107 | |
| 5108 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5109 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5110 | ASSERT_VK_SUCCESS(err); |
| 5111 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5112 | VkClearAttachment color_attachment; |
| 5113 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5114 | color_attachment.clearValue.color.float32[0] = 0; |
| 5115 | color_attachment.clearValue.color.float32[1] = 0; |
| 5116 | color_attachment.clearValue.color.float32[2] = 0; |
| 5117 | color_attachment.clearValue.color.float32[3] = 0; |
| 5118 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5119 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5120 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5121 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5122 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5123 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5124 | } |
| 5125 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5126 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5127 | // Try to add a buffer memory barrier with no buffer. |
| 5128 | m_errorMonitor->SetDesiredFailureMsg( |
| 5129 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5130 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5131 | |
| 5132 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5133 | BeginCommandBuffer(); |
| 5134 | |
| 5135 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5136 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5137 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5138 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5139 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5140 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5141 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5142 | buf_barrier.offset = 0; |
| 5143 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5144 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5145 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5146 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5147 | |
| 5148 | m_errorMonitor->VerifyFound(); |
| 5149 | } |
| 5150 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5151 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5152 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5153 | |
| 5154 | m_errorMonitor->SetDesiredFailureMsg( |
| 5155 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5156 | |
| 5157 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5158 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5159 | |
| 5160 | VkMemoryBarrier mem_barrier = {}; |
| 5161 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5162 | mem_barrier.pNext = NULL; |
| 5163 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5164 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5165 | BeginCommandBuffer(); |
| 5166 | // BeginCommandBuffer() starts a render pass |
| 5167 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5168 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5169 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5170 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5171 | m_errorMonitor->VerifyFound(); |
| 5172 | |
| 5173 | m_errorMonitor->SetDesiredFailureMsg( |
| 5174 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5175 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5176 | VkImageObj image(m_device); |
| 5177 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5178 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5179 | ASSERT_TRUE(image.initialized()); |
| 5180 | VkImageMemoryBarrier img_barrier = {}; |
| 5181 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5182 | img_barrier.pNext = NULL; |
| 5183 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5184 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5185 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5186 | // New layout can't be UNDEFINED |
| 5187 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5188 | img_barrier.image = image.handle(); |
| 5189 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5190 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5191 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5192 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5193 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5194 | img_barrier.subresourceRange.layerCount = 1; |
| 5195 | img_barrier.subresourceRange.levelCount = 1; |
| 5196 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5197 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5198 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5199 | nullptr, 1, &img_barrier); |
| 5200 | m_errorMonitor->VerifyFound(); |
| 5201 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5202 | |
| 5203 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5204 | "Subresource must have the sum of the " |
| 5205 | "baseArrayLayer"); |
| 5206 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5207 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5208 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5209 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5210 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5211 | nullptr, 1, &img_barrier); |
| 5212 | m_errorMonitor->VerifyFound(); |
| 5213 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5214 | |
| 5215 | m_errorMonitor->SetDesiredFailureMsg( |
| 5216 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5217 | "Subresource must have the sum of the baseMipLevel"); |
| 5218 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5219 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5220 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5221 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5222 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5223 | nullptr, 1, &img_barrier); |
| 5224 | m_errorMonitor->VerifyFound(); |
| 5225 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5226 | |
| 5227 | m_errorMonitor->SetDesiredFailureMsg( |
| 5228 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5229 | "Buffer Barriers cannot be used during a render pass"); |
| 5230 | vk_testing::Buffer buffer; |
| 5231 | buffer.init(*m_device, 256); |
| 5232 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5233 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5234 | buf_barrier.pNext = NULL; |
| 5235 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5236 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5237 | buf_barrier.buffer = buffer.handle(); |
| 5238 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5239 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5240 | buf_barrier.offset = 0; |
| 5241 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5242 | // Can't send buffer barrier during a render pass |
| 5243 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5244 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5245 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5246 | &buf_barrier, 0, nullptr); |
| 5247 | m_errorMonitor->VerifyFound(); |
| 5248 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5249 | |
| 5250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5251 | "which is not less than total size"); |
| 5252 | buf_barrier.offset = 257; |
| 5253 | // Offset greater than total size |
| 5254 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5255 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5256 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5257 | &buf_barrier, 0, nullptr); |
| 5258 | m_errorMonitor->VerifyFound(); |
| 5259 | buf_barrier.offset = 0; |
| 5260 | |
| 5261 | m_errorMonitor->SetDesiredFailureMsg( |
| 5262 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5263 | buf_barrier.size = 257; |
| 5264 | // Size greater than total size |
| 5265 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5266 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5267 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5268 | &buf_barrier, 0, nullptr); |
| 5269 | m_errorMonitor->VerifyFound(); |
| 5270 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5271 | |
| 5272 | m_errorMonitor->SetDesiredFailureMsg( |
| 5273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5274 | "Image is a depth and stencil format and thus must " |
| 5275 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5276 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5277 | VkDepthStencilObj ds_image(m_device); |
| 5278 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5279 | ASSERT_TRUE(ds_image.initialized()); |
| 5280 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5281 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5282 | img_barrier.image = ds_image.handle(); |
| 5283 | // Leave aspectMask at COLOR on purpose |
| 5284 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5285 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5286 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5287 | nullptr, 1, &img_barrier); |
| 5288 | m_errorMonitor->VerifyFound(); |
| 5289 | } |
| 5290 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5291 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5292 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5294 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5295 | m_errorMonitor->SetDesiredFailureMsg( |
| 5296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5297 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5298 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5300 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5301 | uint32_t qfi = 0; |
| 5302 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5303 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5304 | buffCI.size = 1024; |
| 5305 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5306 | buffCI.queueFamilyIndexCount = 1; |
| 5307 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5308 | |
| 5309 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5310 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5311 | ASSERT_VK_SUCCESS(err); |
| 5312 | |
| 5313 | BeginCommandBuffer(); |
| 5314 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5315 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5316 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5317 | // 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] | 5318 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5319 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5320 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5321 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5322 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5323 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5324 | } |
| 5325 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5326 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5327 | // Create an out-of-range queueFamilyIndex |
| 5328 | m_errorMonitor->SetDesiredFailureMsg( |
| 5329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5330 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5331 | |
| 5332 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5333 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5334 | VkBufferCreateInfo buffCI = {}; |
| 5335 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5336 | buffCI.size = 1024; |
| 5337 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5338 | buffCI.queueFamilyIndexCount = 1; |
| 5339 | // Introduce failure by specifying invalid queue_family_index |
| 5340 | uint32_t qfi = 777; |
| 5341 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5342 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5343 | |
| 5344 | VkBuffer ib; |
| 5345 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5346 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5347 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5348 | } |
| 5349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5351 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5352 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5353 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5354 | m_errorMonitor->SetDesiredFailureMsg( |
| 5355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5356 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5357 | |
| 5358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5360 | |
| 5361 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5362 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5363 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5364 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5365 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5366 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5367 | } |
| 5368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5369 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5370 | // 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] | 5371 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5372 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5373 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5374 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5375 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5376 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5377 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5378 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5379 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5380 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5382 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5383 | |
| 5384 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5385 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5386 | ds_pool_ci.pNext = NULL; |
| 5387 | ds_pool_ci.maxSets = 1; |
| 5388 | ds_pool_ci.poolSizeCount = 1; |
| 5389 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5390 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5391 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5392 | err = |
| 5393 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5394 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5395 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5396 | dsl_binding.binding = 0; |
| 5397 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5398 | dsl_binding.descriptorCount = 1; |
| 5399 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5400 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5401 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5402 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5403 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5404 | ds_layout_ci.pNext = NULL; |
| 5405 | ds_layout_ci.bindingCount = 1; |
| 5406 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5407 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5408 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5409 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5410 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5411 | ASSERT_VK_SUCCESS(err); |
| 5412 | |
| 5413 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5414 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5415 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5416 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5417 | alloc_info.descriptorPool = ds_pool; |
| 5418 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5419 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5420 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5421 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5422 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5423 | VkSamplerCreateInfo sampler_ci = {}; |
| 5424 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5425 | sampler_ci.pNext = NULL; |
| 5426 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5427 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5428 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5429 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5430 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5431 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5432 | sampler_ci.mipLodBias = 1.0; |
| 5433 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5434 | sampler_ci.maxAnisotropy = 1; |
| 5435 | sampler_ci.compareEnable = VK_FALSE; |
| 5436 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5437 | sampler_ci.minLod = 1.0; |
| 5438 | sampler_ci.maxLod = 1.0; |
| 5439 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5440 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5441 | VkSampler sampler; |
| 5442 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5443 | ASSERT_VK_SUCCESS(err); |
| 5444 | |
| 5445 | VkDescriptorImageInfo info = {}; |
| 5446 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5447 | |
| 5448 | VkWriteDescriptorSet descriptor_write; |
| 5449 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5450 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5451 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5452 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5453 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5454 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5455 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5456 | |
| 5457 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5458 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5459 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5460 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5461 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5462 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5463 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5464 | } |
| 5465 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5466 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5467 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5468 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5471 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5472 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5473 | "starting at binding offset of 0 combined with update array element " |
| 5474 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5475 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5477 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5478 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5479 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5480 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5481 | |
| 5482 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5483 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5484 | ds_pool_ci.pNext = NULL; |
| 5485 | ds_pool_ci.maxSets = 1; |
| 5486 | ds_pool_ci.poolSizeCount = 1; |
| 5487 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5488 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5489 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5490 | err = |
| 5491 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5492 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5493 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5494 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5495 | dsl_binding.binding = 0; |
| 5496 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5497 | dsl_binding.descriptorCount = 1; |
| 5498 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5499 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5500 | |
| 5501 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5502 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5503 | ds_layout_ci.pNext = NULL; |
| 5504 | ds_layout_ci.bindingCount = 1; |
| 5505 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5506 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5507 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5508 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5509 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5510 | ASSERT_VK_SUCCESS(err); |
| 5511 | |
| 5512 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5513 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5514 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5515 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5516 | alloc_info.descriptorPool = ds_pool; |
| 5517 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5518 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5519 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5520 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5521 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5522 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5523 | VkDescriptorBufferInfo buff_info = {}; |
| 5524 | buff_info.buffer = |
| 5525 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5526 | buff_info.offset = 0; |
| 5527 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5528 | |
| 5529 | VkWriteDescriptorSet descriptor_write; |
| 5530 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5531 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5532 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5533 | descriptor_write.dstArrayElement = |
| 5534 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5535 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5536 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5537 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5538 | |
| 5539 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5540 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5541 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5542 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5543 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5544 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5545 | } |
| 5546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5547 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5548 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5549 | // index 2 |
| 5550 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5551 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5552 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5553 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5554 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5556 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5557 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5558 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5559 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5560 | |
| 5561 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5562 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5563 | ds_pool_ci.pNext = NULL; |
| 5564 | ds_pool_ci.maxSets = 1; |
| 5565 | ds_pool_ci.poolSizeCount = 1; |
| 5566 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5567 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5568 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5569 | err = |
| 5570 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5571 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5572 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5573 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | dsl_binding.binding = 0; |
| 5575 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5576 | dsl_binding.descriptorCount = 1; |
| 5577 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5578 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5579 | |
| 5580 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5581 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5582 | ds_layout_ci.pNext = NULL; |
| 5583 | ds_layout_ci.bindingCount = 1; |
| 5584 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5585 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5586 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5587 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5588 | ASSERT_VK_SUCCESS(err); |
| 5589 | |
| 5590 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5591 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5592 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5593 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5594 | alloc_info.descriptorPool = ds_pool; |
| 5595 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5597 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5598 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5599 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5600 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5601 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5602 | sampler_ci.pNext = NULL; |
| 5603 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5604 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5605 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5606 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5607 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5608 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5609 | sampler_ci.mipLodBias = 1.0; |
| 5610 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5611 | sampler_ci.maxAnisotropy = 1; |
| 5612 | sampler_ci.compareEnable = VK_FALSE; |
| 5613 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5614 | sampler_ci.minLod = 1.0; |
| 5615 | sampler_ci.maxLod = 1.0; |
| 5616 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5617 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5618 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5619 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5620 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5621 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5622 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5623 | VkDescriptorImageInfo info = {}; |
| 5624 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5625 | |
| 5626 | VkWriteDescriptorSet descriptor_write; |
| 5627 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5628 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5629 | descriptor_write.dstSet = descriptorSet; |
| 5630 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5631 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5632 | // 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] | 5633 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5634 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5635 | |
| 5636 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5637 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5638 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5639 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5640 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5641 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5642 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5643 | } |
| 5644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5645 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5646 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5647 | // types |
| 5648 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5649 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5651 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5652 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5654 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5655 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5656 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5657 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5658 | |
| 5659 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5660 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5661 | ds_pool_ci.pNext = NULL; |
| 5662 | ds_pool_ci.maxSets = 1; |
| 5663 | ds_pool_ci.poolSizeCount = 1; |
| 5664 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5665 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5666 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5667 | err = |
| 5668 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5669 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5670 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5671 | dsl_binding.binding = 0; |
| 5672 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5673 | dsl_binding.descriptorCount = 1; |
| 5674 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5675 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5676 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5677 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5678 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5679 | ds_layout_ci.pNext = NULL; |
| 5680 | ds_layout_ci.bindingCount = 1; |
| 5681 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5682 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5683 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5684 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5685 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5686 | ASSERT_VK_SUCCESS(err); |
| 5687 | |
| 5688 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5689 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5690 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5691 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5692 | alloc_info.descriptorPool = ds_pool; |
| 5693 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5694 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5695 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5696 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5697 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5698 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5699 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5700 | sampler_ci.pNext = NULL; |
| 5701 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5702 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5703 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5704 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5705 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5706 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5707 | sampler_ci.mipLodBias = 1.0; |
| 5708 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5709 | sampler_ci.maxAnisotropy = 1; |
| 5710 | sampler_ci.compareEnable = VK_FALSE; |
| 5711 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5712 | sampler_ci.minLod = 1.0; |
| 5713 | sampler_ci.maxLod = 1.0; |
| 5714 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5715 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5716 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5717 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5718 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5719 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5720 | VkDescriptorImageInfo info = {}; |
| 5721 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5722 | |
| 5723 | VkWriteDescriptorSet descriptor_write; |
| 5724 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5725 | descriptor_write.sType = |
| 5726 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5727 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5728 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5729 | // 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] | 5730 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5731 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5732 | |
| 5733 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5734 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5735 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5736 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5737 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5738 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5739 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5740 | } |
| 5741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5742 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5743 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5744 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5746 | m_errorMonitor->SetDesiredFailureMsg( |
| 5747 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5748 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5749 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5751 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5752 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5753 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5754 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5755 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5756 | |
| 5757 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5758 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5759 | ds_pool_ci.pNext = NULL; |
| 5760 | ds_pool_ci.maxSets = 1; |
| 5761 | ds_pool_ci.poolSizeCount = 1; |
| 5762 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5763 | |
| 5764 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5765 | err = |
| 5766 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5767 | ASSERT_VK_SUCCESS(err); |
| 5768 | |
| 5769 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5770 | dsl_binding.binding = 0; |
| 5771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5772 | dsl_binding.descriptorCount = 1; |
| 5773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5774 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5775 | |
| 5776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5778 | ds_layout_ci.pNext = NULL; |
| 5779 | ds_layout_ci.bindingCount = 1; |
| 5780 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5781 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5782 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5783 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5784 | ASSERT_VK_SUCCESS(err); |
| 5785 | |
| 5786 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5787 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5788 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5789 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5790 | alloc_info.descriptorPool = ds_pool; |
| 5791 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5793 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5794 | ASSERT_VK_SUCCESS(err); |
| 5795 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5796 | VkSampler sampler = |
| 5797 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5798 | |
| 5799 | VkDescriptorImageInfo descriptor_info; |
| 5800 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5801 | descriptor_info.sampler = sampler; |
| 5802 | |
| 5803 | VkWriteDescriptorSet descriptor_write; |
| 5804 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5805 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5806 | descriptor_write.dstSet = descriptorSet; |
| 5807 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5808 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5809 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5810 | descriptor_write.pImageInfo = &descriptor_info; |
| 5811 | |
| 5812 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5813 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5814 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5815 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5816 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5817 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5818 | } |
| 5819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5821 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5822 | // imageView |
| 5823 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5824 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5825 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5826 | "Attempted write update to combined " |
| 5827 | "image sampler descriptor failed due " |
| 5828 | "to: Invalid VkImageView: 0xbaadbeef"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5829 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5830 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5831 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5832 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5833 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5834 | |
| 5835 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5836 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5837 | ds_pool_ci.pNext = NULL; |
| 5838 | ds_pool_ci.maxSets = 1; |
| 5839 | ds_pool_ci.poolSizeCount = 1; |
| 5840 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5841 | |
| 5842 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5843 | err = |
| 5844 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5845 | ASSERT_VK_SUCCESS(err); |
| 5846 | |
| 5847 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5848 | dsl_binding.binding = 0; |
| 5849 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5850 | dsl_binding.descriptorCount = 1; |
| 5851 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5852 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5853 | |
| 5854 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5855 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5856 | ds_layout_ci.pNext = NULL; |
| 5857 | ds_layout_ci.bindingCount = 1; |
| 5858 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5859 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5860 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5861 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5862 | ASSERT_VK_SUCCESS(err); |
| 5863 | |
| 5864 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5865 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5866 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5867 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5868 | alloc_info.descriptorPool = ds_pool; |
| 5869 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5870 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5871 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5872 | ASSERT_VK_SUCCESS(err); |
| 5873 | |
| 5874 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5875 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5876 | sampler_ci.pNext = NULL; |
| 5877 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5878 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5879 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5880 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5881 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5882 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5883 | sampler_ci.mipLodBias = 1.0; |
| 5884 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5885 | sampler_ci.maxAnisotropy = 1; |
| 5886 | sampler_ci.compareEnable = VK_FALSE; |
| 5887 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5888 | sampler_ci.minLod = 1.0; |
| 5889 | sampler_ci.maxLod = 1.0; |
| 5890 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5891 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5892 | |
| 5893 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5894 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5895 | ASSERT_VK_SUCCESS(err); |
| 5896 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5897 | VkImageView view = |
| 5898 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5899 | |
| 5900 | VkDescriptorImageInfo descriptor_info; |
| 5901 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5902 | descriptor_info.sampler = sampler; |
| 5903 | descriptor_info.imageView = view; |
| 5904 | |
| 5905 | VkWriteDescriptorSet descriptor_write; |
| 5906 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5907 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5908 | descriptor_write.dstSet = descriptorSet; |
| 5909 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5910 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5911 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5912 | descriptor_write.pImageInfo = &descriptor_info; |
| 5913 | |
| 5914 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5916 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5917 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5918 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5919 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5920 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5921 | } |
| 5922 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5923 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 5924 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 5925 | // into the other |
| 5926 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5927 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5928 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5929 | " binding #1 with type " |
| 5930 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 5931 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5932 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5933 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5934 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5935 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5936 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5937 | ds_type_count[0].descriptorCount = 1; |
| 5938 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5939 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5940 | |
| 5941 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5942 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5943 | ds_pool_ci.pNext = NULL; |
| 5944 | ds_pool_ci.maxSets = 1; |
| 5945 | ds_pool_ci.poolSizeCount = 2; |
| 5946 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5947 | |
| 5948 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | err = |
| 5950 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5951 | ASSERT_VK_SUCCESS(err); |
| 5952 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | dsl_binding[0].binding = 0; |
| 5954 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5955 | dsl_binding[0].descriptorCount = 1; |
| 5956 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5957 | dsl_binding[0].pImmutableSamplers = NULL; |
| 5958 | dsl_binding[1].binding = 1; |
| 5959 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5960 | dsl_binding[1].descriptorCount = 1; |
| 5961 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5962 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5963 | |
| 5964 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5965 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5966 | ds_layout_ci.pNext = NULL; |
| 5967 | ds_layout_ci.bindingCount = 2; |
| 5968 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5969 | |
| 5970 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5972 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5973 | ASSERT_VK_SUCCESS(err); |
| 5974 | |
| 5975 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5976 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5977 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5978 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5979 | alloc_info.descriptorPool = ds_pool; |
| 5980 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5981 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5982 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5983 | ASSERT_VK_SUCCESS(err); |
| 5984 | |
| 5985 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5986 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5987 | sampler_ci.pNext = NULL; |
| 5988 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5989 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5990 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5991 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5992 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5993 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5994 | sampler_ci.mipLodBias = 1.0; |
| 5995 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5996 | sampler_ci.maxAnisotropy = 1; |
| 5997 | sampler_ci.compareEnable = VK_FALSE; |
| 5998 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5999 | sampler_ci.minLod = 1.0; |
| 6000 | sampler_ci.maxLod = 1.0; |
| 6001 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6002 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6003 | |
| 6004 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6005 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6006 | ASSERT_VK_SUCCESS(err); |
| 6007 | |
| 6008 | VkDescriptorImageInfo info = {}; |
| 6009 | info.sampler = sampler; |
| 6010 | |
| 6011 | VkWriteDescriptorSet descriptor_write; |
| 6012 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6013 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6014 | descriptor_write.dstSet = descriptorSet; |
| 6015 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6016 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6017 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6018 | descriptor_write.pImageInfo = &info; |
| 6019 | // This write update should succeed |
| 6020 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6021 | // Now perform a copy update that fails due to type mismatch |
| 6022 | VkCopyDescriptorSet copy_ds_update; |
| 6023 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6024 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6025 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6026 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6027 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6028 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6029 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6030 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6031 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6032 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6033 | // 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] | 6034 | m_errorMonitor->SetDesiredFailureMsg( |
| 6035 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6036 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6037 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6038 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6039 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6040 | copy_ds_update.srcBinding = |
| 6041 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6042 | copy_ds_update.dstSet = descriptorSet; |
| 6043 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6044 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6045 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6046 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6047 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6048 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6049 | // 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] | 6050 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6051 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6052 | "update array offset of 0 and update of " |
| 6053 | "5 descriptors oversteps total number " |
| 6054 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6055 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6056 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6057 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6058 | copy_ds_update.srcSet = descriptorSet; |
| 6059 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6060 | copy_ds_update.dstSet = descriptorSet; |
| 6061 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6062 | copy_ds_update.descriptorCount = |
| 6063 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6064 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6066 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6067 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6068 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6069 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6070 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6071 | } |
| 6072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6073 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6074 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6075 | // sampleCount |
| 6076 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6077 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6078 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6080 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6083 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6084 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6085 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6086 | |
| 6087 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6088 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6089 | ds_pool_ci.pNext = NULL; |
| 6090 | ds_pool_ci.maxSets = 1; |
| 6091 | ds_pool_ci.poolSizeCount = 1; |
| 6092 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6093 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6094 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6095 | err = |
| 6096 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6097 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6098 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6099 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6100 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6101 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6102 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6103 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6104 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6105 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6106 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6107 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6108 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6109 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6110 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6111 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6112 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6113 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6114 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6115 | ASSERT_VK_SUCCESS(err); |
| 6116 | |
| 6117 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6118 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6119 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6120 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6121 | alloc_info.descriptorPool = ds_pool; |
| 6122 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6123 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6124 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6125 | ASSERT_VK_SUCCESS(err); |
| 6126 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6127 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6128 | pipe_ms_state_ci.sType = |
| 6129 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6130 | pipe_ms_state_ci.pNext = NULL; |
| 6131 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6132 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6133 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6134 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6135 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6136 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6137 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6138 | pipeline_layout_ci.pNext = NULL; |
| 6139 | pipeline_layout_ci.setLayoutCount = 1; |
| 6140 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6141 | |
| 6142 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6143 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6144 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6145 | ASSERT_VK_SUCCESS(err); |
| 6146 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6147 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6148 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6149 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6150 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6151 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6152 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6153 | VkPipelineObj pipe(m_device); |
| 6154 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6155 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6156 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6157 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6158 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6159 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6160 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6161 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6162 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6163 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6164 | // Render triangle (the error should trigger on the attempt to draw). |
| 6165 | Draw(3, 1, 0, 0); |
| 6166 | |
| 6167 | // Finalize recording of the command buffer |
| 6168 | EndCommandBuffer(); |
| 6169 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6170 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6171 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6172 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6173 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6174 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6175 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6176 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6177 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6178 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6179 | // number of color attachments. In this case, we don't add any color |
| 6180 | // blend attachments even though we have a color attachment. |
| 6181 | VkResult err; |
| 6182 | |
| 6183 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6184 | "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] | 6185 | |
| 6186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6187 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6188 | VkDescriptorPoolSize ds_type_count = {}; |
| 6189 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6190 | ds_type_count.descriptorCount = 1; |
| 6191 | |
| 6192 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6193 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6194 | ds_pool_ci.pNext = NULL; |
| 6195 | ds_pool_ci.maxSets = 1; |
| 6196 | ds_pool_ci.poolSizeCount = 1; |
| 6197 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6198 | |
| 6199 | VkDescriptorPool ds_pool; |
| 6200 | err = |
| 6201 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6202 | ASSERT_VK_SUCCESS(err); |
| 6203 | |
| 6204 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6205 | dsl_binding.binding = 0; |
| 6206 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6207 | dsl_binding.descriptorCount = 1; |
| 6208 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6209 | dsl_binding.pImmutableSamplers = NULL; |
| 6210 | |
| 6211 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6212 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6213 | ds_layout_ci.pNext = NULL; |
| 6214 | ds_layout_ci.bindingCount = 1; |
| 6215 | ds_layout_ci.pBindings = &dsl_binding; |
| 6216 | |
| 6217 | VkDescriptorSetLayout ds_layout; |
| 6218 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6219 | &ds_layout); |
| 6220 | ASSERT_VK_SUCCESS(err); |
| 6221 | |
| 6222 | VkDescriptorSet descriptorSet; |
| 6223 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6224 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6225 | alloc_info.descriptorSetCount = 1; |
| 6226 | alloc_info.descriptorPool = ds_pool; |
| 6227 | alloc_info.pSetLayouts = &ds_layout; |
| 6228 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6229 | &descriptorSet); |
| 6230 | ASSERT_VK_SUCCESS(err); |
| 6231 | |
| 6232 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6233 | pipe_ms_state_ci.sType = |
| 6234 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6235 | pipe_ms_state_ci.pNext = NULL; |
| 6236 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6237 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6238 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6239 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6240 | |
| 6241 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6242 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6243 | pipeline_layout_ci.pNext = NULL; |
| 6244 | pipeline_layout_ci.setLayoutCount = 1; |
| 6245 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6246 | |
| 6247 | VkPipelineLayout pipeline_layout; |
| 6248 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6249 | &pipeline_layout); |
| 6250 | ASSERT_VK_SUCCESS(err); |
| 6251 | |
| 6252 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6253 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6254 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6255 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6256 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6257 | // but add it to be able to run on more devices |
| 6258 | VkPipelineObj pipe(m_device); |
| 6259 | pipe.AddShader(&vs); |
| 6260 | pipe.AddShader(&fs); |
| 6261 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6262 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6263 | |
| 6264 | BeginCommandBuffer(); |
| 6265 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6266 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6267 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6268 | // Render triangle (the error should trigger on the attempt to draw). |
| 6269 | Draw(3, 1, 0, 0); |
| 6270 | |
| 6271 | // Finalize recording of the command buffer |
| 6272 | EndCommandBuffer(); |
| 6273 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6274 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6275 | |
| 6276 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6277 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6278 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6279 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6281 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6282 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6283 | // to issuing a Draw |
| 6284 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6285 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6286 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6287 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6288 | "vkCmdClearAttachments() issued on CB object "); |
| 6289 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6291 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6292 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6293 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6294 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6295 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6296 | |
| 6297 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6298 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6299 | ds_pool_ci.pNext = NULL; |
| 6300 | ds_pool_ci.maxSets = 1; |
| 6301 | ds_pool_ci.poolSizeCount = 1; |
| 6302 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6303 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6304 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6305 | err = |
| 6306 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6307 | ASSERT_VK_SUCCESS(err); |
| 6308 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6309 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6310 | dsl_binding.binding = 0; |
| 6311 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6312 | dsl_binding.descriptorCount = 1; |
| 6313 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6314 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6315 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6316 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6317 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6318 | ds_layout_ci.pNext = NULL; |
| 6319 | ds_layout_ci.bindingCount = 1; |
| 6320 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6321 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6322 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6323 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6324 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6325 | ASSERT_VK_SUCCESS(err); |
| 6326 | |
| 6327 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6328 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6329 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6330 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6331 | alloc_info.descriptorPool = ds_pool; |
| 6332 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6333 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6334 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6335 | ASSERT_VK_SUCCESS(err); |
| 6336 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6337 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6338 | pipe_ms_state_ci.sType = |
| 6339 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6340 | pipe_ms_state_ci.pNext = NULL; |
| 6341 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6342 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6343 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6344 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6345 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6346 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6347 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6348 | pipeline_layout_ci.pNext = NULL; |
| 6349 | pipeline_layout_ci.setLayoutCount = 1; |
| 6350 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6351 | |
| 6352 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6353 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6354 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6355 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6357 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6358 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6359 | // 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] | 6360 | // on more devices |
| 6361 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6362 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6363 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6364 | VkPipelineObj pipe(m_device); |
| 6365 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6366 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6367 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6368 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6369 | |
| 6370 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6372 | // Main thing we care about for this test is that the VkImage obj we're |
| 6373 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6374 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6375 | VkClearAttachment color_attachment; |
| 6376 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6377 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6378 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6379 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6380 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6381 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6382 | VkClearRect clear_rect = { |
| 6383 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6385 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6386 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6387 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6388 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6389 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6390 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6391 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6392 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6393 | } |
| 6394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6395 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6396 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6397 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6398 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6399 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6400 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6401 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6402 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6403 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6405 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6406 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6407 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6408 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6409 | |
| 6410 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6412 | ds_pool_ci.pNext = NULL; |
| 6413 | ds_pool_ci.maxSets = 1; |
| 6414 | ds_pool_ci.poolSizeCount = 1; |
| 6415 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6416 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6417 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6418 | err = |
| 6419 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6420 | ASSERT_VK_SUCCESS(err); |
| 6421 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6422 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6423 | dsl_binding.binding = 0; |
| 6424 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6425 | dsl_binding.descriptorCount = 1; |
| 6426 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6427 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6428 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6429 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6431 | ds_layout_ci.pNext = NULL; |
| 6432 | ds_layout_ci.bindingCount = 1; |
| 6433 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6434 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6435 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6436 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6437 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6438 | ASSERT_VK_SUCCESS(err); |
| 6439 | |
| 6440 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6441 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6442 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6443 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6444 | alloc_info.descriptorPool = ds_pool; |
| 6445 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6446 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6447 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6448 | ASSERT_VK_SUCCESS(err); |
| 6449 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6450 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6451 | pipe_ms_state_ci.sType = |
| 6452 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6453 | pipe_ms_state_ci.pNext = NULL; |
| 6454 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6455 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6456 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6457 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6458 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6459 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6460 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6461 | pipeline_layout_ci.pNext = NULL; |
| 6462 | pipeline_layout_ci.setLayoutCount = 1; |
| 6463 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6464 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6465 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6466 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6467 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6468 | ASSERT_VK_SUCCESS(err); |
| 6469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6470 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6471 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6472 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6473 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6474 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6475 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6476 | VkPipelineObj pipe(m_device); |
| 6477 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6478 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6479 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6480 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6481 | pipe.SetViewport(m_viewports); |
| 6482 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6483 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6484 | |
| 6485 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6486 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6487 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6488 | // Don't care about actual data, just need to get to draw to flag error |
| 6489 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6490 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6491 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6492 | 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] | 6493 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6494 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6495 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6496 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6497 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6498 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6499 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6500 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6501 | #endif // DRAW_STATE_TESTS |
| 6502 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6503 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6504 | #if GTEST_IS_THREADSAFE |
| 6505 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6506 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6507 | VkEvent event; |
| 6508 | bool bailout; |
| 6509 | }; |
| 6510 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6511 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6512 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6514 | for (int i = 0; i < 10000; i++) { |
| 6515 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6516 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6517 | if (data->bailout) { |
| 6518 | break; |
| 6519 | } |
| 6520 | } |
| 6521 | return NULL; |
| 6522 | } |
| 6523 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6524 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6525 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6527 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6528 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6529 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6531 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6532 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6533 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6534 | // Calls AllocateCommandBuffers |
| 6535 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6536 | |
| 6537 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6538 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6539 | |
| 6540 | VkEventCreateInfo event_info; |
| 6541 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6542 | VkResult err; |
| 6543 | |
| 6544 | memset(&event_info, 0, sizeof(event_info)); |
| 6545 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6546 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6547 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6548 | ASSERT_VK_SUCCESS(err); |
| 6549 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6550 | err = vkResetEvent(device(), event); |
| 6551 | ASSERT_VK_SUCCESS(err); |
| 6552 | |
| 6553 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6554 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6555 | data.event = event; |
| 6556 | data.bailout = false; |
| 6557 | m_errorMonitor->SetBailout(&data.bailout); |
| 6558 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6559 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6560 | // Add many entries to command buffer from this thread at the same time. |
| 6561 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6562 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6563 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6564 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6565 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6566 | m_errorMonitor->SetBailout(NULL); |
| 6567 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6568 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6569 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6570 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6571 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6572 | #endif // GTEST_IS_THREADSAFE |
| 6573 | #endif // THREADING_TESTS |
| 6574 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6575 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6576 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6577 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6578 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6579 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6580 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6581 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6582 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6583 | VkShaderModule module; |
| 6584 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6585 | struct icd_spv_header spv; |
| 6586 | |
| 6587 | spv.magic = ICD_SPV_MAGIC; |
| 6588 | spv.version = ICD_SPV_VERSION; |
| 6589 | spv.gen_magic = 0; |
| 6590 | |
| 6591 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6592 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6594 | moduleCreateInfo.codeSize = 4; |
| 6595 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6596 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6597 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6598 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6599 | } |
| 6600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6602 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6603 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6604 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6606 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6607 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6608 | VkShaderModule module; |
| 6609 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6610 | struct icd_spv_header spv; |
| 6611 | |
| 6612 | spv.magic = ~ICD_SPV_MAGIC; |
| 6613 | spv.version = ICD_SPV_VERSION; |
| 6614 | spv.gen_magic = 0; |
| 6615 | |
| 6616 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6617 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6618 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6619 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6620 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6621 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6623 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6624 | } |
| 6625 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6626 | #if 0 |
| 6627 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6628 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6629 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6630 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6631 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6632 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6633 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6634 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6635 | VkShaderModule module; |
| 6636 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6637 | struct icd_spv_header spv; |
| 6638 | |
| 6639 | spv.magic = ICD_SPV_MAGIC; |
| 6640 | spv.version = ~ICD_SPV_VERSION; |
| 6641 | spv.gen_magic = 0; |
| 6642 | |
| 6643 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6644 | moduleCreateInfo.pNext = NULL; |
| 6645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6647 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6648 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6649 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6650 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6651 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6652 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6653 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6655 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6656 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6657 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6658 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6659 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6660 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6661 | |
| 6662 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6663 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6664 | "\n" |
| 6665 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6666 | "out gl_PerVertex {\n" |
| 6667 | " vec4 gl_Position;\n" |
| 6668 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6669 | "void main(){\n" |
| 6670 | " gl_Position = vec4(1);\n" |
| 6671 | " x = 0;\n" |
| 6672 | "}\n"; |
| 6673 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6674 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6675 | "\n" |
| 6676 | "layout(location=0) out vec4 color;\n" |
| 6677 | "void main(){\n" |
| 6678 | " color = vec4(1);\n" |
| 6679 | "}\n"; |
| 6680 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6681 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6682 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6683 | |
| 6684 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6685 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6686 | pipe.AddShader(&vs); |
| 6687 | pipe.AddShader(&fs); |
| 6688 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6689 | VkDescriptorSetObj descriptorSet(m_device); |
| 6690 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6691 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6692 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6693 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6694 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6695 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6696 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6697 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6698 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6699 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6700 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6701 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6702 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6703 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6704 | |
| 6705 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6706 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6707 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6708 | "out gl_PerVertex {\n" |
| 6709 | " vec4 gl_Position;\n" |
| 6710 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6711 | "void main(){\n" |
| 6712 | " gl_Position = vec4(1);\n" |
| 6713 | "}\n"; |
| 6714 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6715 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6716 | "\n" |
| 6717 | "layout(location=0) in float x;\n" |
| 6718 | "layout(location=0) out vec4 color;\n" |
| 6719 | "void main(){\n" |
| 6720 | " color = vec4(x);\n" |
| 6721 | "}\n"; |
| 6722 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6723 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6724 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6725 | |
| 6726 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6727 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6728 | pipe.AddShader(&vs); |
| 6729 | pipe.AddShader(&fs); |
| 6730 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6731 | VkDescriptorSetObj descriptorSet(m_device); |
| 6732 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6733 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6734 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6735 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6736 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6737 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6738 | } |
| 6739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6740 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6741 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6742 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6743 | |
| 6744 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6745 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6746 | |
| 6747 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6748 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6749 | "\n" |
| 6750 | "out gl_PerVertex {\n" |
| 6751 | " vec4 gl_Position;\n" |
| 6752 | "};\n" |
| 6753 | "void main(){\n" |
| 6754 | " gl_Position = vec4(1);\n" |
| 6755 | "}\n"; |
| 6756 | char const *fsSource = |
| 6757 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6758 | "\n" |
| 6759 | "in block { layout(location=0) float x; } ins;\n" |
| 6760 | "layout(location=0) out vec4 color;\n" |
| 6761 | "void main(){\n" |
| 6762 | " color = vec4(ins.x);\n" |
| 6763 | "}\n"; |
| 6764 | |
| 6765 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6766 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6767 | |
| 6768 | VkPipelineObj pipe(m_device); |
| 6769 | pipe.AddColorAttachment(); |
| 6770 | pipe.AddShader(&vs); |
| 6771 | pipe.AddShader(&fs); |
| 6772 | |
| 6773 | VkDescriptorSetObj descriptorSet(m_device); |
| 6774 | descriptorSet.AppendDummy(); |
| 6775 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6776 | |
| 6777 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6778 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6779 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6780 | } |
| 6781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6782 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6783 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6784 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6785 | "output arr[2] of float32' vs 'ptr to " |
| 6786 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6787 | |
| 6788 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6789 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6790 | |
| 6791 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6792 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6793 | "\n" |
| 6794 | "layout(location=0) out float x[2];\n" |
| 6795 | "out gl_PerVertex {\n" |
| 6796 | " vec4 gl_Position;\n" |
| 6797 | "};\n" |
| 6798 | "void main(){\n" |
| 6799 | " x[0] = 0; x[1] = 0;\n" |
| 6800 | " gl_Position = vec4(1);\n" |
| 6801 | "}\n"; |
| 6802 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6803 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6804 | "\n" |
| 6805 | "layout(location=0) in float x[3];\n" |
| 6806 | "layout(location=0) out vec4 color;\n" |
| 6807 | "void main(){\n" |
| 6808 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 6809 | "}\n"; |
| 6810 | |
| 6811 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6812 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6813 | |
| 6814 | VkPipelineObj pipe(m_device); |
| 6815 | pipe.AddColorAttachment(); |
| 6816 | pipe.AddShader(&vs); |
| 6817 | pipe.AddShader(&fs); |
| 6818 | |
| 6819 | VkDescriptorSetObj descriptorSet(m_device); |
| 6820 | descriptorSet.AppendDummy(); |
| 6821 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6822 | |
| 6823 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6824 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6825 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6826 | } |
| 6827 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6828 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6829 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6831 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6832 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6833 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6834 | |
| 6835 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6836 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6837 | "\n" |
| 6838 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6839 | "out gl_PerVertex {\n" |
| 6840 | " vec4 gl_Position;\n" |
| 6841 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6842 | "void main(){\n" |
| 6843 | " x = 0;\n" |
| 6844 | " gl_Position = vec4(1);\n" |
| 6845 | "}\n"; |
| 6846 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6847 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6848 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6849 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6850 | "layout(location=0) out vec4 color;\n" |
| 6851 | "void main(){\n" |
| 6852 | " color = vec4(x);\n" |
| 6853 | "}\n"; |
| 6854 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6855 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6856 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6857 | |
| 6858 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6859 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6860 | pipe.AddShader(&vs); |
| 6861 | pipe.AddShader(&fs); |
| 6862 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6863 | VkDescriptorSetObj descriptorSet(m_device); |
| 6864 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6865 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6866 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6867 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6868 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6869 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6870 | } |
| 6871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6872 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6874 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6875 | |
| 6876 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6877 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6878 | |
| 6879 | char const *vsSource = |
| 6880 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6881 | "\n" |
| 6882 | "out block { layout(location=0) int x; } outs;\n" |
| 6883 | "out gl_PerVertex {\n" |
| 6884 | " vec4 gl_Position;\n" |
| 6885 | "};\n" |
| 6886 | "void main(){\n" |
| 6887 | " outs.x = 0;\n" |
| 6888 | " gl_Position = vec4(1);\n" |
| 6889 | "}\n"; |
| 6890 | char const *fsSource = |
| 6891 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6892 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6893 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6894 | "layout(location=0) out vec4 color;\n" |
| 6895 | "void main(){\n" |
| 6896 | " color = vec4(ins.x);\n" |
| 6897 | "}\n"; |
| 6898 | |
| 6899 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6900 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6901 | |
| 6902 | VkPipelineObj pipe(m_device); |
| 6903 | pipe.AddColorAttachment(); |
| 6904 | pipe.AddShader(&vs); |
| 6905 | pipe.AddShader(&fs); |
| 6906 | |
| 6907 | VkDescriptorSetObj descriptorSet(m_device); |
| 6908 | descriptorSet.AppendDummy(); |
| 6909 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6910 | |
| 6911 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6912 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6913 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6914 | } |
| 6915 | |
| 6916 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 6917 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6918 | "location 0.0 which is not written by vertex shader"); |
| 6919 | |
| 6920 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6921 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6922 | |
| 6923 | char const *vsSource = |
| 6924 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6925 | "\n" |
| 6926 | "out block { layout(location=1) float x; } outs;\n" |
| 6927 | "out gl_PerVertex {\n" |
| 6928 | " vec4 gl_Position;\n" |
| 6929 | "};\n" |
| 6930 | "void main(){\n" |
| 6931 | " outs.x = 0;\n" |
| 6932 | " gl_Position = vec4(1);\n" |
| 6933 | "}\n"; |
| 6934 | char const *fsSource = |
| 6935 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6936 | "\n" |
| 6937 | "in block { layout(location=0) float x; } ins;\n" |
| 6938 | "layout(location=0) out vec4 color;\n" |
| 6939 | "void main(){\n" |
| 6940 | " color = vec4(ins.x);\n" |
| 6941 | "}\n"; |
| 6942 | |
| 6943 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6944 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6945 | |
| 6946 | VkPipelineObj pipe(m_device); |
| 6947 | pipe.AddColorAttachment(); |
| 6948 | pipe.AddShader(&vs); |
| 6949 | pipe.AddShader(&fs); |
| 6950 | |
| 6951 | VkDescriptorSetObj descriptorSet(m_device); |
| 6952 | descriptorSet.AppendDummy(); |
| 6953 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6954 | |
| 6955 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6956 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6957 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6958 | } |
| 6959 | |
| 6960 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 6961 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6962 | "location 0.1 which is not written by vertex shader"); |
| 6963 | |
| 6964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6965 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6966 | |
| 6967 | char const *vsSource = |
| 6968 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6969 | "\n" |
| 6970 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 6971 | "out gl_PerVertex {\n" |
| 6972 | " vec4 gl_Position;\n" |
| 6973 | "};\n" |
| 6974 | "void main(){\n" |
| 6975 | " outs.x = 0;\n" |
| 6976 | " gl_Position = vec4(1);\n" |
| 6977 | "}\n"; |
| 6978 | char const *fsSource = |
| 6979 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6980 | "\n" |
| 6981 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 6982 | "layout(location=0) out vec4 color;\n" |
| 6983 | "void main(){\n" |
| 6984 | " color = vec4(ins.x);\n" |
| 6985 | "}\n"; |
| 6986 | |
| 6987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6989 | |
| 6990 | VkPipelineObj pipe(m_device); |
| 6991 | pipe.AddColorAttachment(); |
| 6992 | pipe.AddShader(&vs); |
| 6993 | pipe.AddShader(&fs); |
| 6994 | |
| 6995 | VkDescriptorSetObj descriptorSet(m_device); |
| 6996 | descriptorSet.AppendDummy(); |
| 6997 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6998 | |
| 6999 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7000 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7001 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7002 | } |
| 7003 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7004 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7006 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7007 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7008 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7009 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7010 | |
| 7011 | VkVertexInputBindingDescription input_binding; |
| 7012 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7013 | |
| 7014 | VkVertexInputAttributeDescription input_attrib; |
| 7015 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7016 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7017 | |
| 7018 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7019 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7020 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7021 | "out gl_PerVertex {\n" |
| 7022 | " vec4 gl_Position;\n" |
| 7023 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7024 | "void main(){\n" |
| 7025 | " gl_Position = vec4(1);\n" |
| 7026 | "}\n"; |
| 7027 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7028 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7029 | "\n" |
| 7030 | "layout(location=0) out vec4 color;\n" |
| 7031 | "void main(){\n" |
| 7032 | " color = vec4(1);\n" |
| 7033 | "}\n"; |
| 7034 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7035 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7036 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7037 | |
| 7038 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7039 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7040 | pipe.AddShader(&vs); |
| 7041 | pipe.AddShader(&fs); |
| 7042 | |
| 7043 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7044 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7045 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7046 | VkDescriptorSetObj descriptorSet(m_device); |
| 7047 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7048 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7049 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7050 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7051 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7052 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7053 | } |
| 7054 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7055 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7056 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7058 | |
| 7059 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7060 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7061 | |
| 7062 | VkVertexInputBindingDescription input_binding; |
| 7063 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7064 | |
| 7065 | VkVertexInputAttributeDescription input_attrib; |
| 7066 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7067 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7068 | |
| 7069 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7070 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7071 | "\n" |
| 7072 | "layout(location=1) in float x;\n" |
| 7073 | "out gl_PerVertex {\n" |
| 7074 | " vec4 gl_Position;\n" |
| 7075 | "};\n" |
| 7076 | "void main(){\n" |
| 7077 | " gl_Position = vec4(x);\n" |
| 7078 | "}\n"; |
| 7079 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7080 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7081 | "\n" |
| 7082 | "layout(location=0) out vec4 color;\n" |
| 7083 | "void main(){\n" |
| 7084 | " color = vec4(1);\n" |
| 7085 | "}\n"; |
| 7086 | |
| 7087 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7088 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7089 | |
| 7090 | VkPipelineObj pipe(m_device); |
| 7091 | pipe.AddColorAttachment(); |
| 7092 | pipe.AddShader(&vs); |
| 7093 | pipe.AddShader(&fs); |
| 7094 | |
| 7095 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7096 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7097 | |
| 7098 | VkDescriptorSetObj descriptorSet(m_device); |
| 7099 | descriptorSet.AppendDummy(); |
| 7100 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7101 | |
| 7102 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7103 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7104 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7105 | } |
| 7106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7107 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7108 | m_errorMonitor->SetDesiredFailureMsg( |
| 7109 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7110 | "VS consumes input at location 0 but not provided"); |
| 7111 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7112 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7113 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7114 | |
| 7115 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7116 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7117 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7118 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7119 | "out gl_PerVertex {\n" |
| 7120 | " vec4 gl_Position;\n" |
| 7121 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7122 | "void main(){\n" |
| 7123 | " gl_Position = x;\n" |
| 7124 | "}\n"; |
| 7125 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7126 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7127 | "\n" |
| 7128 | "layout(location=0) out vec4 color;\n" |
| 7129 | "void main(){\n" |
| 7130 | " color = vec4(1);\n" |
| 7131 | "}\n"; |
| 7132 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7133 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7134 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7135 | |
| 7136 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7137 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7138 | pipe.AddShader(&vs); |
| 7139 | pipe.AddShader(&fs); |
| 7140 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7141 | VkDescriptorSetObj descriptorSet(m_device); |
| 7142 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7143 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7144 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7145 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7147 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7148 | } |
| 7149 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7150 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7151 | m_errorMonitor->SetDesiredFailureMsg( |
| 7152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7153 | "location 0 does not match VS input type"); |
| 7154 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7155 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7156 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7157 | |
| 7158 | VkVertexInputBindingDescription input_binding; |
| 7159 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7160 | |
| 7161 | VkVertexInputAttributeDescription input_attrib; |
| 7162 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7163 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7164 | |
| 7165 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7166 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7167 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7168 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7169 | "out gl_PerVertex {\n" |
| 7170 | " vec4 gl_Position;\n" |
| 7171 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7172 | "void main(){\n" |
| 7173 | " gl_Position = vec4(x);\n" |
| 7174 | "}\n"; |
| 7175 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7176 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7177 | "\n" |
| 7178 | "layout(location=0) out vec4 color;\n" |
| 7179 | "void main(){\n" |
| 7180 | " color = vec4(1);\n" |
| 7181 | "}\n"; |
| 7182 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7183 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7184 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7185 | |
| 7186 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7187 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7188 | pipe.AddShader(&vs); |
| 7189 | pipe.AddShader(&fs); |
| 7190 | |
| 7191 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7192 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7193 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7194 | VkDescriptorSetObj descriptorSet(m_device); |
| 7195 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7196 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7197 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7198 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7199 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7200 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7201 | } |
| 7202 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7203 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7204 | m_errorMonitor->SetDesiredFailureMsg( |
| 7205 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7206 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7207 | |
| 7208 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7209 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7210 | |
| 7211 | char const *vsSource = |
| 7212 | "#version 450\n" |
| 7213 | "\n" |
| 7214 | "out gl_PerVertex {\n" |
| 7215 | " vec4 gl_Position;\n" |
| 7216 | "};\n" |
| 7217 | "void main(){\n" |
| 7218 | " gl_Position = vec4(1);\n" |
| 7219 | "}\n"; |
| 7220 | char const *fsSource = |
| 7221 | "#version 450\n" |
| 7222 | "\n" |
| 7223 | "layout(location=0) out vec4 color;\n" |
| 7224 | "void main(){\n" |
| 7225 | " color = vec4(1);\n" |
| 7226 | "}\n"; |
| 7227 | |
| 7228 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7229 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7230 | |
| 7231 | VkPipelineObj pipe(m_device); |
| 7232 | pipe.AddColorAttachment(); |
| 7233 | pipe.AddShader(&vs); |
| 7234 | pipe.AddShader(&vs); |
| 7235 | pipe.AddShader(&fs); |
| 7236 | |
| 7237 | VkDescriptorSetObj descriptorSet(m_device); |
| 7238 | descriptorSet.AppendDummy(); |
| 7239 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7240 | |
| 7241 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7242 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7243 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7244 | } |
| 7245 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7246 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7247 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7248 | |
| 7249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7250 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7251 | |
| 7252 | VkVertexInputBindingDescription input_binding; |
| 7253 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7254 | |
| 7255 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7256 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7257 | |
| 7258 | for (int i = 0; i < 2; i++) { |
| 7259 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7260 | input_attribs[i].location = i; |
| 7261 | } |
| 7262 | |
| 7263 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7264 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7265 | "\n" |
| 7266 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7267 | "out gl_PerVertex {\n" |
| 7268 | " vec4 gl_Position;\n" |
| 7269 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7270 | "void main(){\n" |
| 7271 | " gl_Position = x[0] + x[1];\n" |
| 7272 | "}\n"; |
| 7273 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7274 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7275 | "\n" |
| 7276 | "layout(location=0) out vec4 color;\n" |
| 7277 | "void main(){\n" |
| 7278 | " color = vec4(1);\n" |
| 7279 | "}\n"; |
| 7280 | |
| 7281 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7282 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7283 | |
| 7284 | VkPipelineObj pipe(m_device); |
| 7285 | pipe.AddColorAttachment(); |
| 7286 | pipe.AddShader(&vs); |
| 7287 | pipe.AddShader(&fs); |
| 7288 | |
| 7289 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7290 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7291 | |
| 7292 | VkDescriptorSetObj descriptorSet(m_device); |
| 7293 | descriptorSet.AppendDummy(); |
| 7294 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7295 | |
| 7296 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7297 | |
| 7298 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7299 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7300 | } |
| 7301 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7302 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7303 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7304 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7305 | |
| 7306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7308 | |
| 7309 | VkVertexInputBindingDescription input_binding; |
| 7310 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7311 | |
| 7312 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7313 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7314 | |
| 7315 | for (int i = 0; i < 2; i++) { |
| 7316 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7317 | input_attribs[i].location = i; |
| 7318 | } |
| 7319 | |
| 7320 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7321 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7322 | "\n" |
| 7323 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7324 | "out gl_PerVertex {\n" |
| 7325 | " vec4 gl_Position;\n" |
| 7326 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7327 | "void main(){\n" |
| 7328 | " gl_Position = x[0] + x[1];\n" |
| 7329 | "}\n"; |
| 7330 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7331 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7332 | "\n" |
| 7333 | "layout(location=0) out vec4 color;\n" |
| 7334 | "void main(){\n" |
| 7335 | " color = vec4(1);\n" |
| 7336 | "}\n"; |
| 7337 | |
| 7338 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7339 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7340 | |
| 7341 | VkPipelineObj pipe(m_device); |
| 7342 | pipe.AddColorAttachment(); |
| 7343 | pipe.AddShader(&vs); |
| 7344 | pipe.AddShader(&fs); |
| 7345 | |
| 7346 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7347 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7348 | |
| 7349 | VkDescriptorSetObj descriptorSet(m_device); |
| 7350 | descriptorSet.AppendDummy(); |
| 7351 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7352 | |
| 7353 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7354 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7355 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7356 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7357 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7358 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7359 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7360 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7361 | |
| 7362 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7363 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7364 | |
| 7365 | char const *vsSource = |
| 7366 | "#version 450\n" |
| 7367 | "out gl_PerVertex {\n" |
| 7368 | " vec4 gl_Position;\n" |
| 7369 | "};\n" |
| 7370 | "void main(){\n" |
| 7371 | " gl_Position = vec4(0);\n" |
| 7372 | "}\n"; |
| 7373 | char const *fsSource = |
| 7374 | "#version 450\n" |
| 7375 | "\n" |
| 7376 | "layout(location=0) out vec4 color;\n" |
| 7377 | "void main(){\n" |
| 7378 | " color = vec4(1);\n" |
| 7379 | "}\n"; |
| 7380 | |
| 7381 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7382 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7383 | |
| 7384 | VkPipelineObj pipe(m_device); |
| 7385 | pipe.AddColorAttachment(); |
| 7386 | pipe.AddShader(&vs); |
| 7387 | pipe.AddShader(&fs); |
| 7388 | |
| 7389 | VkDescriptorSetObj descriptorSet(m_device); |
| 7390 | descriptorSet.AppendDummy(); |
| 7391 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7392 | |
| 7393 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7394 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7395 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7396 | } |
| 7397 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7398 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7399 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7400 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7401 | |
| 7402 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7403 | |
| 7404 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7405 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7406 | |
| 7407 | char const *vsSource = |
| 7408 | "#version 450\n" |
| 7409 | "out gl_PerVertex {\n" |
| 7410 | " vec4 gl_Position;\n" |
| 7411 | "};\n" |
| 7412 | "layout(location=0) out vec3 x;\n" |
| 7413 | "layout(location=1) out ivec3 y;\n" |
| 7414 | "layout(location=2) out vec3 z;\n" |
| 7415 | "void main(){\n" |
| 7416 | " gl_Position = vec4(0);\n" |
| 7417 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7418 | "}\n"; |
| 7419 | char const *fsSource = |
| 7420 | "#version 450\n" |
| 7421 | "\n" |
| 7422 | "layout(location=0) out vec4 color;\n" |
| 7423 | "layout(location=0) in float x;\n" |
| 7424 | "layout(location=1) flat in int y;\n" |
| 7425 | "layout(location=2) in vec2 z;\n" |
| 7426 | "void main(){\n" |
| 7427 | " color = vec4(1 + x + y + z.x);\n" |
| 7428 | "}\n"; |
| 7429 | |
| 7430 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7431 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7432 | |
| 7433 | VkPipelineObj pipe(m_device); |
| 7434 | pipe.AddColorAttachment(); |
| 7435 | pipe.AddShader(&vs); |
| 7436 | pipe.AddShader(&fs); |
| 7437 | |
| 7438 | VkDescriptorSetObj descriptorSet(m_device); |
| 7439 | descriptorSet.AppendDummy(); |
| 7440 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7441 | |
| 7442 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7443 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7444 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7445 | } |
| 7446 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7447 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7448 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7449 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7450 | |
| 7451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7453 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7454 | if (!m_device->phy().features().tessellationShader) { |
| 7455 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7456 | return; |
| 7457 | } |
| 7458 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7459 | char const *vsSource = |
| 7460 | "#version 450\n" |
| 7461 | "void main(){}\n"; |
| 7462 | char const *tcsSource = |
| 7463 | "#version 450\n" |
| 7464 | "layout(location=0) out int x[];\n" |
| 7465 | "layout(vertices=3) out;\n" |
| 7466 | "void main(){\n" |
| 7467 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7468 | " gl_TessLevelInner[0] = 1;\n" |
| 7469 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7470 | "}\n"; |
| 7471 | char const *tesSource = |
| 7472 | "#version 450\n" |
| 7473 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7474 | "layout(location=0) in int x[];\n" |
| 7475 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7476 | "void main(){\n" |
| 7477 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7478 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7479 | "}\n"; |
| 7480 | char const *fsSource = |
| 7481 | "#version 450\n" |
| 7482 | "layout(location=0) out vec4 color;\n" |
| 7483 | "void main(){\n" |
| 7484 | " color = vec4(1);\n" |
| 7485 | "}\n"; |
| 7486 | |
| 7487 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7488 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7489 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7490 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7491 | |
| 7492 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7493 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7494 | nullptr, |
| 7495 | 0, |
| 7496 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7497 | VK_FALSE}; |
| 7498 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7499 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7500 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7501 | nullptr, |
| 7502 | 0, |
| 7503 | 3}; |
| 7504 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7505 | VkPipelineObj pipe(m_device); |
| 7506 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7507 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7508 | pipe.AddColorAttachment(); |
| 7509 | pipe.AddShader(&vs); |
| 7510 | pipe.AddShader(&tcs); |
| 7511 | pipe.AddShader(&tes); |
| 7512 | pipe.AddShader(&fs); |
| 7513 | |
| 7514 | VkDescriptorSetObj descriptorSet(m_device); |
| 7515 | descriptorSet.AppendDummy(); |
| 7516 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7517 | |
| 7518 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7519 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7520 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7521 | } |
| 7522 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7523 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7524 | { |
| 7525 | m_errorMonitor->ExpectSuccess(); |
| 7526 | |
| 7527 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7528 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7529 | |
| 7530 | if (!m_device->phy().features().geometryShader) { |
| 7531 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7532 | return; |
| 7533 | } |
| 7534 | |
| 7535 | char const *vsSource = |
| 7536 | "#version 450\n" |
| 7537 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7538 | "void main(){\n" |
| 7539 | " vs_out.x = vec4(1);\n" |
| 7540 | "}\n"; |
| 7541 | char const *gsSource = |
| 7542 | "#version 450\n" |
| 7543 | "layout(triangles) in;\n" |
| 7544 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7545 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7546 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7547 | "void main() {\n" |
| 7548 | " gl_Position = gs_in[0].x;\n" |
| 7549 | " EmitVertex();\n" |
| 7550 | "}\n"; |
| 7551 | char const *fsSource = |
| 7552 | "#version 450\n" |
| 7553 | "layout(location=0) out vec4 color;\n" |
| 7554 | "void main(){\n" |
| 7555 | " color = vec4(1);\n" |
| 7556 | "}\n"; |
| 7557 | |
| 7558 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7559 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7560 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7561 | |
| 7562 | VkPipelineObj pipe(m_device); |
| 7563 | pipe.AddColorAttachment(); |
| 7564 | pipe.AddShader(&vs); |
| 7565 | pipe.AddShader(&gs); |
| 7566 | pipe.AddShader(&fs); |
| 7567 | |
| 7568 | VkDescriptorSetObj descriptorSet(m_device); |
| 7569 | descriptorSet.AppendDummy(); |
| 7570 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7571 | |
| 7572 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7573 | |
| 7574 | m_errorMonitor->VerifyNotFound(); |
| 7575 | } |
| 7576 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7577 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7578 | { |
| 7579 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7580 | "is per-vertex in tessellation control shader stage " |
| 7581 | "but per-patch in tessellation evaluation shader stage"); |
| 7582 | |
| 7583 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7584 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7585 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7586 | if (!m_device->phy().features().tessellationShader) { |
| 7587 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7588 | return; |
| 7589 | } |
| 7590 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7591 | char const *vsSource = |
| 7592 | "#version 450\n" |
| 7593 | "void main(){}\n"; |
| 7594 | char const *tcsSource = |
| 7595 | "#version 450\n" |
| 7596 | "layout(location=0) out int x[];\n" |
| 7597 | "layout(vertices=3) out;\n" |
| 7598 | "void main(){\n" |
| 7599 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7600 | " gl_TessLevelInner[0] = 1;\n" |
| 7601 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7602 | "}\n"; |
| 7603 | char const *tesSource = |
| 7604 | "#version 450\n" |
| 7605 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7606 | "layout(location=0) patch in int x;\n" |
| 7607 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7608 | "void main(){\n" |
| 7609 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7610 | " gl_Position.w = x;\n" |
| 7611 | "}\n"; |
| 7612 | char const *fsSource = |
| 7613 | "#version 450\n" |
| 7614 | "layout(location=0) out vec4 color;\n" |
| 7615 | "void main(){\n" |
| 7616 | " color = vec4(1);\n" |
| 7617 | "}\n"; |
| 7618 | |
| 7619 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7620 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7621 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7622 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7623 | |
| 7624 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7625 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7626 | nullptr, |
| 7627 | 0, |
| 7628 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7629 | VK_FALSE}; |
| 7630 | |
| 7631 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7632 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7633 | nullptr, |
| 7634 | 0, |
| 7635 | 3}; |
| 7636 | |
| 7637 | VkPipelineObj pipe(m_device); |
| 7638 | pipe.SetInputAssembly(&iasci); |
| 7639 | pipe.SetTessellation(&tsci); |
| 7640 | pipe.AddColorAttachment(); |
| 7641 | pipe.AddShader(&vs); |
| 7642 | pipe.AddShader(&tcs); |
| 7643 | pipe.AddShader(&tes); |
| 7644 | pipe.AddShader(&fs); |
| 7645 | |
| 7646 | VkDescriptorSetObj descriptorSet(m_device); |
| 7647 | descriptorSet.AppendDummy(); |
| 7648 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7649 | |
| 7650 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7651 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7652 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7653 | } |
| 7654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7655 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7656 | m_errorMonitor->SetDesiredFailureMsg( |
| 7657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7658 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7659 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7660 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7662 | |
| 7663 | /* Two binding descriptions for binding 0 */ |
| 7664 | VkVertexInputBindingDescription input_bindings[2]; |
| 7665 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7666 | |
| 7667 | VkVertexInputAttributeDescription input_attrib; |
| 7668 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7669 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7670 | |
| 7671 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7672 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7673 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7674 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7675 | "out gl_PerVertex {\n" |
| 7676 | " vec4 gl_Position;\n" |
| 7677 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7678 | "void main(){\n" |
| 7679 | " gl_Position = vec4(x);\n" |
| 7680 | "}\n"; |
| 7681 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7682 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7683 | "\n" |
| 7684 | "layout(location=0) out vec4 color;\n" |
| 7685 | "void main(){\n" |
| 7686 | " color = vec4(1);\n" |
| 7687 | "}\n"; |
| 7688 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7689 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7690 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7691 | |
| 7692 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7693 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7694 | pipe.AddShader(&vs); |
| 7695 | pipe.AddShader(&fs); |
| 7696 | |
| 7697 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7698 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7699 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7700 | VkDescriptorSetObj descriptorSet(m_device); |
| 7701 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7702 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7703 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7704 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7705 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7706 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7707 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7708 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7709 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7710 | m_errorMonitor->ExpectSuccess(); |
| 7711 | |
| 7712 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7713 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7714 | |
| 7715 | if (!m_device->phy().features().tessellationShader) { |
| 7716 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7717 | return; |
| 7718 | } |
| 7719 | |
| 7720 | VkVertexInputBindingDescription input_bindings[1]; |
| 7721 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7722 | |
| 7723 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7724 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7725 | input_attribs[0].location = 0; |
| 7726 | input_attribs[0].offset = 0; |
| 7727 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7728 | input_attribs[1].location = 2; |
| 7729 | input_attribs[1].offset = 32; |
| 7730 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7731 | input_attribs[2].location = 4; |
| 7732 | input_attribs[2].offset = 64; |
| 7733 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7734 | input_attribs[3].location = 6; |
| 7735 | input_attribs[3].offset = 96; |
| 7736 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7737 | |
| 7738 | char const *vsSource = |
| 7739 | "#version 450\n" |
| 7740 | "\n" |
| 7741 | "layout(location=0) in dmat4 x;\n" |
| 7742 | "out gl_PerVertex {\n" |
| 7743 | " vec4 gl_Position;\n" |
| 7744 | "};\n" |
| 7745 | "void main(){\n" |
| 7746 | " gl_Position = vec4(x[0][0]);\n" |
| 7747 | "}\n"; |
| 7748 | char const *fsSource = |
| 7749 | "#version 450\n" |
| 7750 | "\n" |
| 7751 | "layout(location=0) out vec4 color;\n" |
| 7752 | "void main(){\n" |
| 7753 | " color = vec4(1);\n" |
| 7754 | "}\n"; |
| 7755 | |
| 7756 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7757 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7758 | |
| 7759 | VkPipelineObj pipe(m_device); |
| 7760 | pipe.AddColorAttachment(); |
| 7761 | pipe.AddShader(&vs); |
| 7762 | pipe.AddShader(&fs); |
| 7763 | |
| 7764 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 7765 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 7766 | |
| 7767 | VkDescriptorSetObj descriptorSet(m_device); |
| 7768 | descriptorSet.AppendDummy(); |
| 7769 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7770 | |
| 7771 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7772 | |
| 7773 | m_errorMonitor->VerifyNotFound(); |
| 7774 | } |
| 7775 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7776 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7777 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7778 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7779 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7781 | |
| 7782 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7783 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7784 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7785 | "out gl_PerVertex {\n" |
| 7786 | " vec4 gl_Position;\n" |
| 7787 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7788 | "void main(){\n" |
| 7789 | " gl_Position = vec4(1);\n" |
| 7790 | "}\n"; |
| 7791 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7792 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7793 | "\n" |
| 7794 | "void main(){\n" |
| 7795 | "}\n"; |
| 7796 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7797 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7798 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7799 | |
| 7800 | VkPipelineObj pipe(m_device); |
| 7801 | pipe.AddShader(&vs); |
| 7802 | pipe.AddShader(&fs); |
| 7803 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7804 | /* set up CB 0, not written */ |
| 7805 | pipe.AddColorAttachment(); |
| 7806 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7807 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7808 | VkDescriptorSetObj descriptorSet(m_device); |
| 7809 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7810 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7811 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7812 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7813 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7814 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7815 | } |
| 7816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7817 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7818 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7819 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7820 | "FS writes to output location 1 with no matching attachment"); |
| 7821 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7822 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7823 | |
| 7824 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7825 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7826 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7827 | "out gl_PerVertex {\n" |
| 7828 | " vec4 gl_Position;\n" |
| 7829 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7830 | "void main(){\n" |
| 7831 | " gl_Position = vec4(1);\n" |
| 7832 | "}\n"; |
| 7833 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7834 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7835 | "\n" |
| 7836 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7837 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7838 | "void main(){\n" |
| 7839 | " x = vec4(1);\n" |
| 7840 | " y = vec4(1);\n" |
| 7841 | "}\n"; |
| 7842 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7843 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7844 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7845 | |
| 7846 | VkPipelineObj pipe(m_device); |
| 7847 | pipe.AddShader(&vs); |
| 7848 | pipe.AddShader(&fs); |
| 7849 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7850 | /* set up CB 0, not written */ |
| 7851 | pipe.AddColorAttachment(); |
| 7852 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7853 | /* FS writes CB 1, but we don't configure it */ |
| 7854 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7855 | VkDescriptorSetObj descriptorSet(m_device); |
| 7856 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7857 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7858 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7859 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7860 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7861 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7862 | } |
| 7863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7864 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7865 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7866 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7867 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7869 | |
| 7870 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7871 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7872 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7873 | "out gl_PerVertex {\n" |
| 7874 | " vec4 gl_Position;\n" |
| 7875 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7876 | "void main(){\n" |
| 7877 | " gl_Position = vec4(1);\n" |
| 7878 | "}\n"; |
| 7879 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7880 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7881 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7882 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7883 | "void main(){\n" |
| 7884 | " x = ivec4(1);\n" |
| 7885 | "}\n"; |
| 7886 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7887 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7888 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7889 | |
| 7890 | VkPipelineObj pipe(m_device); |
| 7891 | pipe.AddShader(&vs); |
| 7892 | pipe.AddShader(&fs); |
| 7893 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7894 | /* set up CB 0; type is UNORM by default */ |
| 7895 | pipe.AddColorAttachment(); |
| 7896 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7897 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7898 | VkDescriptorSetObj descriptorSet(m_device); |
| 7899 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7900 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7901 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7902 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7903 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7904 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7905 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 7906 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7907 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7908 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7909 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7910 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7911 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7912 | |
| 7913 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7914 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7915 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7916 | "out gl_PerVertex {\n" |
| 7917 | " vec4 gl_Position;\n" |
| 7918 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7919 | "void main(){\n" |
| 7920 | " gl_Position = vec4(1);\n" |
| 7921 | "}\n"; |
| 7922 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7923 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7924 | "\n" |
| 7925 | "layout(location=0) out vec4 x;\n" |
| 7926 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 7927 | "void main(){\n" |
| 7928 | " x = vec4(bar.y);\n" |
| 7929 | "}\n"; |
| 7930 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7931 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7932 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7933 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7934 | VkPipelineObj pipe(m_device); |
| 7935 | pipe.AddShader(&vs); |
| 7936 | pipe.AddShader(&fs); |
| 7937 | |
| 7938 | /* set up CB 0; type is UNORM by default */ |
| 7939 | pipe.AddColorAttachment(); |
| 7940 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7941 | |
| 7942 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7943 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7944 | |
| 7945 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7946 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7947 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7948 | } |
| 7949 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7950 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 7951 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7952 | "not declared in layout"); |
| 7953 | |
| 7954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7955 | |
| 7956 | char const *vsSource = |
| 7957 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7958 | "\n" |
| 7959 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 7960 | "out gl_PerVertex {\n" |
| 7961 | " vec4 gl_Position;\n" |
| 7962 | "};\n" |
| 7963 | "void main(){\n" |
| 7964 | " gl_Position = vec4(consts.x);\n" |
| 7965 | "}\n"; |
| 7966 | char const *fsSource = |
| 7967 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7968 | "\n" |
| 7969 | "layout(location=0) out vec4 x;\n" |
| 7970 | "void main(){\n" |
| 7971 | " x = vec4(1);\n" |
| 7972 | "}\n"; |
| 7973 | |
| 7974 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7975 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7976 | |
| 7977 | VkPipelineObj pipe(m_device); |
| 7978 | pipe.AddShader(&vs); |
| 7979 | pipe.AddShader(&fs); |
| 7980 | |
| 7981 | /* set up CB 0; type is UNORM by default */ |
| 7982 | pipe.AddColorAttachment(); |
| 7983 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7984 | |
| 7985 | VkDescriptorSetObj descriptorSet(m_device); |
| 7986 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7987 | |
| 7988 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7989 | |
| 7990 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7991 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7992 | } |
| 7993 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7994 | #endif // SHADER_CHECKER_TESTS |
| 7995 | |
| 7996 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7997 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7998 | m_errorMonitor->SetDesiredFailureMsg( |
| 7999 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8000 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8001 | |
| 8002 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8003 | |
| 8004 | // Create an image |
| 8005 | VkImage image; |
| 8006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8007 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8008 | const int32_t tex_width = 32; |
| 8009 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8010 | |
| 8011 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8012 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8013 | image_create_info.pNext = NULL; |
| 8014 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8015 | image_create_info.format = tex_format; |
| 8016 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8017 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8018 | image_create_info.extent.depth = 1; |
| 8019 | image_create_info.mipLevels = 1; |
| 8020 | image_create_info.arrayLayers = 1; |
| 8021 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8022 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8023 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8024 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8025 | |
| 8026 | // Introduce error by sending down a bogus width extent |
| 8027 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8028 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8029 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8030 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8031 | } |
| 8032 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8033 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8034 | m_errorMonitor->SetDesiredFailureMsg( |
| 8035 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8036 | "CreateImage extents is 0 for at least one required dimension"); |
| 8037 | |
| 8038 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8039 | |
| 8040 | // Create an image |
| 8041 | VkImage image; |
| 8042 | |
| 8043 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8044 | const int32_t tex_width = 32; |
| 8045 | const int32_t tex_height = 32; |
| 8046 | |
| 8047 | VkImageCreateInfo image_create_info = {}; |
| 8048 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8049 | image_create_info.pNext = NULL; |
| 8050 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8051 | image_create_info.format = tex_format; |
| 8052 | image_create_info.extent.width = tex_width; |
| 8053 | image_create_info.extent.height = tex_height; |
| 8054 | image_create_info.extent.depth = 1; |
| 8055 | image_create_info.mipLevels = 1; |
| 8056 | image_create_info.arrayLayers = 1; |
| 8057 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8058 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8059 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8060 | image_create_info.flags = 0; |
| 8061 | |
| 8062 | // Introduce error by sending down a bogus width extent |
| 8063 | image_create_info.extent.width = 0; |
| 8064 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8065 | |
| 8066 | m_errorMonitor->VerifyFound(); |
| 8067 | } |
| 8068 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8069 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8070 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8071 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8072 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8073 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8074 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8075 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8076 | |
| 8077 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8078 | vk_testing::Buffer buffer; |
| 8079 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8080 | |
| 8081 | BeginCommandBuffer(); |
| 8082 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8083 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8084 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8085 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8086 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8087 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8088 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8089 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8090 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8091 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8092 | EndCommandBuffer(); |
| 8093 | } |
| 8094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8095 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8096 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8097 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8098 | |
| 8099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8100 | |
| 8101 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8102 | vk_testing::Buffer buffer; |
| 8103 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8104 | |
| 8105 | BeginCommandBuffer(); |
| 8106 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8107 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8108 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8109 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8110 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8111 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8112 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8113 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8114 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8115 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8116 | m_errorMonitor->VerifyFound(); |
| 8117 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8118 | EndCommandBuffer(); |
| 8119 | } |
| 8120 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8121 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8122 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8123 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8124 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8125 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8127 | m_errorMonitor->SetDesiredFailureMsg( |
| 8128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8129 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8130 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8131 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8132 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8133 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8134 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8136 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8137 | const int32_t tex_width = 32; |
| 8138 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8139 | |
| 8140 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8141 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8142 | image_create_info.pNext = NULL; |
| 8143 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8144 | image_create_info.format = tex_format; |
| 8145 | image_create_info.extent.width = tex_width; |
| 8146 | image_create_info.extent.height = tex_height; |
| 8147 | image_create_info.extent.depth = 1; |
| 8148 | image_create_info.mipLevels = 1; |
| 8149 | image_create_info.arrayLayers = 1; |
| 8150 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8151 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8152 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8153 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8154 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8155 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8156 | ASSERT_VK_SUCCESS(err); |
| 8157 | |
| 8158 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8159 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8160 | image_view_create_info.image = image; |
| 8161 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8162 | image_view_create_info.format = tex_format; |
| 8163 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8164 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8165 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8166 | image_view_create_info.subresourceRange.aspectMask = |
| 8167 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8168 | |
| 8169 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8170 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8171 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8173 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8174 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8176 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8177 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8178 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8179 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8180 | "vkCreateImageView: Color image " |
| 8181 | "formats must have ONLY the " |
| 8182 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8183 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8184 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8185 | |
| 8186 | // 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] | 8187 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8189 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8190 | const int32_t tex_width = 32; |
| 8191 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8192 | |
| 8193 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8194 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8195 | image_create_info.pNext = NULL; |
| 8196 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8197 | image_create_info.format = tex_format; |
| 8198 | image_create_info.extent.width = tex_width; |
| 8199 | image_create_info.extent.height = tex_height; |
| 8200 | image_create_info.extent.depth = 1; |
| 8201 | image_create_info.mipLevels = 1; |
| 8202 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8203 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8204 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8205 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8206 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8207 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8208 | ASSERT_VK_SUCCESS(err); |
| 8209 | |
| 8210 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8211 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8212 | image_view_create_info.image = image; |
| 8213 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8214 | image_view_create_info.format = tex_format; |
| 8215 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8216 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8217 | // Cause an error by setting an invalid image aspect |
| 8218 | image_view_create_info.subresourceRange.aspectMask = |
| 8219 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8220 | |
| 8221 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8222 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8223 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8224 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8225 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8226 | } |
| 8227 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8228 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8229 | VkResult err; |
| 8230 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8232 | m_errorMonitor->SetDesiredFailureMsg( |
| 8233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8234 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8235 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8237 | |
| 8238 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8239 | VkImage srcImage; |
| 8240 | VkImage dstImage; |
| 8241 | VkDeviceMemory srcMem; |
| 8242 | VkDeviceMemory destMem; |
| 8243 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8244 | |
| 8245 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8246 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8247 | image_create_info.pNext = NULL; |
| 8248 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8249 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8250 | image_create_info.extent.width = 32; |
| 8251 | image_create_info.extent.height = 32; |
| 8252 | image_create_info.extent.depth = 1; |
| 8253 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8254 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8255 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8256 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8257 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8258 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8259 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | err = |
| 8261 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8262 | ASSERT_VK_SUCCESS(err); |
| 8263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8264 | err = |
| 8265 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8266 | ASSERT_VK_SUCCESS(err); |
| 8267 | |
| 8268 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8269 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8270 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8271 | memAlloc.pNext = NULL; |
| 8272 | memAlloc.allocationSize = 0; |
| 8273 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8274 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8275 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &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); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8279 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8280 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8281 | ASSERT_VK_SUCCESS(err); |
| 8282 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8283 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8284 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8285 | pass = |
| 8286 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8287 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8288 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8289 | ASSERT_VK_SUCCESS(err); |
| 8290 | |
| 8291 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8292 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8293 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8294 | ASSERT_VK_SUCCESS(err); |
| 8295 | |
| 8296 | BeginCommandBuffer(); |
| 8297 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8298 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8299 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8300 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8301 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8302 | copyRegion.srcOffset.x = 0; |
| 8303 | copyRegion.srcOffset.y = 0; |
| 8304 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8305 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8306 | copyRegion.dstSubresource.mipLevel = 0; |
| 8307 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8308 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8309 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8310 | copyRegion.dstOffset.x = 0; |
| 8311 | copyRegion.dstOffset.y = 0; |
| 8312 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8313 | copyRegion.extent.width = 1; |
| 8314 | copyRegion.extent.height = 1; |
| 8315 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8316 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8317 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8318 | EndCommandBuffer(); |
| 8319 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8320 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8321 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8322 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8323 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8324 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8325 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8326 | } |
| 8327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8328 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8329 | VkResult err; |
| 8330 | bool pass; |
| 8331 | |
| 8332 | // Create color images with different format sizes and try to copy between them |
| 8333 | m_errorMonitor->SetDesiredFailureMsg( |
| 8334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8335 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8336 | |
| 8337 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8338 | |
| 8339 | // Create two images of different types and try to copy between them |
| 8340 | VkImage srcImage; |
| 8341 | VkImage dstImage; |
| 8342 | VkDeviceMemory srcMem; |
| 8343 | VkDeviceMemory destMem; |
| 8344 | VkMemoryRequirements memReqs; |
| 8345 | |
| 8346 | VkImageCreateInfo image_create_info = {}; |
| 8347 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8348 | image_create_info.pNext = NULL; |
| 8349 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8350 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8351 | image_create_info.extent.width = 32; |
| 8352 | image_create_info.extent.height = 32; |
| 8353 | image_create_info.extent.depth = 1; |
| 8354 | image_create_info.mipLevels = 1; |
| 8355 | image_create_info.arrayLayers = 1; |
| 8356 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8357 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8358 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8359 | image_create_info.flags = 0; |
| 8360 | |
| 8361 | err = |
| 8362 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8363 | ASSERT_VK_SUCCESS(err); |
| 8364 | |
| 8365 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8366 | // Introduce failure by creating second image with a different-sized format. |
| 8367 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8368 | |
| 8369 | err = |
| 8370 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8371 | ASSERT_VK_SUCCESS(err); |
| 8372 | |
| 8373 | // Allocate memory |
| 8374 | VkMemoryAllocateInfo memAlloc = {}; |
| 8375 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8376 | memAlloc.pNext = NULL; |
| 8377 | memAlloc.allocationSize = 0; |
| 8378 | memAlloc.memoryTypeIndex = 0; |
| 8379 | |
| 8380 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &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, &srcMem); |
| 8386 | ASSERT_VK_SUCCESS(err); |
| 8387 | |
| 8388 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 8389 | memAlloc.allocationSize = memReqs.size; |
| 8390 | pass = |
| 8391 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8392 | ASSERT_TRUE(pass); |
| 8393 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 8394 | ASSERT_VK_SUCCESS(err); |
| 8395 | |
| 8396 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8397 | ASSERT_VK_SUCCESS(err); |
| 8398 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 8399 | ASSERT_VK_SUCCESS(err); |
| 8400 | |
| 8401 | BeginCommandBuffer(); |
| 8402 | VkImageCopy copyRegion; |
| 8403 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8404 | copyRegion.srcSubresource.mipLevel = 0; |
| 8405 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8406 | copyRegion.srcSubresource.layerCount = 0; |
| 8407 | copyRegion.srcOffset.x = 0; |
| 8408 | copyRegion.srcOffset.y = 0; |
| 8409 | copyRegion.srcOffset.z = 0; |
| 8410 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8411 | copyRegion.dstSubresource.mipLevel = 0; |
| 8412 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8413 | copyRegion.dstSubresource.layerCount = 0; |
| 8414 | copyRegion.dstOffset.x = 0; |
| 8415 | copyRegion.dstOffset.y = 0; |
| 8416 | copyRegion.dstOffset.z = 0; |
| 8417 | copyRegion.extent.width = 1; |
| 8418 | copyRegion.extent.height = 1; |
| 8419 | copyRegion.extent.depth = 1; |
| 8420 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8421 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8422 | EndCommandBuffer(); |
| 8423 | |
| 8424 | m_errorMonitor->VerifyFound(); |
| 8425 | |
| 8426 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 8427 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 8428 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8429 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8430 | } |
| 8431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8432 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 8433 | VkResult err; |
| 8434 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8435 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8436 | // 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] | 8437 | m_errorMonitor->SetDesiredFailureMsg( |
| 8438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8439 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8440 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8442 | |
| 8443 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8444 | VkImage srcImage; |
| 8445 | VkImage dstImage; |
| 8446 | VkDeviceMemory srcMem; |
| 8447 | VkDeviceMemory destMem; |
| 8448 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8449 | |
| 8450 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8451 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8452 | image_create_info.pNext = NULL; |
| 8453 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8454 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8455 | image_create_info.extent.width = 32; |
| 8456 | image_create_info.extent.height = 32; |
| 8457 | image_create_info.extent.depth = 1; |
| 8458 | image_create_info.mipLevels = 1; |
| 8459 | image_create_info.arrayLayers = 1; |
| 8460 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8461 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8462 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8463 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8465 | err = |
| 8466 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8467 | ASSERT_VK_SUCCESS(err); |
| 8468 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8469 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8470 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8471 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8472 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8473 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8474 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8476 | err = |
| 8477 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8478 | ASSERT_VK_SUCCESS(err); |
| 8479 | |
| 8480 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8481 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8482 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8483 | memAlloc.pNext = NULL; |
| 8484 | memAlloc.allocationSize = 0; |
| 8485 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8486 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8487 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &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, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8493 | ASSERT_VK_SUCCESS(err); |
| 8494 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8495 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8496 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8497 | pass = |
| 8498 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8499 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8500 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8501 | ASSERT_VK_SUCCESS(err); |
| 8502 | |
| 8503 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8504 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8505 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8506 | ASSERT_VK_SUCCESS(err); |
| 8507 | |
| 8508 | BeginCommandBuffer(); |
| 8509 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8510 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8511 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8512 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8513 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8514 | copyRegion.srcOffset.x = 0; |
| 8515 | copyRegion.srcOffset.y = 0; |
| 8516 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8517 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8518 | copyRegion.dstSubresource.mipLevel = 0; |
| 8519 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8520 | copyRegion.dstSubresource.layerCount = 0; |
| 8521 | copyRegion.dstOffset.x = 0; |
| 8522 | copyRegion.dstOffset.y = 0; |
| 8523 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8524 | copyRegion.extent.width = 1; |
| 8525 | copyRegion.extent.height = 1; |
| 8526 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8527 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8528 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8529 | EndCommandBuffer(); |
| 8530 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8531 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8532 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8533 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8534 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8535 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8536 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8537 | } |
| 8538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8539 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 8540 | VkResult err; |
| 8541 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8542 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8543 | m_errorMonitor->SetDesiredFailureMsg( |
| 8544 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8545 | "vkCmdResolveImage called with source sample count less than 2."); |
| 8546 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8548 | |
| 8549 | // 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] | 8550 | VkImage srcImage; |
| 8551 | VkImage dstImage; |
| 8552 | VkDeviceMemory srcMem; |
| 8553 | VkDeviceMemory destMem; |
| 8554 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8555 | |
| 8556 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8557 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8558 | image_create_info.pNext = NULL; |
| 8559 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8560 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8561 | image_create_info.extent.width = 32; |
| 8562 | image_create_info.extent.height = 1; |
| 8563 | image_create_info.extent.depth = 1; |
| 8564 | image_create_info.mipLevels = 1; |
| 8565 | image_create_info.arrayLayers = 1; |
| 8566 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8567 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8568 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8569 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8571 | err = |
| 8572 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8573 | ASSERT_VK_SUCCESS(err); |
| 8574 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8575 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8576 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8577 | err = |
| 8578 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8579 | ASSERT_VK_SUCCESS(err); |
| 8580 | |
| 8581 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8582 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8583 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8584 | memAlloc.pNext = NULL; |
| 8585 | memAlloc.allocationSize = 0; |
| 8586 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8587 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8588 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8589 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8590 | pass = |
| 8591 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8592 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8593 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8594 | ASSERT_VK_SUCCESS(err); |
| 8595 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8596 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8597 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8598 | pass = |
| 8599 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8600 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8601 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8602 | ASSERT_VK_SUCCESS(err); |
| 8603 | |
| 8604 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8605 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8606 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8607 | ASSERT_VK_SUCCESS(err); |
| 8608 | |
| 8609 | BeginCommandBuffer(); |
| 8610 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8611 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8612 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8613 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8614 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8615 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8616 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8617 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8618 | resolveRegion.srcOffset.x = 0; |
| 8619 | resolveRegion.srcOffset.y = 0; |
| 8620 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8621 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8622 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8623 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8624 | resolveRegion.dstSubresource.layerCount = 0; |
| 8625 | resolveRegion.dstOffset.x = 0; |
| 8626 | resolveRegion.dstOffset.y = 0; |
| 8627 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8628 | resolveRegion.extent.width = 1; |
| 8629 | resolveRegion.extent.height = 1; |
| 8630 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8631 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8632 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8633 | EndCommandBuffer(); |
| 8634 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8635 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8636 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8637 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8638 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8639 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8640 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8641 | } |
| 8642 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8643 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 8644 | VkResult err; |
| 8645 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8647 | m_errorMonitor->SetDesiredFailureMsg( |
| 8648 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8649 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 8650 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8652 | |
| 8653 | // 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] | 8654 | VkImage srcImage; |
| 8655 | VkImage dstImage; |
| 8656 | VkDeviceMemory srcMem; |
| 8657 | VkDeviceMemory destMem; |
| 8658 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8659 | |
| 8660 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8661 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8662 | image_create_info.pNext = NULL; |
| 8663 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8664 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8665 | image_create_info.extent.width = 32; |
| 8666 | image_create_info.extent.height = 1; |
| 8667 | image_create_info.extent.depth = 1; |
| 8668 | image_create_info.mipLevels = 1; |
| 8669 | image_create_info.arrayLayers = 1; |
| 8670 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8671 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8672 | // Note: Some implementations expect color attachment usage for any |
| 8673 | // multisample surface |
| 8674 | image_create_info.usage = |
| 8675 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8676 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8677 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8678 | err = |
| 8679 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8680 | ASSERT_VK_SUCCESS(err); |
| 8681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8682 | // Note: Some implementations expect color attachment usage for any |
| 8683 | // multisample surface |
| 8684 | image_create_info.usage = |
| 8685 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8686 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8687 | err = |
| 8688 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8689 | ASSERT_VK_SUCCESS(err); |
| 8690 | |
| 8691 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8692 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8693 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8694 | memAlloc.pNext = NULL; |
| 8695 | memAlloc.allocationSize = 0; |
| 8696 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8697 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8698 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8699 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8700 | pass = |
| 8701 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8702 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8703 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8704 | ASSERT_VK_SUCCESS(err); |
| 8705 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8706 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8707 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8708 | pass = |
| 8709 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8710 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8711 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8712 | ASSERT_VK_SUCCESS(err); |
| 8713 | |
| 8714 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8715 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8716 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8717 | ASSERT_VK_SUCCESS(err); |
| 8718 | |
| 8719 | BeginCommandBuffer(); |
| 8720 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8721 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8722 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8723 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8724 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8725 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8726 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8727 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8728 | resolveRegion.srcOffset.x = 0; |
| 8729 | resolveRegion.srcOffset.y = 0; |
| 8730 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8731 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8732 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8733 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8734 | resolveRegion.dstSubresource.layerCount = 0; |
| 8735 | resolveRegion.dstOffset.x = 0; |
| 8736 | resolveRegion.dstOffset.y = 0; |
| 8737 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8738 | resolveRegion.extent.width = 1; |
| 8739 | resolveRegion.extent.height = 1; |
| 8740 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8741 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8742 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8743 | EndCommandBuffer(); |
| 8744 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8745 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8746 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8747 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8748 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8749 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8750 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8751 | } |
| 8752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8753 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 8754 | VkResult err; |
| 8755 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8756 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8757 | m_errorMonitor->SetDesiredFailureMsg( |
| 8758 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8759 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 8760 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8761 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8762 | |
| 8763 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8764 | VkImage srcImage; |
| 8765 | VkImage dstImage; |
| 8766 | VkDeviceMemory srcMem; |
| 8767 | VkDeviceMemory destMem; |
| 8768 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8769 | |
| 8770 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8771 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8772 | image_create_info.pNext = NULL; |
| 8773 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8774 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8775 | image_create_info.extent.width = 32; |
| 8776 | image_create_info.extent.height = 1; |
| 8777 | image_create_info.extent.depth = 1; |
| 8778 | image_create_info.mipLevels = 1; |
| 8779 | image_create_info.arrayLayers = 1; |
| 8780 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8781 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8782 | // Note: Some implementations expect color attachment usage for any |
| 8783 | // multisample surface |
| 8784 | image_create_info.usage = |
| 8785 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8786 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8787 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8788 | err = |
| 8789 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8790 | ASSERT_VK_SUCCESS(err); |
| 8791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8792 | // Set format to something other than source image |
| 8793 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 8794 | // Note: Some implementations expect color attachment usage for any |
| 8795 | // multisample surface |
| 8796 | image_create_info.usage = |
| 8797 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8798 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8800 | err = |
| 8801 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8802 | ASSERT_VK_SUCCESS(err); |
| 8803 | |
| 8804 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8805 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8806 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8807 | memAlloc.pNext = NULL; |
| 8808 | memAlloc.allocationSize = 0; |
| 8809 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8810 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8811 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8812 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8813 | pass = |
| 8814 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8815 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8816 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8817 | ASSERT_VK_SUCCESS(err); |
| 8818 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8819 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8820 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8821 | pass = |
| 8822 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8823 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8824 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8825 | ASSERT_VK_SUCCESS(err); |
| 8826 | |
| 8827 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8828 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8829 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8830 | ASSERT_VK_SUCCESS(err); |
| 8831 | |
| 8832 | BeginCommandBuffer(); |
| 8833 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8834 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8835 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8836 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8837 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8838 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8839 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8840 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8841 | resolveRegion.srcOffset.x = 0; |
| 8842 | resolveRegion.srcOffset.y = 0; |
| 8843 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8844 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8845 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8846 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8847 | resolveRegion.dstSubresource.layerCount = 0; |
| 8848 | resolveRegion.dstOffset.x = 0; |
| 8849 | resolveRegion.dstOffset.y = 0; |
| 8850 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8851 | resolveRegion.extent.width = 1; |
| 8852 | resolveRegion.extent.height = 1; |
| 8853 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8854 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8855 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8856 | EndCommandBuffer(); |
| 8857 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8858 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8859 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8860 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8861 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8862 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8863 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8864 | } |
| 8865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8866 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 8867 | VkResult err; |
| 8868 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8869 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8870 | m_errorMonitor->SetDesiredFailureMsg( |
| 8871 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8872 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 8873 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8874 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8875 | |
| 8876 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8877 | VkImage srcImage; |
| 8878 | VkImage dstImage; |
| 8879 | VkDeviceMemory srcMem; |
| 8880 | VkDeviceMemory destMem; |
| 8881 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8882 | |
| 8883 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8884 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8885 | image_create_info.pNext = NULL; |
| 8886 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8887 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8888 | image_create_info.extent.width = 32; |
| 8889 | image_create_info.extent.height = 1; |
| 8890 | image_create_info.extent.depth = 1; |
| 8891 | image_create_info.mipLevels = 1; |
| 8892 | image_create_info.arrayLayers = 1; |
| 8893 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8894 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8895 | // Note: Some implementations expect color attachment usage for any |
| 8896 | // multisample surface |
| 8897 | image_create_info.usage = |
| 8898 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8899 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8901 | err = |
| 8902 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8903 | ASSERT_VK_SUCCESS(err); |
| 8904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8905 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8906 | // Note: Some implementations expect color attachment usage for any |
| 8907 | // multisample surface |
| 8908 | image_create_info.usage = |
| 8909 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8910 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8911 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8912 | err = |
| 8913 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8914 | ASSERT_VK_SUCCESS(err); |
| 8915 | |
| 8916 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8917 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8918 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8919 | memAlloc.pNext = NULL; |
| 8920 | memAlloc.allocationSize = 0; |
| 8921 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8922 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8923 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8924 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8925 | pass = |
| 8926 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8927 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8928 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8929 | ASSERT_VK_SUCCESS(err); |
| 8930 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8931 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8932 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8933 | pass = |
| 8934 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8935 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8936 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8937 | ASSERT_VK_SUCCESS(err); |
| 8938 | |
| 8939 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8940 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8941 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8942 | ASSERT_VK_SUCCESS(err); |
| 8943 | |
| 8944 | BeginCommandBuffer(); |
| 8945 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8946 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8947 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8948 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8949 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8950 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8951 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8952 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8953 | resolveRegion.srcOffset.x = 0; |
| 8954 | resolveRegion.srcOffset.y = 0; |
| 8955 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8956 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8957 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8958 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8959 | resolveRegion.dstSubresource.layerCount = 0; |
| 8960 | resolveRegion.dstOffset.x = 0; |
| 8961 | resolveRegion.dstOffset.y = 0; |
| 8962 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8963 | resolveRegion.extent.width = 1; |
| 8964 | resolveRegion.extent.height = 1; |
| 8965 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8966 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8967 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8968 | EndCommandBuffer(); |
| 8969 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8970 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8971 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8972 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8973 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8974 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8975 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8976 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8978 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8979 | // 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] | 8980 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 8981 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8982 | // The image format check comes 2nd in validation so we trigger it first, |
| 8983 | // 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] | 8984 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8986 | m_errorMonitor->SetDesiredFailureMsg( |
| 8987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8988 | "Combination depth/stencil image formats can have only the "); |
| 8989 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8991 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8992 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8993 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8994 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8995 | |
| 8996 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8997 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8998 | ds_pool_ci.pNext = NULL; |
| 8999 | ds_pool_ci.maxSets = 1; |
| 9000 | ds_pool_ci.poolSizeCount = 1; |
| 9001 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9002 | |
| 9003 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9004 | err = |
| 9005 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9006 | ASSERT_VK_SUCCESS(err); |
| 9007 | |
| 9008 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9009 | dsl_binding.binding = 0; |
| 9010 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9011 | dsl_binding.descriptorCount = 1; |
| 9012 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9013 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9014 | |
| 9015 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9016 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9017 | ds_layout_ci.pNext = NULL; |
| 9018 | ds_layout_ci.bindingCount = 1; |
| 9019 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9020 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9021 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9022 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9023 | ASSERT_VK_SUCCESS(err); |
| 9024 | |
| 9025 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9026 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9027 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9028 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9029 | alloc_info.descriptorPool = ds_pool; |
| 9030 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9031 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9032 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9033 | ASSERT_VK_SUCCESS(err); |
| 9034 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9035 | VkImage image_bad; |
| 9036 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9037 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9038 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9039 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9040 | const int32_t tex_width = 32; |
| 9041 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9042 | |
| 9043 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9044 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9045 | image_create_info.pNext = NULL; |
| 9046 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9047 | image_create_info.format = tex_format_bad; |
| 9048 | image_create_info.extent.width = tex_width; |
| 9049 | image_create_info.extent.height = tex_height; |
| 9050 | image_create_info.extent.depth = 1; |
| 9051 | image_create_info.mipLevels = 1; |
| 9052 | image_create_info.arrayLayers = 1; |
| 9053 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9054 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9055 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9056 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9057 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9059 | err = |
| 9060 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9061 | ASSERT_VK_SUCCESS(err); |
| 9062 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9063 | image_create_info.usage = |
| 9064 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9065 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9066 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9067 | ASSERT_VK_SUCCESS(err); |
| 9068 | |
| 9069 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9070 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9071 | image_view_create_info.image = image_bad; |
| 9072 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9073 | image_view_create_info.format = tex_format_bad; |
| 9074 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9075 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9076 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9077 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9078 | image_view_create_info.subresourceRange.aspectMask = |
| 9079 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9080 | |
| 9081 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9082 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9083 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9084 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9085 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9086 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9087 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9088 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9089 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9090 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9091 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9092 | #endif // IMAGE_TESTS |
| 9093 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9094 | int main(int argc, char **argv) { |
| 9095 | int result; |
| 9096 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9097 | #ifdef ANDROID |
| 9098 | int vulkanSupport = InitVulkan(); |
| 9099 | if (vulkanSupport == 0) |
| 9100 | return 1; |
| 9101 | #endif |
| 9102 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9103 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9104 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9105 | |
| 9106 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9107 | |
| 9108 | result = RUN_ALL_TESTS(); |
| 9109 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9110 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9111 | return result; |
| 9112 | } |