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 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 66 | BsoFailCmdClearAttachments = 0x00000200, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 67 | } BsoFailSelect; |
| 68 | |
| 69 | struct vktriangle_vs_uniform { |
| 70 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 71 | float mvp[4][4]; |
| 72 | float position[3][4]; |
| 73 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 74 | }; |
| 75 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 76 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 77 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | "vec2 vertices[3];\n" |
| 79 | "out gl_PerVertex {\n" |
| 80 | " vec4 gl_Position;\n" |
| 81 | "};\n" |
| 82 | "void main() {\n" |
| 83 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 84 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 85 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 86 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 87 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 88 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 89 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 90 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 91 | "\n" |
| 92 | "layout(location = 0) out vec4 uFragColor;\n" |
| 93 | "void main(){\n" |
| 94 | " uFragColor = vec4(0,1,0,1);\n" |
| 95 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 96 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 97 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 98 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 99 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 100 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 102 | // ******************************************************** |
| 103 | // ErrorMonitor Usage: |
| 104 | // |
| 105 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 106 | // encountered log messages. Passing NULL will match all log messages. |
| 107 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 108 | // |
| 109 | // Call DesiredMsgFound to determine if the desired failure message |
| 110 | // was encountered. |
| 111 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 112 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 113 | public: |
| 114 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 115 | test_platform_thread_create_mutex(&m_mutex); |
| 116 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 117 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 118 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 119 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 120 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 121 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 122 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 124 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 125 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 127 | m_failureMsg.clear(); |
| 128 | m_otherMsgs.clear(); |
| 129 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 130 | m_msgFound = VK_FALSE; |
| 131 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 132 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 133 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 134 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 135 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 137 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 138 | if (m_bailout != NULL) { |
| 139 | *m_bailout = true; |
| 140 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 141 | string errorString(msgString); |
| 142 | if (msgFlags & m_msgFlags) { |
| 143 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 144 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 145 | m_otherMsgs.push_back(m_failureMsg); |
| 146 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 148 | m_msgFound = VK_TRUE; |
| 149 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 150 | } else { |
| 151 | m_otherMsgs.push_back(errorString); |
| 152 | } |
| 153 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 154 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 155 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 156 | } |
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 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
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 | string GetFailureMsg(void) { return m_failureMsg; } |
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 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 166 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 168 | cout << "Other error messages logged for this test were:" << endl; |
| 169 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 170 | cout << " " << *iter << endl; |
| 171 | } |
| 172 | } |
| 173 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 174 | /* helpers */ |
| 175 | |
| 176 | void ExpectSuccess() { |
| 177 | // match anything |
| 178 | SetDesiredFailureMsg(~0u, ""); |
| 179 | } |
| 180 | |
| 181 | void VerifyFound() { |
| 182 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 183 | // any other messages. |
| 184 | if (!DesiredMsgFound()) { |
| 185 | DumpFailureMsgs(); |
| 186 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | void VerifyNotFound() { |
| 191 | // ExpectSuccess() configured us to match anything. Any error is a |
| 192 | // failure. |
| 193 | if (DesiredMsgFound()) { |
| 194 | DumpFailureMsgs(); |
| 195 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 196 | } |
| 197 | } |
| 198 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 199 | private: |
| 200 | VkFlags m_msgFlags; |
| 201 | string m_desiredMsg; |
| 202 | string m_failureMsg; |
| 203 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 204 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 205 | bool *m_bailout; |
| 206 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 207 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 209 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 210 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 211 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 212 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 213 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 214 | (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] | 215 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 217 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 218 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 219 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 221 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 222 | class VkLayerTest : public VkRenderFramework { |
| 223 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 224 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 225 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 226 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 227 | BsoFailSelect failMask); |
| 228 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 229 | VkPipelineObj &pipelineobj, |
| 230 | VkDescriptorSetObj &descriptorSet, |
| 231 | BsoFailSelect failMask); |
| 232 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 233 | VkDescriptorSetObj &descriptorSet, |
| 234 | BsoFailSelect failMask) { |
| 235 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 236 | failMask); |
| 237 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 238 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 239 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 240 | VkResult BeginCommandBuffer() { |
| 241 | return BeginCommandBuffer(*m_commandBuffer); |
| 242 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 243 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 244 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 245 | uint32_t firstVertex, uint32_t firstInstance) { |
| 246 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 247 | firstInstance); |
| 248 | } |
| 249 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 250 | uint32_t firstIndex, int32_t vertexOffset, |
| 251 | uint32_t firstInstance) { |
| 252 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 253 | vertexOffset, firstInstance); |
| 254 | } |
Mark Lobodzinski | cf0ae75 | 2016-06-23 10:02:24 -0600 | [diff] [blame] | 255 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 256 | void QueueCommandBuffer(const VkFence &fence) { |
| 257 | m_commandBuffer->QueueCommandBuffer(fence); |
| 258 | } |
| 259 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 260 | VkDeviceSize offset, uint32_t binding) { |
| 261 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 262 | } |
| 263 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 264 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 265 | } |
| 266 | |
| 267 | protected: |
| 268 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 269 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 270 | |
| 271 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_layer_names; |
| 273 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 274 | std::vector<const char *> instance_extension_names; |
| 275 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 276 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 277 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 278 | /* |
| 279 | * Since CreateDbgMsgCallback is an instance level extension call |
| 280 | * any extension / layer that utilizes that feature also needs |
| 281 | * to be enabled at create instance time. |
| 282 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 283 | // Use Threading layer first to protect others from |
| 284 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 292 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 293 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 299 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 301 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 303 | if (m_enableWSI) { |
| 304 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 305 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 306 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 307 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 308 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 309 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 310 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 311 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 312 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 313 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 314 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 315 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 316 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 317 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 318 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 319 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 320 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 321 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 322 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 323 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 324 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 325 | } |
| 326 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 327 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 328 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 329 | this->app_info.pApplicationName = "layer_tests"; |
| 330 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 331 | this->app_info.pEngineName = "unittest"; |
| 332 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 333 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 334 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 335 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 336 | InitFramework(instance_layer_names, device_layer_names, |
| 337 | instance_extension_names, device_extension_names, |
| 338 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | virtual void TearDown() { |
| 342 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 343 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 344 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 345 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 346 | |
| 347 | VkLayerTest() { |
| 348 | m_enableWSI = false; |
| 349 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 350 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 352 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 353 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 354 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 355 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 356 | |
| 357 | /* |
| 358 | * For render test all drawing happens in a single render pass |
| 359 | * on a single command buffer. |
| 360 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 361 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 362 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | return result; |
| 366 | } |
| 367 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 368 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 369 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 370 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 371 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 372 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 373 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 374 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 375 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 376 | |
| 377 | return result; |
| 378 | } |
| 379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 380 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 381 | const char *fragShaderText, |
| 382 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | // Create identity matrix |
| 384 | int i; |
| 385 | struct vktriangle_vs_uniform data; |
| 386 | |
| 387 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 388 | glm::mat4 View = glm::mat4(1.0f); |
| 389 | glm::mat4 Model = glm::mat4(1.0f); |
| 390 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 392 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 393 | |
| 394 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 396 | static const Vertex tri_data[] = { |
| 397 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 398 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 399 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 400 | }; |
| 401 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 402 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | data.position[i][0] = tri_data[i].posX; |
| 404 | data.position[i][1] = tri_data[i].posY; |
| 405 | data.position[i][2] = tri_data[i].posZ; |
| 406 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 407 | data.color[i][0] = tri_data[i].r; |
| 408 | data.color[i][1] = tri_data[i].g; |
| 409 | data.color[i][2] = tri_data[i].b; |
| 410 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 414 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 415 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 416 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 417 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 419 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 420 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 421 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | |
| 423 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 424 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | pipelineobj.AddShader(&vs); |
| 426 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 427 | if (failMask & BsoFailLineWidth) { |
| 428 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 429 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 430 | ia_state.sType = |
| 431 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 432 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 433 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 434 | } |
| 435 | if (failMask & BsoFailDepthBias) { |
| 436 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 437 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 438 | rs_state.sType = |
| 439 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 440 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 441 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 442 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 443 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 444 | // Viewport and scissors must stay in synch or other errors will occur than |
| 445 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 446 | if (failMask & BsoFailViewport) { |
| 447 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 448 | m_viewports.clear(); |
| 449 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 450 | } |
| 451 | if (failMask & BsoFailScissor) { |
| 452 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 453 | m_scissors.clear(); |
| 454 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 455 | } |
| 456 | if (failMask & BsoFailBlend) { |
| 457 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 458 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 459 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 460 | att_state.blendEnable = VK_TRUE; |
| 461 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 462 | } |
| 463 | if (failMask & BsoFailDepthBounds) { |
| 464 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 465 | } |
| 466 | if (failMask & BsoFailStencilReadMask) { |
| 467 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 468 | } |
| 469 | if (failMask & BsoFailStencilWriteMask) { |
| 470 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 471 | } |
| 472 | if (failMask & BsoFailStencilReference) { |
| 473 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 474 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 475 | |
| 476 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 478 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 479 | |
| 480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 481 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 482 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 483 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 484 | |
| 485 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 486 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 487 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 488 | if (failMask & BsoFailCmdClearAttachments) { |
| 489 | VkClearAttachment color_attachment = {}; |
| 490 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 491 | color_attachment.colorAttachment = 1; // Someone who knew what they were doing would use 0 for the index; |
| 492 | VkClearRect clear_rect = {{{0, 0}, {static_cast<uint32_t>(m_width), static_cast<uint32_t>(m_height)}}, 0, 0}; |
| 493 | |
| 494 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 495 | &color_attachment, 1, &clear_rect); |
| 496 | } |
| 497 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 498 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 499 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 501 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 502 | } |
| 503 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 504 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 505 | VkPipelineObj &pipelineobj, |
| 506 | VkDescriptorSetObj &descriptorSet, |
| 507 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 508 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 509 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 510 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 511 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 512 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 513 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 514 | } |
| 515 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 516 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 517 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 518 | // correctly |
| 519 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 520 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 521 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 522 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 523 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 524 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 525 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 526 | |
| 527 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 528 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 529 | ds_ci.pNext = NULL; |
| 530 | ds_ci.depthTestEnable = VK_FALSE; |
| 531 | ds_ci.depthWriteEnable = VK_TRUE; |
| 532 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 533 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 534 | if (failMask & BsoFailDepthBounds) { |
| 535 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 536 | ds_ci.maxDepthBounds = 0.0f; |
| 537 | ds_ci.minDepthBounds = 0.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 538 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 539 | ds_ci.stencilTestEnable = VK_TRUE; |
| 540 | ds_ci.front = stencil; |
| 541 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 542 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 543 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 544 | pipelineobj.SetViewport(m_viewports); |
| 545 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 546 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 547 | VkResult err = pipelineobj.CreateVKPipeline( |
| 548 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 549 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 550 | commandBuffer->BindPipeline(pipelineobj); |
| 551 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 552 | } |
| 553 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 554 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 555 | public: |
| 556 | protected: |
| 557 | VkWsiEnabledLayerTest() { |
| 558 | m_enableWSI = true; |
| 559 | } |
| 560 | }; |
| 561 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 562 | // ******************************************************************************************************************** |
| 563 | // ******************************************************************************************************************** |
| 564 | // ******************************************************************************************************************** |
| 565 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 566 | #if PARAMETER_VALIDATION_TESTS |
| 567 | TEST_F(VkLayerTest, RequiredParameter) { |
| 568 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 569 | "pointer, array, and array count parameters"); |
| 570 | |
| 571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 572 | |
| 573 | m_errorMonitor->SetDesiredFailureMsg( |
| 574 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 575 | "required parameter pFeatures specified as NULL"); |
| 576 | // Specify NULL for a pointer to a handle |
| 577 | // Expected to trigger an error with |
| 578 | // parameter_validation::validate_required_pointer |
| 579 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 580 | m_errorMonitor->VerifyFound(); |
| 581 | |
| 582 | m_errorMonitor->SetDesiredFailureMsg( |
| 583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 584 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 585 | // Specify NULL for pointer to array count |
| 586 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 587 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 588 | m_errorMonitor->VerifyFound(); |
| 589 | |
| 590 | m_errorMonitor->SetDesiredFailureMsg( |
| 591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 592 | "parameter viewportCount must be greater than 0"); |
| 593 | // Specify 0 for a required array count |
| 594 | // Expected to trigger an error with parameter_validation::validate_array |
| 595 | VkViewport view_port = {}; |
| 596 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 597 | m_errorMonitor->VerifyFound(); |
| 598 | |
| 599 | m_errorMonitor->SetDesiredFailureMsg( |
| 600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 601 | "required parameter pViewports specified as NULL"); |
| 602 | // Specify NULL for a required array |
| 603 | // Expected to trigger an error with parameter_validation::validate_array |
| 604 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 605 | m_errorMonitor->VerifyFound(); |
| 606 | |
| 607 | m_errorMonitor->SetDesiredFailureMsg( |
| 608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 609 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 610 | // Specify VK_NULL_HANDLE for a required handle |
| 611 | // Expected to trigger an error with |
| 612 | // parameter_validation::validate_required_handle |
| 613 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 614 | m_errorMonitor->VerifyFound(); |
| 615 | |
| 616 | m_errorMonitor->SetDesiredFailureMsg( |
| 617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 618 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 619 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 620 | // Expected to trigger an error with |
| 621 | // parameter_validation::validate_required_handle_array |
| 622 | VkFence fence = VK_NULL_HANDLE; |
| 623 | vkResetFences(device(), 1, &fence); |
| 624 | m_errorMonitor->VerifyFound(); |
| 625 | |
| 626 | m_errorMonitor->SetDesiredFailureMsg( |
| 627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 628 | "required parameter pAllocateInfo specified as NULL"); |
| 629 | // Specify NULL for a required struct pointer |
| 630 | // Expected to trigger an error with |
| 631 | // parameter_validation::validate_struct_type |
| 632 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 633 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 634 | m_errorMonitor->VerifyFound(); |
| 635 | |
| 636 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 637 | "value of faceMask must not be 0"); |
| 638 | // Specify 0 for a required VkFlags parameter |
| 639 | // Expected to trigger an error with parameter_validation::validate_flags |
| 640 | m_commandBuffer->SetStencilReference(0, 0); |
| 641 | m_errorMonitor->VerifyFound(); |
| 642 | |
| 643 | m_errorMonitor->SetDesiredFailureMsg( |
| 644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 645 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 646 | // Specify 0 for a required VkFlags array entry |
| 647 | // Expected to trigger an error with |
| 648 | // parameter_validation::validate_flags_array |
| 649 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 650 | VkPipelineStageFlags stageFlags = 0; |
| 651 | VkSubmitInfo submitInfo = {}; |
| 652 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 653 | submitInfo.waitSemaphoreCount = 1; |
| 654 | submitInfo.pWaitSemaphores = &semaphore; |
| 655 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 656 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 657 | m_errorMonitor->VerifyFound(); |
| 658 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 659 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 660 | TEST_F(VkLayerTest, ReservedParameter) { |
| 661 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 662 | |
| 663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 664 | |
| 665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 666 | " must be 0"); |
| 667 | // Specify 0 for a reserved VkFlags parameter |
| 668 | // Expected to trigger an error with |
| 669 | // parameter_validation::validate_reserved_flags |
| 670 | VkEvent event_handle = VK_NULL_HANDLE; |
| 671 | VkEventCreateInfo event_info = {}; |
| 672 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 673 | event_info.flags = 1; |
| 674 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 675 | m_errorMonitor->VerifyFound(); |
| 676 | } |
| 677 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 678 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 679 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 680 | "structure's sType field"); |
| 681 | |
| 682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 683 | |
| 684 | m_errorMonitor->SetDesiredFailureMsg( |
| 685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "parameter pAllocateInfo->sType must be"); |
| 687 | // Zero struct memory, effectively setting sType to |
| 688 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 689 | // Expected to trigger an error with |
| 690 | // parameter_validation::validate_struct_type |
| 691 | VkMemoryAllocateInfo alloc_info = {}; |
| 692 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 693 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 694 | m_errorMonitor->VerifyFound(); |
| 695 | |
| 696 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 697 | "parameter pSubmits[0].sType must be"); |
| 698 | // Zero struct memory, effectively setting sType to |
| 699 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 700 | // Expected to trigger an error with |
| 701 | // parameter_validation::validate_struct_type_array |
| 702 | VkSubmitInfo submit_info = {}; |
| 703 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 704 | m_errorMonitor->VerifyFound(); |
| 705 | } |
| 706 | |
| 707 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 708 | TEST_DESCRIPTION( |
| 709 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 710 | |
| 711 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 712 | |
| 713 | m_errorMonitor->SetDesiredFailureMsg( |
| 714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 715 | "value of pAllocateInfo->pNext must be NULL"); |
| 716 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 717 | // NULL |
| 718 | // Expected to trigger an error with |
| 719 | // parameter_validation::validate_struct_pnext |
| 720 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 721 | // Zero-initialization will provide the correct sType |
| 722 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 723 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 724 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 725 | memory_alloc_info.pNext = &app_info; |
| 726 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 727 | m_errorMonitor->VerifyFound(); |
| 728 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 729 | m_errorMonitor->SetDesiredFailureMsg( |
| 730 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 731 | " chain includes a structure with unexpected VkStructureType "); |
| 732 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 733 | // Expected to trigger an error with |
| 734 | // parameter_validation::validate_struct_pnext |
| 735 | VkDescriptorPoolSize ds_type_count = {}; |
| 736 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 737 | ds_type_count.descriptorCount = 1; |
| 738 | |
| 739 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 740 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 741 | ds_pool_ci.pNext = NULL; |
| 742 | ds_pool_ci.maxSets = 1; |
| 743 | ds_pool_ci.poolSizeCount = 1; |
| 744 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 745 | |
| 746 | VkDescriptorPool ds_pool; |
| 747 | VkResult err = |
| 748 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 749 | ASSERT_VK_SUCCESS(err); |
| 750 | |
| 751 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 752 | dsl_binding.binding = 0; |
| 753 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 754 | dsl_binding.descriptorCount = 1; |
| 755 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 756 | dsl_binding.pImmutableSamplers = NULL; |
| 757 | |
| 758 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 759 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 760 | ds_layout_ci.pNext = NULL; |
| 761 | ds_layout_ci.bindingCount = 1; |
| 762 | ds_layout_ci.pBindings = &dsl_binding; |
| 763 | |
| 764 | VkDescriptorSetLayout ds_layout; |
| 765 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 766 | &ds_layout); |
| 767 | ASSERT_VK_SUCCESS(err); |
| 768 | |
| 769 | VkDescriptorSet descriptorSet; |
| 770 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 771 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 772 | ds_alloc_info.descriptorSetCount = 1; |
| 773 | ds_alloc_info.descriptorPool = ds_pool; |
| 774 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 775 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 776 | &descriptorSet); |
| 777 | ASSERT_VK_SUCCESS(err); |
| 778 | |
| 779 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 780 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 781 | pipeline_layout_ci.setLayoutCount = 1; |
| 782 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 783 | |
| 784 | VkPipelineLayout pipeline_layout; |
| 785 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 786 | &pipeline_layout); |
| 787 | ASSERT_VK_SUCCESS(err); |
| 788 | |
| 789 | VkViewport vp = {}; // Just need dummy vp to point to |
| 790 | VkRect2D sc = {}; // dummy scissor to point to |
| 791 | |
| 792 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 793 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 794 | vp_state_ci.scissorCount = 1; |
| 795 | vp_state_ci.pScissors = ≻ |
| 796 | vp_state_ci.viewportCount = 1; |
| 797 | vp_state_ci.pViewports = &vp; |
| 798 | |
| 799 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 800 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 801 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 802 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 803 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 804 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 805 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 806 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 807 | |
| 808 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 809 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 810 | gp_ci.pViewportState = &vp_state_ci; |
| 811 | gp_ci.pRasterizationState = &rs_state_ci; |
| 812 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 813 | gp_ci.layout = pipeline_layout; |
| 814 | gp_ci.renderPass = renderPass(); |
| 815 | |
| 816 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 817 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 818 | pc_ci.initialDataSize = 0; |
| 819 | pc_ci.pInitialData = 0; |
| 820 | |
| 821 | VkPipeline pipeline; |
| 822 | VkPipelineCache pipelineCache; |
| 823 | |
| 824 | err = |
| 825 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 826 | ASSERT_VK_SUCCESS(err); |
| 827 | |
| 828 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 829 | VkApplicationInfo invalid_pnext_struct = {}; |
| 830 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 831 | |
| 832 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 833 | &gp_ci, NULL, &pipeline); |
| 834 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 835 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 836 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 837 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 838 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 839 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 840 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 841 | |
| 842 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 843 | TEST_DESCRIPTION( |
| 844 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 845 | |
| 846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 847 | |
| 848 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 849 | "does not fall within the begin..end " |
| 850 | "range of the core VkFormat " |
| 851 | "enumeration tokens"); |
| 852 | // Specify an invalid VkFormat value |
| 853 | // Expected to trigger an error with |
| 854 | // parameter_validation::validate_ranged_enum |
| 855 | VkFormatProperties format_properties; |
| 856 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 857 | &format_properties); |
| 858 | m_errorMonitor->VerifyFound(); |
| 859 | |
| 860 | m_errorMonitor->SetDesiredFailureMsg( |
| 861 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 862 | "contains flag bits that are not recognized members of"); |
| 863 | // Specify an invalid VkFlags bitmask value |
| 864 | // Expected to trigger an error with parameter_validation::validate_flags |
| 865 | VkImageFormatProperties image_format_properties; |
| 866 | vkGetPhysicalDeviceImageFormatProperties( |
| 867 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 868 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 869 | &image_format_properties); |
| 870 | m_errorMonitor->VerifyFound(); |
| 871 | |
| 872 | m_errorMonitor->SetDesiredFailureMsg( |
| 873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 874 | "contains flag bits that are not recognized members of"); |
| 875 | // Specify an invalid VkFlags array entry |
| 876 | // Expected to trigger an error with |
| 877 | // parameter_validation::validate_flags_array |
| 878 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 879 | VkPipelineStageFlags stage_flags = |
| 880 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 881 | VkSubmitInfo submit_info = {}; |
| 882 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 883 | submit_info.waitSemaphoreCount = 1; |
| 884 | submit_info.pWaitSemaphores = &semaphore; |
| 885 | submit_info.pWaitDstStageMask = &stage_flags; |
| 886 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 887 | m_errorMonitor->VerifyFound(); |
| 888 | |
| 889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 890 | "is neither VK_TRUE nor VK_FALSE"); |
| 891 | // Specify an invalid VkBool32 value |
| 892 | // Expected to trigger a warning with |
| 893 | // parameter_validation::validate_bool32 |
| 894 | VkSampler sampler = VK_NULL_HANDLE; |
| 895 | VkSamplerCreateInfo sampler_info = {}; |
| 896 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 897 | sampler_info.pNext = NULL; |
| 898 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 899 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 900 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 901 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 902 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 903 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 904 | sampler_info.mipLodBias = 1.0; |
| 905 | sampler_info.maxAnisotropy = 1; |
| 906 | sampler_info.compareEnable = VK_FALSE; |
| 907 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 908 | sampler_info.minLod = 1.0; |
| 909 | sampler_info.maxLod = 1.0; |
| 910 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 911 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 912 | // Not VK_TRUE or VK_FALSE |
| 913 | sampler_info.anisotropyEnable = 3; |
| 914 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 915 | m_errorMonitor->VerifyFound(); |
| 916 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 917 | |
| 918 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 919 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 920 | |
| 921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 922 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 923 | // Find an unsupported image format |
| 924 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 925 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 926 | VkFormat format = static_cast<VkFormat>(f); |
| 927 | VkFormatProperties fProps = m_device->format_properties(format); |
| 928 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 929 | fProps.optimalTilingFeatures == 0) { |
| 930 | unsupported = format; |
| 931 | break; |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 936 | m_errorMonitor->SetDesiredFailureMsg( |
| 937 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 938 | "the requested format is not supported on this device"); |
| 939 | // Specify an unsupported VkFormat value to generate a |
| 940 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 941 | // Expected to trigger a warning from |
| 942 | // parameter_validation::validate_result |
| 943 | VkImageFormatProperties image_format_properties; |
| 944 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 945 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 946 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 947 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 948 | m_errorMonitor->VerifyFound(); |
| 949 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 950 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 951 | |
| 952 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 953 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); |
| 954 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 955 | |
| 956 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 957 | |
| 958 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 959 | vk_testing::Buffer buffer; |
| 960 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 961 | |
| 962 | BeginCommandBuffer(); |
| 963 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 965 | " is not a multiple of 4"); |
| 966 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
| 967 | m_errorMonitor->VerifyFound(); |
| 968 | |
| 969 | // Introduce failure by using dataSize that is not multiple of 4 |
| 970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 971 | " is not a multiple of 4"); |
| 972 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
| 973 | m_errorMonitor->VerifyFound(); |
| 974 | |
| 975 | // Introduce failure by using dataSize that is < 0 |
| 976 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 977 | "must be greater than zero and less than or equal to 65536"); |
| 978 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); |
| 979 | m_errorMonitor->VerifyFound(); |
| 980 | |
| 981 | // Introduce failure by using dataSize that is > 65536 |
| 982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 983 | "must be greater than zero and less than or equal to 65536"); |
| 984 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); |
| 985 | m_errorMonitor->VerifyFound(); |
| 986 | |
| 987 | EndCommandBuffer(); |
| 988 | } |
| 989 | |
| 990 | TEST_F(VkLayerTest, FillBufferAlignment) { |
| 991 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); |
| 992 | |
| 993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 994 | |
| 995 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 996 | vk_testing::Buffer buffer; |
| 997 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 998 | |
| 999 | BeginCommandBuffer(); |
| 1000 | |
| 1001 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 1002 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1003 | " is not a multiple of 4"); |
| 1004 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
| 1005 | m_errorMonitor->VerifyFound(); |
| 1006 | |
| 1007 | // Introduce failure by using size that is not multiple of 4 |
| 1008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1009 | " is not a multiple of 4"); |
| 1010 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
| 1011 | m_errorMonitor->VerifyFound(); |
| 1012 | |
| 1013 | // Introduce failure by using size that is zero |
| 1014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1015 | "must be greater than zero"); |
| 1016 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); |
| 1017 | m_errorMonitor->VerifyFound(); |
| 1018 | |
| 1019 | EndCommandBuffer(); |
| 1020 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1021 | #endif // PARAMETER_VALIDATION_TESTS |
| 1022 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1023 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1024 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1025 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1026 | { |
| 1027 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1028 | VkFenceCreateInfo fenceInfo = {}; |
| 1029 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1030 | fenceInfo.pNext = NULL; |
| 1031 | fenceInfo.flags = 0; |
| 1032 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1033 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1034 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1036 | |
| 1037 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1038 | vk_testing::Buffer buffer; |
| 1039 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1040 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1041 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1042 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1043 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1044 | |
| 1045 | testFence.init(*m_device, fenceInfo); |
| 1046 | |
| 1047 | // Bypass framework since it does the waits automatically |
| 1048 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1049 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1050 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1051 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1052 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1053 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1054 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1055 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1057 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1058 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1059 | |
| 1060 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1061 | ASSERT_VK_SUCCESS( err ); |
| 1062 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1063 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1064 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1066 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1067 | } |
| 1068 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1069 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1070 | { |
| 1071 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1072 | VkFenceCreateInfo fenceInfo = {}; |
| 1073 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1074 | fenceInfo.pNext = NULL; |
| 1075 | fenceInfo.flags = 0; |
| 1076 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1077 | 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] | 1078 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1080 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1082 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1083 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1084 | 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] | 1085 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1086 | |
| 1087 | testFence.init(*m_device, fenceInfo); |
| 1088 | |
| 1089 | // Bypass framework since it does the waits automatically |
| 1090 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1091 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1092 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1093 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1094 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1095 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1096 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1097 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1098 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1099 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1100 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1101 | |
| 1102 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1103 | ASSERT_VK_SUCCESS( err ); |
| 1104 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1105 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1106 | VkCommandBufferBeginInfo info = {}; |
| 1107 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1108 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1109 | info.renderPass = VK_NULL_HANDLE; |
| 1110 | info.subpass = 0; |
| 1111 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1112 | info.occlusionQueryEnable = VK_FALSE; |
| 1113 | info.queryFlags = 0; |
| 1114 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1115 | |
| 1116 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1117 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1119 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1120 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1121 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1122 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1123 | // This is a positive test. No failures are expected. |
| 1124 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1125 | VkResult err; |
| 1126 | bool pass; |
| 1127 | |
| 1128 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1129 | "the buffer, create an image, and bind the same memory to " |
| 1130 | "it"); |
| 1131 | |
| 1132 | m_errorMonitor->ExpectSuccess(); |
| 1133 | |
| 1134 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1135 | |
| 1136 | VkBuffer buffer; |
| 1137 | VkImage image; |
| 1138 | VkDeviceMemory mem; |
| 1139 | VkMemoryRequirements mem_reqs; |
| 1140 | |
| 1141 | VkBufferCreateInfo buf_info = {}; |
| 1142 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1143 | buf_info.pNext = NULL; |
| 1144 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1145 | buf_info.size = 256; |
| 1146 | buf_info.queueFamilyIndexCount = 0; |
| 1147 | buf_info.pQueueFamilyIndices = NULL; |
| 1148 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1149 | buf_info.flags = 0; |
| 1150 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1151 | ASSERT_VK_SUCCESS(err); |
| 1152 | |
| 1153 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1154 | |
| 1155 | VkMemoryAllocateInfo alloc_info = {}; |
| 1156 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1157 | alloc_info.pNext = NULL; |
| 1158 | alloc_info.memoryTypeIndex = 0; |
| 1159 | |
| 1160 | // Ensure memory is big enough for both bindings |
| 1161 | alloc_info.allocationSize = 0x10000; |
| 1162 | |
| 1163 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1164 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1165 | if (!pass) { |
| 1166 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1167 | return; |
| 1168 | } |
| 1169 | |
| 1170 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1171 | ASSERT_VK_SUCCESS(err); |
| 1172 | |
| 1173 | uint8_t *pData; |
| 1174 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1175 | (void **)&pData); |
| 1176 | ASSERT_VK_SUCCESS(err); |
| 1177 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1178 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1179 | |
| 1180 | vkUnmapMemory(m_device->device(), mem); |
| 1181 | |
| 1182 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1183 | ASSERT_VK_SUCCESS(err); |
| 1184 | |
| 1185 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1186 | // memory. In fact, it was never used by the GPU. |
| 1187 | // Just be be sure, wait for idle. |
| 1188 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1189 | vkDeviceWaitIdle(m_device->device()); |
| 1190 | |
| 1191 | VkImageCreateInfo image_create_info = {}; |
| 1192 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1193 | image_create_info.pNext = NULL; |
| 1194 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1195 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1196 | image_create_info.extent.width = 64; |
| 1197 | image_create_info.extent.height = 64; |
| 1198 | image_create_info.extent.depth = 1; |
| 1199 | image_create_info.mipLevels = 1; |
| 1200 | image_create_info.arrayLayers = 1; |
| 1201 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1202 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1203 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1204 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1205 | image_create_info.queueFamilyIndexCount = 0; |
| 1206 | image_create_info.pQueueFamilyIndices = NULL; |
| 1207 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1208 | image_create_info.flags = 0; |
| 1209 | |
| 1210 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1211 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1212 | mem_alloc.pNext = NULL; |
| 1213 | mem_alloc.allocationSize = 0; |
| 1214 | mem_alloc.memoryTypeIndex = 0; |
| 1215 | |
| 1216 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1217 | * to be textures or it will be the staging image if they are not. |
| 1218 | */ |
| 1219 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1220 | ASSERT_VK_SUCCESS(err); |
| 1221 | |
| 1222 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1223 | |
| 1224 | mem_alloc.allocationSize = mem_reqs.size; |
| 1225 | |
| 1226 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1227 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1228 | if (!pass) { |
| 1229 | vkDestroyImage(m_device->device(), image, NULL); |
| 1230 | return; |
| 1231 | } |
| 1232 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1233 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1234 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1235 | ASSERT_VK_SUCCESS(err); |
| 1236 | |
| 1237 | m_errorMonitor->VerifyNotFound(); |
| 1238 | |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1239 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1240 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1241 | vkDestroyImage(m_device->device(), image, NULL); |
| 1242 | } |
| 1243 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1244 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1245 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1246 | "buffer and image to memory such that they will alias."); |
| 1247 | VkResult err; |
| 1248 | bool pass; |
| 1249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1250 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1251 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1252 | VkImage image; |
| 1253 | VkDeviceMemory mem; // buffer will be bound first |
| 1254 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1255 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1256 | |
| 1257 | VkBufferCreateInfo buf_info = {}; |
| 1258 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1259 | buf_info.pNext = NULL; |
| 1260 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1261 | buf_info.size = 256; |
| 1262 | buf_info.queueFamilyIndexCount = 0; |
| 1263 | buf_info.pQueueFamilyIndices = NULL; |
| 1264 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1265 | buf_info.flags = 0; |
| 1266 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1267 | ASSERT_VK_SUCCESS(err); |
| 1268 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1269 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1270 | |
| 1271 | VkImageCreateInfo image_create_info = {}; |
| 1272 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1273 | image_create_info.pNext = NULL; |
| 1274 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1275 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1276 | image_create_info.extent.width = 64; |
| 1277 | image_create_info.extent.height = 64; |
| 1278 | image_create_info.extent.depth = 1; |
| 1279 | image_create_info.mipLevels = 1; |
| 1280 | image_create_info.arrayLayers = 1; |
| 1281 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1282 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1283 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1284 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1285 | image_create_info.queueFamilyIndexCount = 0; |
| 1286 | image_create_info.pQueueFamilyIndices = NULL; |
| 1287 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1288 | image_create_info.flags = 0; |
| 1289 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1290 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1291 | ASSERT_VK_SUCCESS(err); |
| 1292 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1293 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1294 | |
| 1295 | VkMemoryAllocateInfo alloc_info = {}; |
| 1296 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1297 | alloc_info.pNext = NULL; |
| 1298 | alloc_info.memoryTypeIndex = 0; |
| 1299 | // Ensure memory is big enough for both bindings |
| 1300 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1301 | pass = m_device->phy().set_memory_type( |
| 1302 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1303 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1304 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1305 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1306 | vkDestroyImage(m_device->device(), image, NULL); |
| 1307 | return; |
| 1308 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1309 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1310 | ASSERT_VK_SUCCESS(err); |
| 1311 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1312 | ASSERT_VK_SUCCESS(err); |
| 1313 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1314 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1315 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1316 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1317 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1318 | m_errorMonitor->VerifyFound(); |
| 1319 | |
| 1320 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1321 | // aliasing buffer2 |
| 1322 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1323 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1324 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1325 | ASSERT_VK_SUCCESS(err); |
| 1326 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1327 | ASSERT_VK_SUCCESS(err); |
| 1328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1329 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1330 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1331 | m_errorMonitor->VerifyFound(); |
| 1332 | |
| 1333 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1334 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1335 | vkDestroyImage(m_device->device(), image, NULL); |
| 1336 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1337 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1338 | } |
| 1339 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1340 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1341 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1342 | VkResult err; |
| 1343 | bool pass; |
| 1344 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1345 | |
| 1346 | VkBuffer buffer; |
| 1347 | VkDeviceMemory mem; |
| 1348 | VkMemoryRequirements mem_reqs; |
| 1349 | |
| 1350 | VkBufferCreateInfo buf_info = {}; |
| 1351 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1352 | buf_info.pNext = NULL; |
| 1353 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1354 | buf_info.size = 256; |
| 1355 | buf_info.queueFamilyIndexCount = 0; |
| 1356 | buf_info.pQueueFamilyIndices = NULL; |
| 1357 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1358 | buf_info.flags = 0; |
| 1359 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1360 | ASSERT_VK_SUCCESS(err); |
| 1361 | |
| 1362 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1363 | VkMemoryAllocateInfo alloc_info = {}; |
| 1364 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1365 | alloc_info.pNext = NULL; |
| 1366 | alloc_info.memoryTypeIndex = 0; |
| 1367 | |
| 1368 | // Ensure memory is big enough for both bindings |
| 1369 | static const VkDeviceSize allocation_size = 0x10000; |
| 1370 | alloc_info.allocationSize = allocation_size; |
| 1371 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1372 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1373 | if (!pass) { |
| 1374 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1375 | return; |
| 1376 | } |
| 1377 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1378 | ASSERT_VK_SUCCESS(err); |
| 1379 | |
| 1380 | uint8_t *pData; |
| 1381 | // Attempt to map memory size 0 is invalid |
| 1382 | m_errorMonitor->SetDesiredFailureMsg( |
| 1383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1384 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1385 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1386 | m_errorMonitor->VerifyFound(); |
| 1387 | // Map memory twice |
| 1388 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1389 | (void **)&pData); |
| 1390 | ASSERT_VK_SUCCESS(err); |
| 1391 | m_errorMonitor->SetDesiredFailureMsg( |
| 1392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1393 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1394 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1395 | (void **)&pData); |
| 1396 | m_errorMonitor->VerifyFound(); |
| 1397 | |
| 1398 | // Unmap the memory to avoid re-map error |
| 1399 | vkUnmapMemory(m_device->device(), mem); |
| 1400 | // overstep allocation with VK_WHOLE_SIZE |
| 1401 | m_errorMonitor->SetDesiredFailureMsg( |
| 1402 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1403 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1404 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1405 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1406 | m_errorMonitor->VerifyFound(); |
| 1407 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1408 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1409 | " oversteps total array size 0x"); |
| 1410 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1411 | (void **)&pData); |
| 1412 | m_errorMonitor->VerifyFound(); |
| 1413 | // Now error due to unmapping memory that's not mapped |
| 1414 | m_errorMonitor->SetDesiredFailureMsg( |
| 1415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1416 | "Unmapping Memory without memory being mapped: "); |
| 1417 | vkUnmapMemory(m_device->device(), mem); |
| 1418 | m_errorMonitor->VerifyFound(); |
| 1419 | // Now map memory and cause errors due to flushing invalid ranges |
| 1420 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1421 | (void **)&pData); |
| 1422 | ASSERT_VK_SUCCESS(err); |
| 1423 | VkMappedMemoryRange mmr = {}; |
Chris Forbes | 3aec089 | 2016-06-13 10:29:26 +1200 | [diff] [blame] | 1424 | mmr.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1425 | mmr.memory = mem; |
| 1426 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1427 | m_errorMonitor->SetDesiredFailureMsg( |
| 1428 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1429 | ") is less than Memory Object's offset ("); |
| 1430 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1431 | m_errorMonitor->VerifyFound(); |
| 1432 | // Now flush range that oversteps mapped range |
| 1433 | vkUnmapMemory(m_device->device(), mem); |
| 1434 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1435 | ASSERT_VK_SUCCESS(err); |
| 1436 | mmr.offset = 16; |
| 1437 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1438 | m_errorMonitor->SetDesiredFailureMsg( |
| 1439 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1440 | ") exceeds the Memory Object's upper-bound ("); |
| 1441 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1442 | m_errorMonitor->VerifyFound(); |
| 1443 | |
| 1444 | pass = |
| 1445 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1446 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1447 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1448 | if (!pass) { |
| 1449 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1450 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1451 | return; |
| 1452 | } |
| 1453 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1454 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1455 | |
| 1456 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1457 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1458 | } |
| 1459 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1460 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1461 | VkResult err; |
| 1462 | bool pass; |
| 1463 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1464 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1465 | // following declaration (which is temporarily being moved below): |
| 1466 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1467 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1468 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1469 | uint32_t swapchain_image_count = 0; |
| 1470 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1471 | uint32_t image_index = 0; |
| 1472 | // VkPresentInfoKHR present_info = {}; |
| 1473 | |
| 1474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1475 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1476 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1477 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1478 | // Use the functions from the VK_KHR_android_surface extension without |
| 1479 | // enabling that extension: |
| 1480 | |
| 1481 | // Create a surface: |
| 1482 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1483 | m_errorMonitor->SetDesiredFailureMsg( |
| 1484 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1485 | "extension was not enabled for this"); |
| 1486 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1487 | &surface); |
| 1488 | pass = (err != VK_SUCCESS); |
| 1489 | ASSERT_TRUE(pass); |
| 1490 | m_errorMonitor->VerifyFound(); |
| 1491 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1492 | |
| 1493 | |
| 1494 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1495 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1496 | // that extension: |
| 1497 | |
| 1498 | // Create a surface: |
| 1499 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1500 | m_errorMonitor->SetDesiredFailureMsg( |
| 1501 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1502 | "extension was not enabled for this"); |
| 1503 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1504 | pass = (err != VK_SUCCESS); |
| 1505 | ASSERT_TRUE(pass); |
| 1506 | m_errorMonitor->VerifyFound(); |
| 1507 | |
| 1508 | // Tell whether an mir_connection supports presentation: |
| 1509 | MirConnection *mir_connection = NULL; |
| 1510 | m_errorMonitor->SetDesiredFailureMsg( |
| 1511 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1512 | "extension was not enabled for this"); |
| 1513 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1514 | visual_id); |
| 1515 | m_errorMonitor->VerifyFound(); |
| 1516 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1517 | |
| 1518 | |
| 1519 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1520 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1521 | // enabling that extension: |
| 1522 | |
| 1523 | // Create a surface: |
| 1524 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1525 | m_errorMonitor->SetDesiredFailureMsg( |
| 1526 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1527 | "extension was not enabled for this"); |
| 1528 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1529 | &surface); |
| 1530 | pass = (err != VK_SUCCESS); |
| 1531 | ASSERT_TRUE(pass); |
| 1532 | m_errorMonitor->VerifyFound(); |
| 1533 | |
| 1534 | // Tell whether an wayland_display supports presentation: |
| 1535 | struct wl_display wayland_display = {}; |
| 1536 | m_errorMonitor->SetDesiredFailureMsg( |
| 1537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1538 | "extension was not enabled for this"); |
| 1539 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1540 | &wayland_display); |
| 1541 | m_errorMonitor->VerifyFound(); |
| 1542 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1543 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1544 | |
| 1545 | |
| 1546 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1547 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1548 | // TO NON-LINUX PLATFORMS: |
| 1549 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1550 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1551 | // enabling that extension: |
| 1552 | |
| 1553 | // Create a surface: |
| 1554 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1555 | m_errorMonitor->SetDesiredFailureMsg( |
| 1556 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1557 | "extension was not enabled for this"); |
| 1558 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1559 | &surface); |
| 1560 | pass = (err != VK_SUCCESS); |
| 1561 | ASSERT_TRUE(pass); |
| 1562 | m_errorMonitor->VerifyFound(); |
| 1563 | |
| 1564 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1565 | m_errorMonitor->SetDesiredFailureMsg( |
| 1566 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1567 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1568 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1569 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1570 | // Set this (for now, until all platforms are supported and tested): |
| 1571 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1572 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1573 | |
| 1574 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1575 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1576 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1577 | // TO NON-LINUX PLATFORMS: |
| 1578 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1579 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1580 | // that extension: |
| 1581 | |
| 1582 | // Create a surface: |
| 1583 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1584 | m_errorMonitor->SetDesiredFailureMsg( |
| 1585 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1586 | "extension was not enabled for this"); |
| 1587 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1588 | pass = (err != VK_SUCCESS); |
| 1589 | ASSERT_TRUE(pass); |
| 1590 | m_errorMonitor->VerifyFound(); |
| 1591 | |
| 1592 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1593 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1594 | xcb_visualid_t visual_id = 0; |
| 1595 | m_errorMonitor->SetDesiredFailureMsg( |
| 1596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1597 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1598 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1599 | visual_id); |
| 1600 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1601 | // Set this (for now, until all platforms are supported and tested): |
| 1602 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1603 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1604 | |
| 1605 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1606 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1607 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1608 | // that extension: |
| 1609 | |
| 1610 | // Create a surface: |
| 1611 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1612 | m_errorMonitor->SetDesiredFailureMsg( |
| 1613 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1614 | "extension was not enabled for this"); |
| 1615 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1616 | pass = (err != VK_SUCCESS); |
| 1617 | ASSERT_TRUE(pass); |
| 1618 | m_errorMonitor->VerifyFound(); |
| 1619 | |
| 1620 | // Tell whether an Xlib VisualID supports presentation: |
| 1621 | Display *dpy = NULL; |
| 1622 | VisualID visual = 0; |
| 1623 | m_errorMonitor->SetDesiredFailureMsg( |
| 1624 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1625 | "extension was not enabled for this"); |
| 1626 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1627 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1628 | // Set this (for now, until all platforms are supported and tested): |
| 1629 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1630 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1631 | |
| 1632 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1633 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1634 | // that extension: |
| 1635 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1636 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1637 | // Destroy a surface: |
| 1638 | m_errorMonitor->SetDesiredFailureMsg( |
| 1639 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1640 | "extension was not enabled for this"); |
| 1641 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1642 | m_errorMonitor->VerifyFound(); |
| 1643 | |
| 1644 | // Check if surface supports presentation: |
| 1645 | VkBool32 supported = false; |
| 1646 | m_errorMonitor->SetDesiredFailureMsg( |
| 1647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1648 | "extension was not enabled for this"); |
| 1649 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1650 | pass = (err != VK_SUCCESS); |
| 1651 | ASSERT_TRUE(pass); |
| 1652 | m_errorMonitor->VerifyFound(); |
| 1653 | |
| 1654 | // Check surface capabilities: |
| 1655 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1656 | m_errorMonitor->SetDesiredFailureMsg( |
| 1657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1658 | "extension was not enabled for this"); |
| 1659 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1660 | &capabilities); |
| 1661 | pass = (err != VK_SUCCESS); |
| 1662 | ASSERT_TRUE(pass); |
| 1663 | m_errorMonitor->VerifyFound(); |
| 1664 | |
| 1665 | // Check surface formats: |
| 1666 | uint32_t format_count = 0; |
| 1667 | VkSurfaceFormatKHR *formats = NULL; |
| 1668 | m_errorMonitor->SetDesiredFailureMsg( |
| 1669 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1670 | "extension was not enabled for this"); |
| 1671 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1672 | &format_count, formats); |
| 1673 | pass = (err != VK_SUCCESS); |
| 1674 | ASSERT_TRUE(pass); |
| 1675 | m_errorMonitor->VerifyFound(); |
| 1676 | |
| 1677 | // Check surface present modes: |
| 1678 | uint32_t present_mode_count = 0; |
| 1679 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1680 | m_errorMonitor->SetDesiredFailureMsg( |
| 1681 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1682 | "extension was not enabled for this"); |
| 1683 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1684 | &present_mode_count, present_modes); |
| 1685 | pass = (err != VK_SUCCESS); |
| 1686 | ASSERT_TRUE(pass); |
| 1687 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1688 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1689 | |
| 1690 | |
| 1691 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1692 | // that extension: |
| 1693 | |
| 1694 | // Create a swapchain: |
| 1695 | m_errorMonitor->SetDesiredFailureMsg( |
| 1696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1697 | "extension was not enabled for this"); |
| 1698 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1699 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1700 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1701 | NULL, &swapchain); |
| 1702 | pass = (err != VK_SUCCESS); |
| 1703 | ASSERT_TRUE(pass); |
| 1704 | m_errorMonitor->VerifyFound(); |
| 1705 | |
| 1706 | // Get the images from the swapchain: |
| 1707 | m_errorMonitor->SetDesiredFailureMsg( |
| 1708 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1709 | "extension was not enabled for this"); |
| 1710 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1711 | &swapchain_image_count, NULL); |
| 1712 | pass = (err != VK_SUCCESS); |
| 1713 | ASSERT_TRUE(pass); |
| 1714 | m_errorMonitor->VerifyFound(); |
| 1715 | |
| 1716 | // Try to acquire an image: |
| 1717 | m_errorMonitor->SetDesiredFailureMsg( |
| 1718 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1719 | "extension was not enabled for this"); |
| 1720 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1721 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1722 | pass = (err != VK_SUCCESS); |
| 1723 | ASSERT_TRUE(pass); |
| 1724 | m_errorMonitor->VerifyFound(); |
| 1725 | |
| 1726 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1727 | // |
| 1728 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1729 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1730 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1731 | |
| 1732 | // Destroy the swapchain: |
| 1733 | m_errorMonitor->SetDesiredFailureMsg( |
| 1734 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1735 | "extension was not enabled for this"); |
| 1736 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1737 | m_errorMonitor->VerifyFound(); |
| 1738 | } |
| 1739 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1740 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1741 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1742 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1743 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1744 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1745 | VkResult err; |
| 1746 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1747 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1748 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1749 | // uint32_t swapchain_image_count = 0; |
| 1750 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1751 | // uint32_t image_index = 0; |
| 1752 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1753 | |
| 1754 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1755 | |
| 1756 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1757 | // order to create a surface, testing all known errors in the process, |
| 1758 | // before successfully creating a surface: |
| 1759 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1760 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1761 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1762 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1763 | pass = (err != VK_SUCCESS); |
| 1764 | ASSERT_TRUE(pass); |
| 1765 | m_errorMonitor->VerifyFound(); |
| 1766 | |
| 1767 | // Next, try to create a surface with the wrong |
| 1768 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1769 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1770 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1771 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1772 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1773 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1774 | pass = (err != VK_SUCCESS); |
| 1775 | ASSERT_TRUE(pass); |
| 1776 | m_errorMonitor->VerifyFound(); |
| 1777 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1778 | // Create a native window, and then correctly create a surface: |
| 1779 | xcb_connection_t *connection; |
| 1780 | xcb_screen_t *screen; |
| 1781 | xcb_window_t xcb_window; |
| 1782 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1783 | |
| 1784 | const xcb_setup_t *setup; |
| 1785 | xcb_screen_iterator_t iter; |
| 1786 | int scr; |
| 1787 | uint32_t value_mask, value_list[32]; |
| 1788 | int width = 1; |
| 1789 | int height = 1; |
| 1790 | |
| 1791 | connection = xcb_connect(NULL, &scr); |
| 1792 | ASSERT_TRUE(connection != NULL); |
| 1793 | setup = xcb_get_setup(connection); |
| 1794 | iter = xcb_setup_roots_iterator(setup); |
| 1795 | while (scr-- > 0) |
| 1796 | xcb_screen_next(&iter); |
| 1797 | screen = iter.data; |
| 1798 | |
| 1799 | xcb_window = xcb_generate_id(connection); |
| 1800 | |
| 1801 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1802 | value_list[0] = screen->black_pixel; |
| 1803 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1804 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1805 | |
| 1806 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1807 | screen->root, 0, 0, width, height, 0, |
| 1808 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1809 | value_mask, value_list); |
| 1810 | |
| 1811 | /* Magic code that will send notification when window is destroyed */ |
| 1812 | xcb_intern_atom_cookie_t cookie = |
| 1813 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1814 | xcb_intern_atom_reply_t *reply = |
| 1815 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1816 | |
| 1817 | xcb_intern_atom_cookie_t cookie2 = |
| 1818 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1819 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1820 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1821 | (*reply).atom, 4, 32, 1, |
| 1822 | &(*atom_wm_delete_window).atom); |
| 1823 | free(reply); |
| 1824 | |
| 1825 | xcb_map_window(connection, xcb_window); |
| 1826 | |
| 1827 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1828 | // runs |
| 1829 | const uint32_t coords[] = {100, 100}; |
| 1830 | xcb_configure_window(connection, xcb_window, |
| 1831 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1832 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1833 | // Finally, try to correctly create a surface: |
| 1834 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1835 | xcb_create_info.pNext = NULL; |
| 1836 | xcb_create_info.flags = 0; |
| 1837 | xcb_create_info.connection = connection; |
| 1838 | xcb_create_info.window = xcb_window; |
| 1839 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1840 | pass = (err == VK_SUCCESS); |
| 1841 | ASSERT_TRUE(pass); |
| 1842 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1843 | // Check if surface supports presentation: |
| 1844 | |
| 1845 | // 1st, do so without having queried the queue families: |
| 1846 | VkBool32 supported = false; |
| 1847 | // TODO: Get the following error to come out: |
| 1848 | m_errorMonitor->SetDesiredFailureMsg( |
| 1849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1850 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1851 | "function"); |
| 1852 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1853 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1854 | // ASSERT_TRUE(pass); |
| 1855 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1856 | |
| 1857 | // Next, query a queue family index that's too large: |
| 1858 | m_errorMonitor->SetDesiredFailureMsg( |
| 1859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1860 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1861 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1862 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1863 | pass = (err != VK_SUCCESS); |
| 1864 | ASSERT_TRUE(pass); |
| 1865 | m_errorMonitor->VerifyFound(); |
| 1866 | |
| 1867 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1868 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1869 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1870 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1871 | pass = (err == VK_SUCCESS); |
| 1872 | ASSERT_TRUE(pass); |
| 1873 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1874 | // Before proceeding, try to create a swapchain without having called |
| 1875 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1876 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1877 | swapchain_create_info.pNext = NULL; |
| 1878 | swapchain_create_info.flags = 0; |
| 1879 | m_errorMonitor->SetDesiredFailureMsg( |
| 1880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1881 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1882 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1883 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1884 | pass = (err != VK_SUCCESS); |
| 1885 | ASSERT_TRUE(pass); |
| 1886 | m_errorMonitor->VerifyFound(); |
| 1887 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1888 | // Get the surface capabilities: |
| 1889 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1890 | |
| 1891 | // Do so correctly (only error logged by this entrypoint is if the |
| 1892 | // extension isn't enabled): |
| 1893 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1894 | &surface_capabilities); |
| 1895 | pass = (err == VK_SUCCESS); |
| 1896 | ASSERT_TRUE(pass); |
| 1897 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1898 | // Get the surface formats: |
| 1899 | uint32_t surface_format_count; |
| 1900 | |
| 1901 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1902 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1903 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1904 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1905 | pass = (err == VK_SUCCESS); |
| 1906 | ASSERT_TRUE(pass); |
| 1907 | m_errorMonitor->VerifyFound(); |
| 1908 | |
| 1909 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1910 | // correctly done a 1st try (to get the count): |
| 1911 | m_errorMonitor->SetDesiredFailureMsg( |
| 1912 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1913 | "but no prior positive value has been seen for"); |
| 1914 | surface_format_count = 0; |
| 1915 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1916 | gpu(), surface, &surface_format_count, |
| 1917 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1918 | pass = (err == VK_SUCCESS); |
| 1919 | ASSERT_TRUE(pass); |
| 1920 | m_errorMonitor->VerifyFound(); |
| 1921 | |
| 1922 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1923 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1924 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1925 | pass = (err == VK_SUCCESS); |
| 1926 | ASSERT_TRUE(pass); |
| 1927 | |
| 1928 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1929 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1930 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1931 | |
| 1932 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1933 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1934 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1935 | "that is greater than the value"); |
| 1936 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1937 | surface_formats); |
| 1938 | pass = (err == VK_SUCCESS); |
| 1939 | ASSERT_TRUE(pass); |
| 1940 | m_errorMonitor->VerifyFound(); |
| 1941 | |
| 1942 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1943 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1944 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1945 | pass = (err == VK_SUCCESS); |
| 1946 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1947 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1948 | surface_formats); |
| 1949 | pass = (err == VK_SUCCESS); |
| 1950 | ASSERT_TRUE(pass); |
| 1951 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1952 | // Get the surface present modes: |
| 1953 | uint32_t surface_present_mode_count; |
| 1954 | |
| 1955 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1956 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1957 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1958 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1959 | pass = (err == VK_SUCCESS); |
| 1960 | ASSERT_TRUE(pass); |
| 1961 | m_errorMonitor->VerifyFound(); |
| 1962 | |
| 1963 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1964 | // correctly done a 1st try (to get the count): |
| 1965 | m_errorMonitor->SetDesiredFailureMsg( |
| 1966 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1967 | "but no prior positive value has been seen for"); |
| 1968 | surface_present_mode_count = 0; |
| 1969 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1970 | gpu(), surface, &surface_present_mode_count, |
| 1971 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1972 | pass = (err == VK_SUCCESS); |
| 1973 | ASSERT_TRUE(pass); |
| 1974 | m_errorMonitor->VerifyFound(); |
| 1975 | |
| 1976 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1977 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1978 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1979 | pass = (err == VK_SUCCESS); |
| 1980 | ASSERT_TRUE(pass); |
| 1981 | |
| 1982 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1983 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1984 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1985 | |
| 1986 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1987 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1989 | "that is greater than the value"); |
| 1990 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1991 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1992 | pass = (err == VK_SUCCESS); |
| 1993 | ASSERT_TRUE(pass); |
| 1994 | m_errorMonitor->VerifyFound(); |
| 1995 | |
| 1996 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1997 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1998 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1999 | pass = (err == VK_SUCCESS); |
| 2000 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2001 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 2002 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2003 | pass = (err == VK_SUCCESS); |
| 2004 | ASSERT_TRUE(pass); |
| 2005 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2006 | // Create a swapchain: |
| 2007 | |
| 2008 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2009 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2010 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2011 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 2012 | pass = (err != VK_SUCCESS); |
| 2013 | ASSERT_TRUE(pass); |
| 2014 | m_errorMonitor->VerifyFound(); |
| 2015 | |
| 2016 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 2017 | // sType: |
| 2018 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2020 | "called with the wrong value for"); |
| 2021 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2022 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2023 | pass = (err != VK_SUCCESS); |
| 2024 | ASSERT_TRUE(pass); |
| 2025 | m_errorMonitor->VerifyFound(); |
| 2026 | |
| 2027 | // Next, call with a NULL swapchain pointer: |
| 2028 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 2029 | swapchain_create_info.pNext = NULL; |
| 2030 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2031 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2032 | "called with NULL pointer"); |
| 2033 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2034 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2035 | pass = (err != VK_SUCCESS); |
| 2036 | ASSERT_TRUE(pass); |
| 2037 | m_errorMonitor->VerifyFound(); |
| 2038 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2039 | // TODO: Enhance swapchain layer so that |
| 2040 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2041 | |
| 2042 | // Next, call with a queue family index that's too large: |
| 2043 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 2044 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2045 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 2046 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 2047 | m_errorMonitor->SetDesiredFailureMsg( |
| 2048 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2049 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2050 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2051 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2052 | pass = (err != VK_SUCCESS); |
| 2053 | ASSERT_TRUE(pass); |
| 2054 | m_errorMonitor->VerifyFound(); |
| 2055 | |
| 2056 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 2057 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2058 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2059 | m_errorMonitor->SetDesiredFailureMsg( |
| 2060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2061 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 2062 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2063 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2064 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2065 | pass = (err != VK_SUCCESS); |
| 2066 | ASSERT_TRUE(pass); |
| 2067 | m_errorMonitor->VerifyFound(); |
| 2068 | |
| 2069 | // Next, call with an invalid imageSharingMode: |
| 2070 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 2071 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2072 | m_errorMonitor->SetDesiredFailureMsg( |
| 2073 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2074 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2075 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2076 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2077 | pass = (err != VK_SUCCESS); |
| 2078 | ASSERT_TRUE(pass); |
| 2079 | m_errorMonitor->VerifyFound(); |
| 2080 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2081 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 2082 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2083 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2084 | queueFamilyIndex[0] = 0; |
| 2085 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2086 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2087 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2088 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2089 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2090 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2091 | // Destroy the swapchain: |
| 2092 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2093 | // TODOs: |
| 2094 | // |
| 2095 | // - Try destroying the device without first destroying the swapchain |
| 2096 | // |
| 2097 | // - Try destroying the device without first destroying the surface |
| 2098 | // |
| 2099 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2100 | |
| 2101 | // Destroy the surface: |
| 2102 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2103 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2104 | // Tear down the window: |
| 2105 | xcb_destroy_window(connection, xcb_window); |
| 2106 | xcb_disconnect(connection); |
| 2107 | |
| 2108 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2109 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2110 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2111 | } |
| 2112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2113 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2114 | VkResult err; |
| 2115 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2117 | m_errorMonitor->SetDesiredFailureMsg( |
| 2118 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2119 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2120 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2122 | |
| 2123 | // 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] | 2124 | VkImage image; |
| 2125 | VkDeviceMemory mem; |
| 2126 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2127 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2128 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2129 | const int32_t tex_width = 32; |
| 2130 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2131 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2132 | VkImageCreateInfo image_create_info = {}; |
| 2133 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2134 | image_create_info.pNext = NULL; |
| 2135 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2136 | image_create_info.format = tex_format; |
| 2137 | image_create_info.extent.width = tex_width; |
| 2138 | image_create_info.extent.height = tex_height; |
| 2139 | image_create_info.extent.depth = 1; |
| 2140 | image_create_info.mipLevels = 1; |
| 2141 | image_create_info.arrayLayers = 1; |
| 2142 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2143 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2144 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2145 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2146 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2147 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2148 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2149 | mem_alloc.pNext = NULL; |
| 2150 | mem_alloc.allocationSize = 0; |
| 2151 | // Introduce failure, do NOT set memProps to |
| 2152 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2153 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2154 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2155 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2156 | ASSERT_VK_SUCCESS(err); |
| 2157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2158 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2159 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2160 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2162 | pass = |
| 2163 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2164 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2165 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2166 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2167 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2168 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2169 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2170 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2171 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2172 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2173 | ASSERT_VK_SUCCESS(err); |
| 2174 | |
| 2175 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2176 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2177 | ASSERT_VK_SUCCESS(err); |
| 2178 | |
| 2179 | // Map memory as if to initialize the image |
| 2180 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2181 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2182 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2183 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2184 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2185 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2186 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2187 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2188 | } |
| 2189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2190 | TEST_F(VkLayerTest, RebindMemory) { |
| 2191 | VkResult err; |
| 2192 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2194 | m_errorMonitor->SetDesiredFailureMsg( |
| 2195 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2196 | "which has already been bound to mem object"); |
| 2197 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2198 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2199 | |
| 2200 | // 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] | 2201 | VkImage image; |
| 2202 | VkDeviceMemory mem1; |
| 2203 | VkDeviceMemory mem2; |
| 2204 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2206 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2207 | const int32_t tex_width = 32; |
| 2208 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2209 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2210 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2211 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2212 | image_create_info.pNext = NULL; |
| 2213 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2214 | image_create_info.format = tex_format; |
| 2215 | image_create_info.extent.width = tex_width; |
| 2216 | image_create_info.extent.height = tex_height; |
| 2217 | image_create_info.extent.depth = 1; |
| 2218 | image_create_info.mipLevels = 1; |
| 2219 | image_create_info.arrayLayers = 1; |
| 2220 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2221 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2222 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2223 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2224 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2225 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2226 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2227 | mem_alloc.pNext = NULL; |
| 2228 | mem_alloc.allocationSize = 0; |
| 2229 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2231 | // Introduce failure, do NOT set memProps to |
| 2232 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2233 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2234 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2235 | ASSERT_VK_SUCCESS(err); |
| 2236 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2237 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2238 | |
| 2239 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2240 | pass = |
| 2241 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2242 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2243 | |
| 2244 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2245 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2246 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2247 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2248 | ASSERT_VK_SUCCESS(err); |
| 2249 | |
| 2250 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2251 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2252 | ASSERT_VK_SUCCESS(err); |
| 2253 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2254 | // Introduce validation failure, try to bind a different memory object to |
| 2255 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2256 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2257 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2258 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2259 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2260 | vkDestroyImage(m_device->device(), image, NULL); |
| 2261 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2262 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2263 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2265 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2266 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2268 | m_errorMonitor->SetDesiredFailureMsg( |
| 2269 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2270 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2271 | |
| 2272 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2273 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2274 | fenceInfo.pNext = NULL; |
| 2275 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2276 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2277 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2278 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2279 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2280 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2281 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2282 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2283 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2284 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2285 | |
| 2286 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2287 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2288 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2289 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2290 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2291 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2292 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2293 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2294 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2295 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2296 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2297 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2298 | |
| 2299 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2300 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2301 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2302 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2303 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2304 | // This is a positive test. We used to expect error in this case but spec now |
| 2305 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2306 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2307 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2308 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2309 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2310 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2311 | fenceInfo.pNext = NULL; |
| 2312 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2313 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2314 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2315 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2316 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2317 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2318 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2319 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2320 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2321 | |
Chris Forbes | e70b7d3 | 2016-06-15 15:49:12 +1200 | [diff] [blame] | 2322 | #if 0 |
| 2323 | TEST_F(VkLayerTest, LongFenceChain) |
| 2324 | { |
| 2325 | m_errorMonitor->ExpectSuccess(); |
| 2326 | |
| 2327 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2328 | VkResult err; |
| 2329 | |
| 2330 | std::vector<VkFence> fences; |
| 2331 | |
| 2332 | const int chainLength = 32768; |
| 2333 | |
| 2334 | for (int i = 0; i < chainLength; i++) { |
| 2335 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; |
| 2336 | VkFence fence; |
| 2337 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); |
| 2338 | ASSERT_VK_SUCCESS(err); |
| 2339 | |
| 2340 | fences.push_back(fence); |
| 2341 | |
| 2342 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, |
| 2343 | 0, nullptr, 0, nullptr }; |
| 2344 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); |
| 2345 | ASSERT_VK_SUCCESS(err); |
| 2346 | |
| 2347 | } |
| 2348 | |
| 2349 | // BOOM, stack overflow. |
| 2350 | vkWaitForFences(m_device->device(), 1, &fences.back(), VK_TRUE, UINT64_MAX); |
| 2351 | |
| 2352 | for (auto fence : fences) |
| 2353 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2354 | |
| 2355 | m_errorMonitor->VerifyNotFound(); |
| 2356 | } |
| 2357 | #endif |
| 2358 | |
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 2359 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
| 2360 | { |
| 2361 | m_errorMonitor->ExpectSuccess(); |
| 2362 | |
| 2363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2364 | VkResult err; |
| 2365 | |
| 2366 | // Record (empty!) command buffer that can be submitted multiple times |
| 2367 | // simultaneously. |
| 2368 | VkCommandBufferBeginInfo cbbi = { |
| 2369 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 2370 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr |
| 2371 | }; |
| 2372 | m_commandBuffer->BeginCommandBuffer(&cbbi); |
| 2373 | m_commandBuffer->EndCommandBuffer(); |
| 2374 | |
| 2375 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; |
| 2376 | VkFence fence; |
| 2377 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); |
| 2378 | ASSERT_VK_SUCCESS(err); |
| 2379 | |
| 2380 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; |
| 2381 | VkSemaphore s1, s2; |
| 2382 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); |
| 2383 | ASSERT_VK_SUCCESS(err); |
| 2384 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); |
| 2385 | ASSERT_VK_SUCCESS(err); |
| 2386 | |
| 2387 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. |
| 2388 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, |
| 2389 | 1, &m_commandBuffer->handle(), 1, &s1 }; |
| 2390 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); |
| 2391 | ASSERT_VK_SUCCESS(err); |
| 2392 | |
| 2393 | // Submit CB again, signaling s2. |
| 2394 | si.pSignalSemaphores = &s2; |
| 2395 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); |
| 2396 | ASSERT_VK_SUCCESS(err); |
| 2397 | |
| 2398 | // Wait for fence. |
| 2399 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2400 | ASSERT_VK_SUCCESS(err); |
| 2401 | |
| 2402 | // CB is still in flight from second submission, but semaphore s1 is no |
| 2403 | // longer in flight. delete it. |
| 2404 | vkDestroySemaphore(m_device->device(), s1, nullptr); |
| 2405 | |
| 2406 | m_errorMonitor->VerifyNotFound(); |
| 2407 | |
| 2408 | // Force device idle and clean up remaining objects |
| 2409 | vkDeviceWaitIdle(m_device->device()); |
| 2410 | vkDestroySemaphore(m_device->device(), s2, nullptr); |
| 2411 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2412 | } |
| 2413 | |
Chris Forbes | 4e44c91 | 2016-06-16 10:20:00 +1200 | [diff] [blame] | 2414 | TEST_F(VkLayerTest, FenceCreateSignaledWaitHandling) |
| 2415 | { |
| 2416 | m_errorMonitor->ExpectSuccess(); |
| 2417 | |
| 2418 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2419 | VkResult err; |
| 2420 | |
| 2421 | // A fence created signaled |
| 2422 | VkFenceCreateInfo fci1 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT }; |
| 2423 | VkFence f1; |
| 2424 | err = vkCreateFence(m_device->device(), &fci1, nullptr, &f1); |
| 2425 | ASSERT_VK_SUCCESS(err); |
| 2426 | |
| 2427 | // A fence created not |
| 2428 | VkFenceCreateInfo fci2 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; |
| 2429 | VkFence f2; |
| 2430 | err = vkCreateFence(m_device->device(), &fci2, nullptr, &f2); |
| 2431 | ASSERT_VK_SUCCESS(err); |
| 2432 | |
| 2433 | // Submit the unsignaled fence |
| 2434 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, |
| 2435 | 0, nullptr, 0, nullptr }; |
| 2436 | err = vkQueueSubmit(m_device->m_queue, 1, &si, f2); |
| 2437 | |
| 2438 | // Wait on both fences, with signaled first. |
| 2439 | VkFence fences[] = { f1, f2 }; |
| 2440 | vkWaitForFences(m_device->device(), 2, fences, VK_TRUE, UINT64_MAX); |
| 2441 | |
| 2442 | // Should have both retired! |
| 2443 | vkDestroyFence(m_device->device(), f1, nullptr); |
| 2444 | vkDestroyFence(m_device->device(), f2, nullptr); |
| 2445 | |
| 2446 | m_errorMonitor->VerifyNotFound(); |
| 2447 | } |
| 2448 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2449 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2450 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2451 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2452 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2453 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2454 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2455 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2456 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2457 | |
| 2458 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2459 | VkImageObj image(m_device); |
| 2460 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2461 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2462 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2463 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2464 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2465 | VkImageView dsv; |
| 2466 | VkImageViewCreateInfo dsvci = {}; |
| 2467 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2468 | dsvci.image = image.handle(); |
| 2469 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2470 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2471 | dsvci.subresourceRange.layerCount = 1; |
| 2472 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2473 | dsvci.subresourceRange.levelCount = 1; |
| 2474 | dsvci.subresourceRange.aspectMask = |
| 2475 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2476 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2477 | // Create a view with depth / stencil aspect for image with different usage |
| 2478 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2479 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2480 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2481 | |
| 2482 | // Initialize buffer with TRANSFER_DST usage |
| 2483 | vk_testing::Buffer buffer; |
| 2484 | VkMemoryPropertyFlags reqs = 0; |
| 2485 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2486 | VkBufferImageCopy region = {}; |
| 2487 | region.bufferRowLength = 128; |
| 2488 | region.bufferImageHeight = 128; |
| 2489 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2490 | region.imageSubresource.layerCount = 1; |
| 2491 | region.imageExtent.height = 16; |
| 2492 | region.imageExtent.width = 16; |
| 2493 | region.imageExtent.depth = 1; |
| 2494 | |
| 2495 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2496 | "Invalid usage flag for buffer "); |
| 2497 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2498 | // TRANSFER_DST |
| 2499 | BeginCommandBuffer(); |
| 2500 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2501 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2502 | 1, ®ion); |
| 2503 | m_errorMonitor->VerifyFound(); |
| 2504 | |
| 2505 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2506 | "Invalid usage flag for image "); |
| 2507 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2508 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2509 | 1, ®ion); |
| 2510 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2511 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2512 | #endif // MEM_TRACKER_TESTS |
| 2513 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2514 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2515 | |
| 2516 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2517 | VkResult err; |
| 2518 | |
| 2519 | TEST_DESCRIPTION( |
| 2520 | "Create a fence and destroy its device without first destroying the fence."); |
| 2521 | |
| 2522 | // Note that we have to create a new device since destroying the |
| 2523 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2524 | // will destroy the errorMonitor. |
| 2525 | |
| 2526 | m_errorMonitor->SetDesiredFailureMsg( |
| 2527 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2528 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2529 | |
| 2530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2531 | |
| 2532 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2533 | m_device->queue_props; |
| 2534 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2535 | queue_info.reserve(queue_props.size()); |
| 2536 | std::vector<std::vector<float>> queue_priorities; |
| 2537 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2538 | VkDeviceQueueCreateInfo qi = {}; |
| 2539 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2540 | qi.pNext = NULL; |
| 2541 | qi.queueFamilyIndex = i; |
| 2542 | qi.queueCount = queue_props[i].queueCount; |
| 2543 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2544 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2545 | queue_info.push_back(qi); |
| 2546 | } |
| 2547 | |
| 2548 | std::vector<const char *> device_layer_names; |
| 2549 | std::vector<const char *> device_extension_names; |
| 2550 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2551 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2552 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2553 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2554 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2555 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2556 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2557 | |
| 2558 | // The sacrificial device object |
| 2559 | VkDevice testDevice; |
| 2560 | VkDeviceCreateInfo device_create_info = {}; |
| 2561 | auto features = m_device->phy().features(); |
| 2562 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2563 | device_create_info.pNext = NULL; |
| 2564 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2565 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2566 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2567 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2568 | device_create_info.pEnabledFeatures = &features; |
| 2569 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2570 | ASSERT_VK_SUCCESS(err); |
| 2571 | |
| 2572 | VkFence fence; |
| 2573 | VkFenceCreateInfo fence_create_info = {}; |
| 2574 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2575 | fence_create_info.pNext = NULL; |
| 2576 | fence_create_info.flags = 0; |
| 2577 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2578 | ASSERT_VK_SUCCESS(err); |
| 2579 | |
| 2580 | // Induce failure by not calling vkDestroyFence |
| 2581 | vkDestroyDevice(testDevice, NULL); |
| 2582 | m_errorMonitor->VerifyFound(); |
| 2583 | } |
| 2584 | |
| 2585 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2586 | |
| 2587 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2588 | "attempt to delete them from another."); |
| 2589 | |
| 2590 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2591 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2592 | |
| 2593 | VkCommandPool command_pool_one; |
| 2594 | VkCommandPool command_pool_two; |
| 2595 | |
| 2596 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2597 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2598 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2599 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2600 | |
| 2601 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2602 | &command_pool_one); |
| 2603 | |
| 2604 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2605 | &command_pool_two); |
| 2606 | |
| 2607 | VkCommandBuffer command_buffer[9]; |
| 2608 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2609 | command_buffer_allocate_info.sType = |
| 2610 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2611 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2612 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2613 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2614 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2615 | command_buffer); |
| 2616 | |
| 2617 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2618 | &command_buffer[3]); |
| 2619 | |
| 2620 | m_errorMonitor->VerifyFound(); |
| 2621 | |
| 2622 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2623 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2624 | } |
| 2625 | |
| 2626 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2627 | VkResult err; |
| 2628 | |
| 2629 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2630 | "attempt to delete them from another."); |
| 2631 | |
| 2632 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2633 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2634 | |
| 2635 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2636 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2637 | |
| 2638 | VkDescriptorPoolSize ds_type_count = {}; |
| 2639 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2640 | ds_type_count.descriptorCount = 1; |
| 2641 | |
| 2642 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2643 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2644 | ds_pool_ci.pNext = NULL; |
| 2645 | ds_pool_ci.flags = 0; |
| 2646 | ds_pool_ci.maxSets = 1; |
| 2647 | ds_pool_ci.poolSizeCount = 1; |
| 2648 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2649 | |
| 2650 | VkDescriptorPool ds_pool_one; |
| 2651 | err = |
| 2652 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2653 | ASSERT_VK_SUCCESS(err); |
| 2654 | |
| 2655 | // Create a second descriptor pool |
| 2656 | VkDescriptorPool ds_pool_two; |
| 2657 | err = |
| 2658 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2659 | ASSERT_VK_SUCCESS(err); |
| 2660 | |
| 2661 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2662 | dsl_binding.binding = 0; |
| 2663 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2664 | dsl_binding.descriptorCount = 1; |
| 2665 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2666 | dsl_binding.pImmutableSamplers = NULL; |
| 2667 | |
| 2668 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2669 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2670 | ds_layout_ci.pNext = NULL; |
| 2671 | ds_layout_ci.bindingCount = 1; |
| 2672 | ds_layout_ci.pBindings = &dsl_binding; |
| 2673 | |
| 2674 | VkDescriptorSetLayout ds_layout; |
| 2675 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2676 | &ds_layout); |
| 2677 | ASSERT_VK_SUCCESS(err); |
| 2678 | |
| 2679 | VkDescriptorSet descriptorSet; |
| 2680 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2681 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2682 | alloc_info.descriptorSetCount = 1; |
| 2683 | alloc_info.descriptorPool = ds_pool_one; |
| 2684 | alloc_info.pSetLayouts = &ds_layout; |
| 2685 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2686 | &descriptorSet); |
| 2687 | ASSERT_VK_SUCCESS(err); |
| 2688 | |
| 2689 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2690 | |
| 2691 | m_errorMonitor->VerifyFound(); |
| 2692 | |
| 2693 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2694 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2695 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2696 | } |
| 2697 | |
| 2698 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2699 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2700 | "Invalid VkImage Object "); |
| 2701 | |
| 2702 | TEST_DESCRIPTION( |
| 2703 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2704 | |
| 2705 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2706 | |
| 2707 | // Pass bogus handle into GetImageMemoryRequirements |
| 2708 | VkMemoryRequirements mem_reqs; |
| 2709 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2710 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2711 | |
| 2712 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2713 | |
| 2714 | m_errorMonitor->VerifyFound(); |
| 2715 | } |
| 2716 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2717 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2718 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2719 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2720 | TEST_DESCRIPTION( |
| 2721 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2722 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2723 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2725 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2726 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2727 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2728 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2729 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2730 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2731 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2732 | |
| 2733 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2734 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2735 | ds_pool_ci.pNext = NULL; |
| 2736 | ds_pool_ci.maxSets = 1; |
| 2737 | ds_pool_ci.poolSizeCount = 1; |
| 2738 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2739 | |
| 2740 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2741 | err = |
| 2742 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2743 | ASSERT_VK_SUCCESS(err); |
| 2744 | |
| 2745 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2746 | dsl_binding.binding = 0; |
| 2747 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2748 | dsl_binding.descriptorCount = 1; |
| 2749 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2750 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2751 | |
| 2752 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2753 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2754 | ds_layout_ci.pNext = NULL; |
| 2755 | ds_layout_ci.bindingCount = 1; |
| 2756 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2757 | |
| 2758 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2760 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2761 | ASSERT_VK_SUCCESS(err); |
| 2762 | |
| 2763 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2764 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2765 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2766 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2767 | alloc_info.descriptorPool = ds_pool; |
| 2768 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2770 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2771 | ASSERT_VK_SUCCESS(err); |
| 2772 | |
| 2773 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2774 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2775 | pipeline_layout_ci.pNext = NULL; |
| 2776 | pipeline_layout_ci.setLayoutCount = 1; |
| 2777 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2778 | |
| 2779 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2780 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2781 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2782 | ASSERT_VK_SUCCESS(err); |
| 2783 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2784 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2785 | |
| 2786 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2787 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2788 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2790 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2791 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2792 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2793 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2794 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2795 | } |
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 2796 | |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2797 | TEST_F(VkLayerTest, BindImageInvalidMemoryType) { |
| 2798 | VkResult err; |
| 2799 | |
| 2800 | TEST_DESCRIPTION("Test validation check for an invalid memory type index " |
| 2801 | "during bind[Buffer|Image]Memory time"); |
| 2802 | |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2803 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2804 | |
| 2805 | // Create an image, allocate memory, set a bad typeIndex and then try to |
| 2806 | // bind it |
| 2807 | VkImage image; |
| 2808 | VkDeviceMemory mem; |
| 2809 | VkMemoryRequirements mem_reqs; |
| 2810 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2811 | const int32_t tex_width = 32; |
| 2812 | const int32_t tex_height = 32; |
| 2813 | |
| 2814 | VkImageCreateInfo image_create_info = {}; |
| 2815 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2816 | image_create_info.pNext = NULL; |
| 2817 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2818 | image_create_info.format = tex_format; |
| 2819 | image_create_info.extent.width = tex_width; |
| 2820 | image_create_info.extent.height = tex_height; |
| 2821 | image_create_info.extent.depth = 1; |
| 2822 | image_create_info.mipLevels = 1; |
| 2823 | image_create_info.arrayLayers = 1; |
| 2824 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2825 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2826 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2827 | image_create_info.flags = 0; |
| 2828 | |
| 2829 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2830 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2831 | mem_alloc.pNext = NULL; |
| 2832 | mem_alloc.allocationSize = 0; |
| 2833 | mem_alloc.memoryTypeIndex = 0; |
| 2834 | |
| 2835 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2836 | ASSERT_VK_SUCCESS(err); |
| 2837 | |
| 2838 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 2839 | mem_alloc.allocationSize = mem_reqs.size; |
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 2840 | |
| 2841 | // Introduce Failure, select invalid TypeIndex |
| 2842 | VkPhysicalDeviceMemoryProperties memory_info; |
| 2843 | |
| 2844 | vkGetPhysicalDeviceMemoryProperties(gpu(), &memory_info); |
| 2845 | unsigned int i; |
| 2846 | for (i = 0; i < memory_info.memoryTypeCount; i++) { |
| 2847 | if ((mem_reqs.memoryTypeBits & (1 << i)) == 0) { |
| 2848 | mem_alloc.memoryTypeIndex = i; |
| 2849 | break; |
| 2850 | } |
| 2851 | } |
| 2852 | if (i >= memory_info.memoryTypeCount) { |
| 2853 | printf("No invalid memory type index could be found; skipped.\n"); |
| 2854 | vkDestroyImage(m_device->device(), image, NULL); |
| 2855 | return; |
| 2856 | } |
| 2857 | |
| 2858 | m_errorMonitor->SetDesiredFailureMsg( |
| 2859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2860 | "for this object type are not compatible with the memory"); |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2861 | |
| 2862 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2863 | ASSERT_VK_SUCCESS(err); |
| 2864 | |
| 2865 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2866 | (void)err; |
| 2867 | |
| 2868 | m_errorMonitor->VerifyFound(); |
| 2869 | |
| 2870 | vkDestroyImage(m_device->device(), image, NULL); |
| 2871 | vkFreeMemory(m_device->device(), mem, NULL); |
| 2872 | } |
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 2873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2874 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2875 | VkResult err; |
| 2876 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2877 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2879 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2880 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2881 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2882 | |
| 2883 | // 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] | 2884 | VkImage image; |
| 2885 | VkDeviceMemory mem; |
| 2886 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2889 | const int32_t tex_width = 32; |
| 2890 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2891 | |
| 2892 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2893 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2894 | image_create_info.pNext = NULL; |
| 2895 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2896 | image_create_info.format = tex_format; |
| 2897 | image_create_info.extent.width = tex_width; |
| 2898 | image_create_info.extent.height = tex_height; |
| 2899 | image_create_info.extent.depth = 1; |
| 2900 | image_create_info.mipLevels = 1; |
| 2901 | image_create_info.arrayLayers = 1; |
| 2902 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2903 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2904 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2905 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2906 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2907 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2908 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2909 | mem_alloc.pNext = NULL; |
| 2910 | mem_alloc.allocationSize = 0; |
| 2911 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2912 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2913 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2914 | ASSERT_VK_SUCCESS(err); |
| 2915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2916 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2917 | |
| 2918 | mem_alloc.allocationSize = mem_reqs.size; |
| 2919 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2920 | pass = |
| 2921 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2922 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2923 | |
| 2924 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2925 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2926 | ASSERT_VK_SUCCESS(err); |
| 2927 | |
| 2928 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2929 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2930 | |
| 2931 | // Try to bind free memory that has been freed |
| 2932 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2933 | // This may very well return an error. |
| 2934 | (void)err; |
| 2935 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2936 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2937 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2938 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2939 | } |
| 2940 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2941 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2942 | VkResult err; |
| 2943 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2946 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2947 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2948 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2950 | // Create an image object, allocate memory, destroy the object and then try |
| 2951 | // to bind it |
| 2952 | VkImage image; |
| 2953 | VkDeviceMemory mem; |
| 2954 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2955 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2956 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2957 | const int32_t tex_width = 32; |
| 2958 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2959 | |
| 2960 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2961 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2962 | image_create_info.pNext = NULL; |
| 2963 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2964 | image_create_info.format = tex_format; |
| 2965 | image_create_info.extent.width = tex_width; |
| 2966 | image_create_info.extent.height = tex_height; |
| 2967 | image_create_info.extent.depth = 1; |
| 2968 | image_create_info.mipLevels = 1; |
| 2969 | image_create_info.arrayLayers = 1; |
| 2970 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2971 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2972 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2973 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2974 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2975 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2976 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2977 | mem_alloc.pNext = NULL; |
| 2978 | mem_alloc.allocationSize = 0; |
| 2979 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2980 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2981 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2982 | ASSERT_VK_SUCCESS(err); |
| 2983 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2984 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2985 | |
| 2986 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2987 | pass = |
| 2988 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2989 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2990 | |
| 2991 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2992 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2993 | ASSERT_VK_SUCCESS(err); |
| 2994 | |
| 2995 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2996 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2997 | ASSERT_VK_SUCCESS(err); |
| 2998 | |
| 2999 | // Now Try to bind memory to this destroyed object |
| 3000 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 3001 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3002 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3003 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3004 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3005 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3006 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3007 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3008 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3009 | #endif // OBJ_TRACKER_TESTS |
| 3010 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3011 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3012 | |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 3013 | TEST_F(VkLayerTest, RenderPassInitialLayoutUndefined) { |
| 3014 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass with an attachment's " |
| 3015 | "initialLayout of VK_IMAGE_LAYOUT_UNDEFINED works when " |
| 3016 | "the command buffer has prior knowledge of that " |
| 3017 | "attachment's layout."); |
| 3018 | |
| 3019 | m_errorMonitor->ExpectSuccess(); |
| 3020 | |
| 3021 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3022 | |
| 3023 | // A renderpass with one color attachment. |
| 3024 | VkAttachmentDescription attachment = { |
| 3025 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, |
| 3026 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, |
| 3027 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3028 | VK_IMAGE_LAYOUT_UNDEFINED, |
| 3029 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3030 | }; |
| 3031 | |
| 3032 | VkAttachmentReference att_ref = { |
| 3033 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3034 | }; |
| 3035 | |
| 3036 | VkSubpassDescription subpass = { |
| 3037 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, |
| 3038 | 1, &att_ref, nullptr, nullptr, 0, nullptr |
| 3039 | }; |
| 3040 | |
| 3041 | VkRenderPassCreateInfo rpci = { |
| 3042 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3043 | 0, 1, &attachment, 1, &subpass, 0, nullptr |
| 3044 | }; |
| 3045 | |
| 3046 | VkRenderPass rp; |
| 3047 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3048 | ASSERT_VK_SUCCESS(err); |
| 3049 | |
| 3050 | // A compatible framebuffer. |
| 3051 | VkImageObj image(m_device); |
| 3052 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, |
| 3053 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
| 3054 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 3055 | ASSERT_TRUE(image.initialized()); |
| 3056 | |
| 3057 | VkImageViewCreateInfo ivci = { |
| 3058 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, |
| 3059 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, |
| 3060 | { |
| 3061 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3062 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3063 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3064 | VK_COMPONENT_SWIZZLE_IDENTITY |
| 3065 | }, |
| 3066 | { |
| 3067 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 |
| 3068 | }, |
| 3069 | }; |
| 3070 | VkImageView view; |
| 3071 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); |
| 3072 | ASSERT_VK_SUCCESS(err); |
| 3073 | |
| 3074 | VkFramebufferCreateInfo fci = { |
| 3075 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, |
| 3076 | 0, rp, 1, &view, |
| 3077 | 32, 32, 1 |
| 3078 | }; |
| 3079 | VkFramebuffer fb; |
| 3080 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); |
| 3081 | ASSERT_VK_SUCCESS(err); |
| 3082 | |
| 3083 | // Record a single command buffer which uses this renderpass twice. The |
| 3084 | // bug is triggered at the beginning of the second renderpass, when the |
| 3085 | // command buffer already has a layout recorded for the attachment. |
| 3086 | VkRenderPassBeginInfo rpbi = { |
| 3087 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, |
| 3088 | rp, fb, { 0, 0, 32, 32 }, |
| 3089 | 0, nullptr |
| 3090 | }; |
| 3091 | BeginCommandBuffer(); |
| 3092 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, |
| 3093 | VK_SUBPASS_CONTENTS_INLINE); |
| 3094 | vkCmdEndRenderPass(m_commandBuffer->handle()); |
| 3095 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, |
| 3096 | VK_SUBPASS_CONTENTS_INLINE); |
| 3097 | |
| 3098 | m_errorMonitor->VerifyNotFound(); |
| 3099 | |
| 3100 | vkCmdEndRenderPass(m_commandBuffer->handle()); |
| 3101 | EndCommandBuffer(); |
| 3102 | |
| 3103 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); |
| 3104 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3105 | vkDestroyImageView(m_device->device(), view, nullptr); |
| 3106 | } |
| 3107 | |
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3108 | TEST_F(VkLayerTest, RenderPassSubpassZeroTransitionsApplied) { |
| 3109 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass applies the layout " |
| 3110 | "transitions for the first subpass"); |
| 3111 | |
| 3112 | m_errorMonitor->ExpectSuccess(); |
| 3113 | |
| 3114 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3115 | |
| 3116 | // A renderpass with one color attachment. |
| 3117 | VkAttachmentDescription attachment = { |
| 3118 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, |
| 3119 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, |
| 3120 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3121 | VK_IMAGE_LAYOUT_UNDEFINED, |
| 3122 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3123 | }; |
| 3124 | |
| 3125 | VkAttachmentReference att_ref = { |
| 3126 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3127 | }; |
| 3128 | |
| 3129 | VkSubpassDescription subpass = { |
| 3130 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, |
| 3131 | 1, &att_ref, nullptr, nullptr, 0, nullptr |
| 3132 | }; |
| 3133 | |
| 3134 | VkSubpassDependency dep = { |
| 3135 | 0, 0, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3136 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3137 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 3138 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 3139 | VK_DEPENDENCY_BY_REGION_BIT |
| 3140 | }; |
| 3141 | |
| 3142 | VkRenderPassCreateInfo rpci = { |
| 3143 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3144 | 0, 1, &attachment, 1, &subpass, 1, &dep |
| 3145 | }; |
| 3146 | |
| 3147 | VkResult err; |
| 3148 | VkRenderPass rp; |
| 3149 | err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3150 | ASSERT_VK_SUCCESS(err); |
| 3151 | |
| 3152 | // A compatible framebuffer. |
| 3153 | VkImageObj image(m_device); |
| 3154 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, |
| 3155 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
| 3156 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 3157 | ASSERT_TRUE(image.initialized()); |
| 3158 | |
| 3159 | VkImageViewCreateInfo ivci = { |
| 3160 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, |
| 3161 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, |
| 3162 | { |
| 3163 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3164 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3165 | VK_COMPONENT_SWIZZLE_IDENTITY, |
| 3166 | VK_COMPONENT_SWIZZLE_IDENTITY |
| 3167 | }, |
| 3168 | { |
| 3169 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 |
| 3170 | }, |
| 3171 | }; |
| 3172 | VkImageView view; |
| 3173 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); |
| 3174 | ASSERT_VK_SUCCESS(err); |
| 3175 | |
| 3176 | VkFramebufferCreateInfo fci = { |
| 3177 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, |
| 3178 | 0, rp, 1, &view, |
| 3179 | 32, 32, 1 |
| 3180 | }; |
| 3181 | VkFramebuffer fb; |
| 3182 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); |
| 3183 | ASSERT_VK_SUCCESS(err); |
| 3184 | |
| 3185 | // Record a single command buffer which issues a pipeline barrier w/ |
| 3186 | // image memory barrier for the attachment. This detects the previously |
| 3187 | // missing tracking of the subpass layout by throwing a validation error |
| 3188 | // if it doesn't occur. |
| 3189 | VkRenderPassBeginInfo rpbi = { |
| 3190 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, |
| 3191 | rp, fb, { 0, 0, 32, 32 }, |
| 3192 | 0, nullptr |
| 3193 | }; |
| 3194 | BeginCommandBuffer(); |
| 3195 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, |
| 3196 | VK_SUBPASS_CONTENTS_INLINE); |
| 3197 | |
| 3198 | VkImageMemoryBarrier imb = { |
| 3199 | VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, nullptr, |
| 3200 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 3201 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 3202 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3203 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3204 | VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, |
| 3205 | image.handle(), |
| 3206 | { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } |
| 3207 | }; |
| 3208 | vkCmdPipelineBarrier(m_commandBuffer->handle(), |
| 3209 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3210 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3211 | VK_DEPENDENCY_BY_REGION_BIT, |
| 3212 | 0, nullptr, 0, nullptr, 1, &imb); |
| 3213 | |
| 3214 | vkCmdEndRenderPass(m_commandBuffer->handle()); |
| 3215 | m_errorMonitor->VerifyNotFound(); |
| 3216 | EndCommandBuffer(); |
| 3217 | |
| 3218 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); |
| 3219 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3220 | vkDestroyImageView(m_device->device(), view, nullptr); |
| 3221 | } |
| 3222 | |
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 3223 | TEST_F(VkLayerTest, RenderPassTransitionsAttachmentUnused) { |
| 3224 | TEST_DESCRIPTION("Ensure that layout transitions work correctly without " |
| 3225 | "errors, when an attachment reference is " |
| 3226 | "VK_ATTACHMENT_UNUSED"); |
| 3227 | |
| 3228 | m_errorMonitor->ExpectSuccess(); |
| 3229 | |
| 3230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3231 | |
| 3232 | // A renderpass with no attachments |
| 3233 | VkAttachmentReference att_ref = { |
| 3234 | VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3235 | }; |
| 3236 | |
| 3237 | VkSubpassDescription subpass = { |
| 3238 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, |
| 3239 | 1, &att_ref, nullptr, nullptr, 0, nullptr |
| 3240 | }; |
| 3241 | |
| 3242 | VkRenderPassCreateInfo rpci = { |
| 3243 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3244 | 0, 0, nullptr, 1, &subpass, 0, nullptr |
| 3245 | }; |
| 3246 | |
| 3247 | VkRenderPass rp; |
| 3248 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3249 | ASSERT_VK_SUCCESS(err); |
| 3250 | |
| 3251 | // A compatible framebuffer. |
| 3252 | VkFramebufferCreateInfo fci = { |
| 3253 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, |
| 3254 | 0, rp, 0, nullptr, |
| 3255 | 32, 32, 1 |
| 3256 | }; |
| 3257 | VkFramebuffer fb; |
| 3258 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); |
| 3259 | ASSERT_VK_SUCCESS(err); |
| 3260 | |
| 3261 | // Record a command buffer which just begins and ends the renderpass. The |
| 3262 | // bug manifests in BeginRenderPass. |
| 3263 | VkRenderPassBeginInfo rpbi = { |
| 3264 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, |
| 3265 | rp, fb, { 0, 0, 32, 32 }, |
| 3266 | 0, nullptr |
| 3267 | }; |
| 3268 | BeginCommandBuffer(); |
| 3269 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, |
| 3270 | VK_SUBPASS_CONTENTS_INLINE); |
| 3271 | vkCmdEndRenderPass(m_commandBuffer->handle()); |
| 3272 | m_errorMonitor->VerifyNotFound(); |
| 3273 | EndCommandBuffer(); |
| 3274 | |
| 3275 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); |
| 3276 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3277 | } |
| 3278 | |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 3279 | // This is a positive test. No errors are expected. |
| 3280 | TEST_F(VkLayerTest, StencilLoadOp) { |
| 3281 | TEST_DESCRIPTION("Create a stencil-only attachment with a LOAD_OP set to " |
| 3282 | "CLEAR. stencil[Load|Store]Op used to be ignored."); |
| 3283 | VkResult result = VK_SUCCESS; |
| 3284 | VkImageFormatProperties formatProps; |
| 3285 | vkGetPhysicalDeviceImageFormatProperties( |
| 3286 | gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TYPE_2D, |
| 3287 | VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3288 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 3289 | 0, &formatProps); |
| 3290 | if (formatProps.maxExtent.width < 100 || formatProps.maxExtent.height < 100) { |
| 3291 | return; |
| 3292 | } |
| 3293 | |
| 3294 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3295 | VkFormat depth_stencil_fmt = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3296 | m_depthStencil->Init(m_device, 100, 100, depth_stencil_fmt, |
| 3297 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3298 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); |
| 3299 | VkAttachmentDescription att = {}; |
| 3300 | VkAttachmentReference ref = {}; |
| 3301 | att.format = depth_stencil_fmt; |
| 3302 | att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 3303 | att.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 3304 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 3305 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 3306 | att.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3307 | att.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3308 | |
| 3309 | VkClearValue clear; |
| 3310 | clear.depthStencil.depth = 1.0; |
| 3311 | clear.depthStencil.stencil = 0; |
| 3312 | ref.attachment = 0; |
| 3313 | ref.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3314 | |
| 3315 | VkSubpassDescription subpass = {}; |
| 3316 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; |
| 3317 | subpass.flags = 0; |
| 3318 | subpass.inputAttachmentCount = 0; |
| 3319 | subpass.pInputAttachments = NULL; |
| 3320 | subpass.colorAttachmentCount = 0; |
| 3321 | subpass.pColorAttachments = NULL; |
| 3322 | subpass.pResolveAttachments = NULL; |
| 3323 | subpass.pDepthStencilAttachment = &ref; |
| 3324 | subpass.preserveAttachmentCount = 0; |
| 3325 | subpass.pPreserveAttachments = NULL; |
| 3326 | |
| 3327 | VkRenderPass rp; |
| 3328 | VkRenderPassCreateInfo rp_info = {}; |
| 3329 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3330 | rp_info.attachmentCount = 1; |
| 3331 | rp_info.pAttachments = &att; |
| 3332 | rp_info.subpassCount = 1; |
| 3333 | rp_info.pSubpasses = &subpass; |
| 3334 | result = vkCreateRenderPass(device(), &rp_info, NULL, &rp); |
| 3335 | ASSERT_VK_SUCCESS(result); |
| 3336 | |
| 3337 | VkImageView *depthView = m_depthStencil->BindInfo(); |
| 3338 | VkFramebufferCreateInfo fb_info = {}; |
| 3339 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 3340 | fb_info.pNext = NULL; |
| 3341 | fb_info.renderPass = rp; |
| 3342 | fb_info.attachmentCount = 1; |
| 3343 | fb_info.pAttachments = depthView; |
| 3344 | fb_info.width = 100; |
| 3345 | fb_info.height = 100; |
| 3346 | fb_info.layers = 1; |
| 3347 | VkFramebuffer fb; |
| 3348 | result = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3349 | ASSERT_VK_SUCCESS(result); |
| 3350 | |
| 3351 | |
| 3352 | VkRenderPassBeginInfo rpbinfo = {}; |
| 3353 | rpbinfo.clearValueCount = 1; |
| 3354 | rpbinfo.pClearValues = &clear; |
| 3355 | rpbinfo.pNext = NULL; |
| 3356 | rpbinfo.renderPass = rp; |
| 3357 | rpbinfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3358 | rpbinfo.renderArea.extent.width = 100; |
| 3359 | rpbinfo.renderArea.extent.height = 100; |
| 3360 | rpbinfo.renderArea.offset.x = 0; |
| 3361 | rpbinfo.renderArea.offset.y = 0; |
| 3362 | rpbinfo.framebuffer = fb; |
| 3363 | |
| 3364 | VkFence fence = {}; |
| 3365 | VkFenceCreateInfo fence_ci = {}; |
| 3366 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3367 | fence_ci.pNext = nullptr; |
| 3368 | fence_ci.flags = 0; |
| 3369 | result = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fence); |
| 3370 | ASSERT_VK_SUCCESS(result); |
| 3371 | |
| 3372 | |
| 3373 | m_commandBuffer->BeginCommandBuffer(); |
| 3374 | m_commandBuffer->BeginRenderPass(rpbinfo); |
| 3375 | m_commandBuffer->EndRenderPass(); |
| 3376 | m_commandBuffer->EndCommandBuffer(); |
| 3377 | m_commandBuffer->QueueCommandBuffer(fence); |
| 3378 | |
| 3379 | VkImageObj destImage(m_device); |
| 3380 | destImage.init(100, 100, depth_stencil_fmt, |
| 3381 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3382 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 3383 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 3384 | VkImageMemoryBarrier barrier = {}; |
| 3385 | VkImageSubresourceRange range; |
| 3386 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 3387 | barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | |
| 3388 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 3389 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | |
| 3390 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; |
| 3391 | barrier.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3392 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 3393 | barrier.image = m_depthStencil->handle(); |
| 3394 | range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3395 | range.baseMipLevel = 0; |
| 3396 | range.levelCount = 1; |
| 3397 | range.baseArrayLayer = 0; |
| 3398 | range.layerCount = 1; |
| 3399 | barrier.subresourceRange = range; |
| 3400 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3401 | VkCommandBufferObj cmdbuf(m_device, m_commandPool); |
| 3402 | cmdbuf.BeginCommandBuffer(); |
| 3403 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3404 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, |
| 3405 | nullptr, 1, &barrier); |
| 3406 | barrier.srcAccessMask = 0; |
| 3407 | barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3408 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; |
| 3409 | barrier.image = destImage.handle(); |
| 3410 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | |
| 3411 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 3412 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3413 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, |
| 3414 | nullptr, 1, &barrier); |
| 3415 | VkImageCopy cregion; |
| 3416 | cregion.srcSubresource.aspectMask = |
| 3417 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3418 | cregion.srcSubresource.mipLevel = 0; |
| 3419 | cregion.srcSubresource.baseArrayLayer = 0; |
| 3420 | cregion.srcSubresource.layerCount = 1; |
| 3421 | cregion.srcOffset.x = 0; |
| 3422 | cregion.srcOffset.y = 0; |
| 3423 | cregion.srcOffset.z = 0; |
| 3424 | cregion.dstSubresource.aspectMask = |
| 3425 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3426 | cregion.dstSubresource.mipLevel = 0; |
| 3427 | cregion.dstSubresource.baseArrayLayer = 0; |
| 3428 | cregion.dstSubresource.layerCount = 1; |
| 3429 | cregion.dstOffset.x = 0; |
| 3430 | cregion.dstOffset.y = 0; |
| 3431 | cregion.dstOffset.z = 0; |
| 3432 | cregion.extent.width = 100; |
| 3433 | cregion.extent.height = 100; |
| 3434 | cregion.extent.depth = 1; |
| 3435 | cmdbuf.CopyImage(m_depthStencil->handle(), |
| 3436 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, destImage.handle(), |
| 3437 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cregion); |
| 3438 | cmdbuf.EndCommandBuffer(); |
| 3439 | |
| 3440 | VkSubmitInfo submit_info; |
| 3441 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3442 | submit_info.pNext = NULL; |
| 3443 | submit_info.waitSemaphoreCount = 0; |
| 3444 | submit_info.pWaitSemaphores = NULL; |
| 3445 | submit_info.pWaitDstStageMask = NULL; |
| 3446 | submit_info.commandBufferCount = 1; |
| 3447 | submit_info.pCommandBuffers = &cmdbuf.handle(); |
| 3448 | submit_info.signalSemaphoreCount = 0; |
| 3449 | submit_info.pSignalSemaphores = NULL; |
| 3450 | |
| 3451 | m_errorMonitor->ExpectSuccess(); |
| 3452 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3453 | m_errorMonitor->VerifyNotFound(); |
| 3454 | |
Mark Lobodzinski | d0440da | 2016-06-17 15:10:03 -0600 | [diff] [blame] | 3455 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 3456 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3457 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3458 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); |
| 3459 | } |
| 3460 | |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3461 | TEST_F(VkLayerTest, UnusedPreserveAttachment) { |
| 3462 | TEST_DESCRIPTION("Create a framebuffer where a subpass has a preserve " |
| 3463 | "attachment reference of VK_ATTACHMENT_UNUSED"); |
| 3464 | |
| 3465 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3466 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3467 | |
| 3468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3469 | "must not be VK_ATTACHMENT_UNUSED"); |
| 3470 | |
| 3471 | VkAttachmentReference color_attach = {}; |
| 3472 | color_attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 3473 | color_attach.attachment = 0; |
| 3474 | uint32_t preserve_attachment = VK_ATTACHMENT_UNUSED; |
| 3475 | VkSubpassDescription subpass = {}; |
| 3476 | subpass.colorAttachmentCount = 1; |
| 3477 | subpass.pColorAttachments = &color_attach; |
| 3478 | subpass.preserveAttachmentCount = 1; |
| 3479 | subpass.pPreserveAttachments = &preserve_attachment; |
| 3480 | |
| 3481 | VkRenderPassCreateInfo rpci = {}; |
| 3482 | rpci.subpassCount = 1; |
| 3483 | rpci.pSubpasses = &subpass; |
| 3484 | rpci.attachmentCount = 1; |
| 3485 | VkAttachmentDescription attach_desc = {}; |
| 3486 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 3487 | rpci.pAttachments = &attach_desc; |
| 3488 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3489 | VkRenderPass rp; |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 3490 | VkResult result = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3491 | |
| 3492 | m_errorMonitor->VerifyFound(); |
| 3493 | |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 3494 | if (result == VK_SUCCESS) { |
| 3495 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3496 | } |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3497 | } |
| 3498 | |
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 3499 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresColorMsaa) { |
| 3500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3501 | |
| 3502 | m_errorMonitor->SetDesiredFailureMsg( |
| 3503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3504 | "Subpass 0 requests multisample resolve, but renders to " |
| 3505 | "attachment 0 which has VK_SAMPLE_COUNT_1_BIT"); |
| 3506 | |
| 3507 | VkAttachmentDescription attachments[] = { |
| 3508 | { |
| 3509 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3510 | VK_SAMPLE_COUNT_1_BIT, |
| 3511 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3512 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3513 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3514 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3515 | }, |
| 3516 | { |
| 3517 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3518 | VK_SAMPLE_COUNT_1_BIT, |
| 3519 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3520 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3521 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3522 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3523 | }, |
| 3524 | }; |
| 3525 | |
| 3526 | VkAttachmentReference color = { |
| 3527 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3528 | }; |
| 3529 | |
| 3530 | VkAttachmentReference resolve = { |
| 3531 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3532 | }; |
| 3533 | |
| 3534 | VkSubpassDescription subpass = { |
| 3535 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3536 | 0, nullptr, |
| 3537 | 1, &color, |
| 3538 | &resolve, |
| 3539 | nullptr, |
| 3540 | 0, nullptr |
| 3541 | }; |
| 3542 | |
| 3543 | VkRenderPassCreateInfo rpci = { |
| 3544 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3545 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3546 | }; |
| 3547 | |
| 3548 | VkRenderPass rp; |
| 3549 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3550 | |
| 3551 | m_errorMonitor->VerifyFound(); |
| 3552 | |
| 3553 | if (err == VK_SUCCESS) |
| 3554 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3555 | } |
| 3556 | |
| 3557 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresSingleSampleDest) { |
| 3558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3559 | |
| 3560 | m_errorMonitor->SetDesiredFailureMsg( |
| 3561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3562 | "Subpass 0 requests multisample resolve into attachment 1, which " |
| 3563 | "must have VK_SAMPLE_COUNT_1_BIT but has VK_SAMPLE_COUNT_4_BIT"); |
| 3564 | |
| 3565 | VkAttachmentDescription attachments[] = { |
| 3566 | { |
| 3567 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3568 | VK_SAMPLE_COUNT_4_BIT, |
| 3569 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3570 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3571 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3572 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3573 | }, |
| 3574 | { |
| 3575 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3576 | VK_SAMPLE_COUNT_4_BIT, |
| 3577 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3578 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3579 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3580 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3581 | }, |
| 3582 | }; |
| 3583 | |
| 3584 | VkAttachmentReference color = { |
| 3585 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3586 | }; |
| 3587 | |
| 3588 | VkAttachmentReference resolve = { |
| 3589 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3590 | }; |
| 3591 | |
| 3592 | VkSubpassDescription subpass = { |
| 3593 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3594 | 0, nullptr, |
| 3595 | 1, &color, |
| 3596 | &resolve, |
| 3597 | nullptr, |
| 3598 | 0, nullptr |
| 3599 | }; |
| 3600 | |
| 3601 | VkRenderPassCreateInfo rpci = { |
| 3602 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3603 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3604 | }; |
| 3605 | |
| 3606 | VkRenderPass rp; |
| 3607 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3608 | |
| 3609 | m_errorMonitor->VerifyFound(); |
| 3610 | |
| 3611 | if (err == VK_SUCCESS) |
| 3612 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3613 | } |
| 3614 | |
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 3615 | TEST_F(VkLayerTest, CreateRenderPassSubpassSampleCountConsistency) { |
| 3616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3617 | |
| 3618 | m_errorMonitor->SetDesiredFailureMsg( |
| 3619 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3620 | "Subpass 0 attempts to render to attachments with inconsistent sample counts"); |
| 3621 | |
| 3622 | VkAttachmentDescription attachments[] = { |
| 3623 | { |
| 3624 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3625 | VK_SAMPLE_COUNT_1_BIT, |
| 3626 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3627 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3628 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3629 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3630 | }, |
| 3631 | { |
| 3632 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3633 | VK_SAMPLE_COUNT_4_BIT, |
| 3634 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3635 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3636 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3637 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3638 | }, |
| 3639 | }; |
| 3640 | |
| 3641 | VkAttachmentReference color[] = { |
| 3642 | { |
| 3643 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3644 | }, |
| 3645 | { |
| 3646 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3647 | }, |
| 3648 | }; |
| 3649 | |
| 3650 | VkSubpassDescription subpass = { |
| 3651 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3652 | 0, nullptr, |
| 3653 | 2, color, |
| 3654 | nullptr, |
| 3655 | nullptr, |
| 3656 | 0, nullptr |
| 3657 | }; |
| 3658 | |
| 3659 | VkRenderPassCreateInfo rpci = { |
| 3660 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3661 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3662 | }; |
| 3663 | |
| 3664 | VkRenderPass rp; |
| 3665 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3666 | |
| 3667 | m_errorMonitor->VerifyFound(); |
| 3668 | |
| 3669 | if (err == VK_SUCCESS) |
| 3670 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3671 | } |
| 3672 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3673 | TEST_F(VkLayerTest, FramebufferCreateErrors) { |
| 3674 | TEST_DESCRIPTION("Hit errors when attempting to create a framebuffer :\n" |
| 3675 | " 1. Mismatch between fb & renderPass attachmentCount\n" |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3676 | " 2. Use a color image as depthStencil attachment\n" |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3677 | " 3. Mismatch fb & renderPass attachment formats\n" |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3678 | " 4. Mismatch fb & renderPass attachment #samples\n" |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3679 | " 5. FB attachment w/ non-1 mip-levels\n" |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 3680 | " 6. FB attachment where dimensions don't match\n" |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 3681 | " 7. FB attachment w/o identity swizzle\n" |
| 3682 | " 8. FB dimensions exceed physical device limits\n"); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3683 | |
| 3684 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3685 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3686 | |
| 3687 | m_errorMonitor->SetDesiredFailureMsg( |
| 3688 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3689 | "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of 2 " |
| 3690 | "does not match attachmentCount of 1 of "); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3691 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3692 | // Create a renderPass with a single color attachment |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3693 | VkAttachmentReference attach = {}; |
| 3694 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 3695 | VkSubpassDescription subpass = {}; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3696 | subpass.pColorAttachments = &attach; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3697 | VkRenderPassCreateInfo rpci = {}; |
| 3698 | rpci.subpassCount = 1; |
| 3699 | rpci.pSubpasses = &subpass; |
| 3700 | rpci.attachmentCount = 1; |
| 3701 | VkAttachmentDescription attach_desc = {}; |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3702 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3703 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3704 | rpci.pAttachments = &attach_desc; |
| 3705 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3706 | VkRenderPass rp; |
| 3707 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3708 | ASSERT_VK_SUCCESS(err); |
| 3709 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3710 | VkImageView ivs[2]; |
| 3711 | ivs[0] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
| 3712 | ivs[1] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3713 | VkFramebufferCreateInfo fb_info = {}; |
| 3714 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 3715 | fb_info.pNext = NULL; |
| 3716 | fb_info.renderPass = rp; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3717 | // Set mis-matching attachmentCount |
| 3718 | fb_info.attachmentCount = 2; |
| 3719 | fb_info.pAttachments = ivs; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3720 | fb_info.width = 100; |
| 3721 | fb_info.height = 100; |
| 3722 | fb_info.layers = 1; |
| 3723 | |
| 3724 | VkFramebuffer fb; |
| 3725 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3726 | |
| 3727 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3728 | if (err == VK_SUCCESS) { |
| 3729 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3730 | } |
| 3731 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3732 | |
| 3733 | // Create a renderPass with a depth-stencil attachment created with |
| 3734 | // IMAGE_USAGE_COLOR_ATTACHMENT |
| 3735 | // Add our color attachment to pDepthStencilAttachment |
| 3736 | subpass.pDepthStencilAttachment = &attach; |
| 3737 | subpass.pColorAttachments = NULL; |
| 3738 | VkRenderPass rp_ds; |
| 3739 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp_ds); |
| 3740 | ASSERT_VK_SUCCESS(err); |
| 3741 | // Set correct attachment count, but attachment has COLOR usage bit set |
| 3742 | fb_info.attachmentCount = 1; |
| 3743 | fb_info.renderPass = rp_ds; |
| 3744 | |
| 3745 | m_errorMonitor->SetDesiredFailureMsg( |
| 3746 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3747 | " conflicts with the image's IMAGE_USAGE flags "); |
| 3748 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3749 | |
| 3750 | m_errorMonitor->VerifyFound(); |
| 3751 | if (err == VK_SUCCESS) { |
| 3752 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3753 | } |
| 3754 | vkDestroyRenderPass(m_device->device(), rp_ds, NULL); |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3755 | |
| 3756 | // Create new renderpass with alternate attachment format from fb |
| 3757 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3758 | subpass.pDepthStencilAttachment = NULL; |
| 3759 | subpass.pColorAttachments = &attach; |
| 3760 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3761 | ASSERT_VK_SUCCESS(err); |
| 3762 | |
| 3763 | // Cause error due to mis-matched formats between rp & fb |
| 3764 | // rp attachment 0 now has RGBA8 but corresponding fb attach is BGRA8 |
| 3765 | fb_info.renderPass = rp; |
| 3766 | m_errorMonitor->SetDesiredFailureMsg( |
| 3767 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3768 | " has format of VK_FORMAT_B8G8R8A8_UNORM that does not match "); |
| 3769 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3770 | |
| 3771 | m_errorMonitor->VerifyFound(); |
| 3772 | if (err == VK_SUCCESS) { |
| 3773 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3774 | } |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3775 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3776 | |
| 3777 | // Create new renderpass with alternate sample count from fb |
| 3778 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3779 | attach_desc.samples = VK_SAMPLE_COUNT_4_BIT; |
| 3780 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3781 | ASSERT_VK_SUCCESS(err); |
| 3782 | |
| 3783 | // Cause error due to mis-matched sample count between rp & fb |
| 3784 | fb_info.renderPass = rp; |
| 3785 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3786 | " has VK_SAMPLE_COUNT_1_BIT samples " |
| 3787 | "that do not match the " |
| 3788 | "VK_SAMPLE_COUNT_4_BIT "); |
| 3789 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3790 | |
| 3791 | m_errorMonitor->VerifyFound(); |
| 3792 | if (err == VK_SUCCESS) { |
| 3793 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3794 | } |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3795 | |
| 3796 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3797 | |
| 3798 | // Create a custom imageView with non-1 mip levels |
| 3799 | VkImageObj image(m_device); |
| 3800 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 3801 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 3802 | ASSERT_TRUE(image.initialized()); |
| 3803 | |
| 3804 | VkImageView view; |
| 3805 | VkImageViewCreateInfo ivci = {}; |
| 3806 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3807 | ivci.image = image.handle(); |
| 3808 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3809 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3810 | ivci.subresourceRange.layerCount = 1; |
| 3811 | ivci.subresourceRange.baseMipLevel = 0; |
| 3812 | // Set level count 2 (only 1 is allowed for FB attachment) |
| 3813 | ivci.subresourceRange.levelCount = 2; |
| 3814 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3815 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); |
| 3816 | ASSERT_VK_SUCCESS(err); |
| 3817 | // Re-create renderpass to have matching sample count |
| 3818 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3819 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3820 | ASSERT_VK_SUCCESS(err); |
| 3821 | |
| 3822 | fb_info.renderPass = rp; |
| 3823 | fb_info.pAttachments = &view; |
| 3824 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3825 | " has mip levelCount of 2 but only "); |
| 3826 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3827 | |
| 3828 | m_errorMonitor->VerifyFound(); |
| 3829 | if (err == VK_SUCCESS) { |
| 3830 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3831 | } |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3832 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3833 | // Update view to original color buffer and grow FB dimensions too big |
| 3834 | fb_info.pAttachments = ivs; |
| 3835 | fb_info.height = 1024; |
| 3836 | fb_info.width = 1024; |
| 3837 | fb_info.layers = 2; |
| 3838 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3839 | " Attachment dimensions must be at " |
| 3840 | "least as large. "); |
| 3841 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3842 | |
| 3843 | m_errorMonitor->VerifyFound(); |
| 3844 | if (err == VK_SUCCESS) { |
| 3845 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3846 | } |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 3847 | // Create view attachment with non-identity swizzle |
| 3848 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3849 | ivci.image = image.handle(); |
| 3850 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3851 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3852 | ivci.subresourceRange.layerCount = 1; |
| 3853 | ivci.subresourceRange.baseMipLevel = 0; |
| 3854 | ivci.subresourceRange.levelCount = 1; |
| 3855 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3856 | ivci.components.r = VK_COMPONENT_SWIZZLE_G; |
| 3857 | ivci.components.g = VK_COMPONENT_SWIZZLE_R; |
| 3858 | ivci.components.b = VK_COMPONENT_SWIZZLE_A; |
| 3859 | ivci.components.a = VK_COMPONENT_SWIZZLE_B; |
| 3860 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); |
| 3861 | ASSERT_VK_SUCCESS(err); |
| 3862 | |
| 3863 | fb_info.pAttachments = &view; |
| 3864 | fb_info.height = 100; |
| 3865 | fb_info.width = 100; |
| 3866 | fb_info.layers = 1; |
| 3867 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3868 | " has non-identy swizzle. All " |
| 3869 | "framebuffer attachments must have " |
| 3870 | "been created with the identity " |
| 3871 | "swizzle. "); |
| 3872 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3873 | |
| 3874 | m_errorMonitor->VerifyFound(); |
| 3875 | if (err == VK_SUCCESS) { |
| 3876 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3877 | } |
| 3878 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 3879 | // Request fb that exceeds max dimensions |
| 3880 | // reset attachment to color attachment |
| 3881 | fb_info.pAttachments = ivs; |
| 3882 | fb_info.width = m_device->props.limits.maxFramebufferWidth + 1; |
| 3883 | fb_info.height = m_device->props.limits.maxFramebufferHeight + 1; |
| 3884 | fb_info.layers = m_device->props.limits.maxFramebufferLayers + 1; |
| 3885 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3886 | " Requested VkFramebufferCreateInfo " |
| 3887 | "dimensions exceed physical device " |
| 3888 | "limits. "); |
| 3889 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3890 | |
| 3891 | m_errorMonitor->VerifyFound(); |
| 3892 | if (err == VK_SUCCESS) { |
| 3893 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3894 | } |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3895 | |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3896 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3897 | } |
| 3898 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3899 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3900 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 3901 | TEST_DESCRIPTION( |
| 3902 | "Wait on a event then set it after the wait has been submitted."); |
| 3903 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3904 | m_errorMonitor->ExpectSuccess(); |
| 3905 | |
| 3906 | VkEvent event; |
| 3907 | VkEventCreateInfo event_create_info{}; |
| 3908 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3909 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3910 | |
| 3911 | VkCommandPool command_pool; |
| 3912 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3913 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3914 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3915 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3916 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3917 | &command_pool); |
| 3918 | |
| 3919 | VkCommandBuffer command_buffer; |
| 3920 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3921 | command_buffer_allocate_info.sType = |
| 3922 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3923 | command_buffer_allocate_info.commandPool = command_pool; |
| 3924 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3925 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3926 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3927 | &command_buffer); |
| 3928 | |
| 3929 | VkQueue queue = VK_NULL_HANDLE; |
| 3930 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3931 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3932 | |
| 3933 | { |
| 3934 | VkCommandBufferBeginInfo begin_info{}; |
| 3935 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3936 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3937 | |
| 3938 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 3939 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3940 | nullptr, 0, nullptr); |
| 3941 | vkCmdResetEvent(command_buffer, event, |
| 3942 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3943 | vkEndCommandBuffer(command_buffer); |
| 3944 | } |
| 3945 | { |
| 3946 | VkSubmitInfo submit_info{}; |
| 3947 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3948 | submit_info.commandBufferCount = 1; |
| 3949 | submit_info.pCommandBuffers = &command_buffer; |
| 3950 | submit_info.signalSemaphoreCount = 0; |
| 3951 | submit_info.pSignalSemaphores = nullptr; |
| 3952 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3953 | } |
| 3954 | { vkSetEvent(m_device->device(), event); } |
| 3955 | |
| 3956 | vkQueueWaitIdle(queue); |
| 3957 | |
| 3958 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3959 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3960 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3961 | |
| 3962 | m_errorMonitor->VerifyNotFound(); |
| 3963 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3964 | // This is a positive test. No errors should be generated. |
| 3965 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 3966 | TEST_DESCRIPTION( |
| 3967 | "Issue a query and copy from it on a second command buffer."); |
| 3968 | |
| 3969 | if ((m_device->queue_props.empty()) || |
| 3970 | (m_device->queue_props[0].queueCount < 2)) |
| 3971 | return; |
| 3972 | |
| 3973 | m_errorMonitor->ExpectSuccess(); |
| 3974 | |
| 3975 | VkQueryPool query_pool; |
| 3976 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 3977 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 3978 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 3979 | query_pool_create_info.queryCount = 1; |
| 3980 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 3981 | &query_pool); |
| 3982 | |
| 3983 | VkCommandPool command_pool; |
| 3984 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3985 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3986 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3987 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3988 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3989 | &command_pool); |
| 3990 | |
| 3991 | VkCommandBuffer command_buffer[2]; |
| 3992 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3993 | command_buffer_allocate_info.sType = |
| 3994 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3995 | command_buffer_allocate_info.commandPool = command_pool; |
| 3996 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3997 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3998 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3999 | command_buffer); |
| 4000 | |
| 4001 | VkQueue queue = VK_NULL_HANDLE; |
| 4002 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4003 | 1, &queue); |
| 4004 | |
| 4005 | uint32_t qfi = 0; |
| 4006 | VkBufferCreateInfo buff_create_info = {}; |
| 4007 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4008 | buff_create_info.size = 1024; |
| 4009 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 4010 | buff_create_info.queueFamilyIndexCount = 1; |
| 4011 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 4012 | |
| 4013 | VkResult err; |
| 4014 | VkBuffer buffer; |
| 4015 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 4016 | ASSERT_VK_SUCCESS(err); |
| 4017 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4018 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4019 | mem_alloc.pNext = NULL; |
| 4020 | mem_alloc.allocationSize = 1024; |
| 4021 | mem_alloc.memoryTypeIndex = 0; |
| 4022 | |
| 4023 | VkMemoryRequirements memReqs; |
| 4024 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 4025 | bool pass = |
| 4026 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 4027 | if (!pass) { |
| 4028 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 4029 | return; |
| 4030 | } |
| 4031 | |
| 4032 | VkDeviceMemory mem; |
| 4033 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4034 | ASSERT_VK_SUCCESS(err); |
| 4035 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 4036 | ASSERT_VK_SUCCESS(err); |
| 4037 | |
| 4038 | { |
| 4039 | VkCommandBufferBeginInfo begin_info{}; |
| 4040 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4041 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4042 | |
| 4043 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 4044 | vkCmdWriteTimestamp(command_buffer[0], |
| 4045 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 4046 | |
| 4047 | vkEndCommandBuffer(command_buffer[0]); |
| 4048 | |
| 4049 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4050 | |
| 4051 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 4052 | 0, 0, 0); |
| 4053 | |
| 4054 | vkEndCommandBuffer(command_buffer[1]); |
| 4055 | } |
| 4056 | { |
| 4057 | VkSubmitInfo submit_info{}; |
| 4058 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4059 | submit_info.commandBufferCount = 2; |
| 4060 | submit_info.pCommandBuffers = command_buffer; |
| 4061 | submit_info.signalSemaphoreCount = 0; |
| 4062 | submit_info.pSignalSemaphores = nullptr; |
| 4063 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4064 | } |
| 4065 | |
| 4066 | vkQueueWaitIdle(queue); |
| 4067 | |
| 4068 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 4069 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 4070 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4071 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 4072 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 4073 | |
| 4074 | m_errorMonitor->VerifyNotFound(); |
| 4075 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4076 | |
| 4077 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 4078 | TEST_DESCRIPTION( |
| 4079 | "Reset an event then set it after the reset has been submitted."); |
| 4080 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4081 | m_errorMonitor->ExpectSuccess(); |
| 4082 | |
| 4083 | VkEvent event; |
| 4084 | VkEventCreateInfo event_create_info{}; |
| 4085 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4086 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 4087 | |
| 4088 | VkCommandPool command_pool; |
| 4089 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4090 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4091 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4092 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4093 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4094 | &command_pool); |
| 4095 | |
| 4096 | VkCommandBuffer command_buffer; |
| 4097 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4098 | command_buffer_allocate_info.sType = |
| 4099 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4100 | command_buffer_allocate_info.commandPool = command_pool; |
| 4101 | command_buffer_allocate_info.commandBufferCount = 1; |
| 4102 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4103 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4104 | &command_buffer); |
| 4105 | |
| 4106 | VkQueue queue = VK_NULL_HANDLE; |
| 4107 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 4108 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4109 | |
| 4110 | { |
| 4111 | VkCommandBufferBeginInfo begin_info{}; |
| 4112 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4113 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 4114 | |
| 4115 | vkCmdResetEvent(command_buffer, event, |
| 4116 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 4117 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 4118 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4119 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 4120 | nullptr, 0, nullptr); |
| 4121 | vkEndCommandBuffer(command_buffer); |
| 4122 | } |
| 4123 | { |
| 4124 | VkSubmitInfo submit_info{}; |
| 4125 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4126 | submit_info.commandBufferCount = 1; |
| 4127 | submit_info.pCommandBuffers = &command_buffer; |
| 4128 | submit_info.signalSemaphoreCount = 0; |
| 4129 | submit_info.pSignalSemaphores = nullptr; |
| 4130 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4131 | } |
| 4132 | { |
| 4133 | m_errorMonitor->SetDesiredFailureMsg( |
| 4134 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 4135 | "0x1 that is already in use by a " |
| 4136 | "command buffer."); |
| 4137 | vkSetEvent(m_device->device(), event); |
| 4138 | m_errorMonitor->VerifyFound(); |
| 4139 | } |
| 4140 | |
| 4141 | vkQueueWaitIdle(queue); |
| 4142 | |
| 4143 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 4144 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 4145 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4146 | } |
| 4147 | |
| 4148 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4149 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 4150 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 4151 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 4152 | "previously revealed a bug so running this positive test " |
| 4153 | "to prevent a regression."); |
| 4154 | m_errorMonitor->ExpectSuccess(); |
| 4155 | |
| 4156 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4157 | VkQueue queue = VK_NULL_HANDLE; |
| 4158 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4159 | 0, &queue); |
| 4160 | |
| 4161 | static const uint32_t NUM_OBJECTS = 2; |
| 4162 | static const uint32_t NUM_FRAMES = 3; |
| 4163 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 4164 | VkFence fences[NUM_OBJECTS] = {}; |
| 4165 | |
| 4166 | VkCommandPool cmd_pool; |
| 4167 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 4168 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4169 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4170 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4171 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 4172 | nullptr, &cmd_pool); |
| 4173 | ASSERT_VK_SUCCESS(err); |
| 4174 | |
| 4175 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 4176 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4177 | cmd_buf_info.commandPool = cmd_pool; |
| 4178 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4179 | cmd_buf_info.commandBufferCount = 1; |
| 4180 | |
| 4181 | VkFenceCreateInfo fence_ci = {}; |
| 4182 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4183 | fence_ci.pNext = nullptr; |
| 4184 | fence_ci.flags = 0; |
| 4185 | |
| 4186 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 4187 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 4188 | &cmd_buffers[i]); |
| 4189 | ASSERT_VK_SUCCESS(err); |
| 4190 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 4191 | ASSERT_VK_SUCCESS(err); |
| 4192 | } |
| 4193 | |
| 4194 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4195 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 4196 | // Create empty cmd buffer |
| 4197 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 4198 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4199 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4200 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 4201 | ASSERT_VK_SUCCESS(err); |
| 4202 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 4203 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4204 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4205 | VkSubmitInfo submit_info = {}; |
| 4206 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4207 | submit_info.commandBufferCount = 1; |
| 4208 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 4209 | // Submit cmd buffer and wait for fence |
| 4210 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 4211 | ASSERT_VK_SUCCESS(err); |
| 4212 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 4213 | UINT64_MAX); |
| 4214 | ASSERT_VK_SUCCESS(err); |
| 4215 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 4216 | ASSERT_VK_SUCCESS(err); |
| 4217 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4218 | } |
| 4219 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4220 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 4221 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 4222 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 4223 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4224 | } |
| 4225 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4226 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 4227 | |
| 4228 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4229 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 4230 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4231 | if ((m_device->queue_props.empty()) || |
| 4232 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4233 | return; |
| 4234 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4235 | m_errorMonitor->ExpectSuccess(); |
| 4236 | |
| 4237 | VkSemaphore semaphore; |
| 4238 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4239 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4240 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4241 | &semaphore); |
| 4242 | |
| 4243 | VkCommandPool command_pool; |
| 4244 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4245 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4246 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4247 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4248 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4249 | &command_pool); |
| 4250 | |
| 4251 | VkCommandBuffer command_buffer[2]; |
| 4252 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4253 | command_buffer_allocate_info.sType = |
| 4254 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4255 | command_buffer_allocate_info.commandPool = command_pool; |
| 4256 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4257 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4258 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4259 | command_buffer); |
| 4260 | |
| 4261 | VkQueue queue = VK_NULL_HANDLE; |
| 4262 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4263 | 1, &queue); |
| 4264 | |
| 4265 | { |
| 4266 | VkCommandBufferBeginInfo begin_info{}; |
| 4267 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4268 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4269 | |
| 4270 | vkCmdPipelineBarrier(command_buffer[0], |
| 4271 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4272 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4273 | 0, nullptr, 0, nullptr); |
| 4274 | |
| 4275 | VkViewport viewport{}; |
| 4276 | viewport.maxDepth = 1.0f; |
| 4277 | viewport.minDepth = 0.0f; |
| 4278 | viewport.width = 512; |
| 4279 | viewport.height = 512; |
| 4280 | viewport.x = 0; |
| 4281 | viewport.y = 0; |
| 4282 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4283 | vkEndCommandBuffer(command_buffer[0]); |
| 4284 | } |
| 4285 | { |
| 4286 | VkCommandBufferBeginInfo begin_info{}; |
| 4287 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4288 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4289 | |
| 4290 | VkViewport viewport{}; |
| 4291 | viewport.maxDepth = 1.0f; |
| 4292 | viewport.minDepth = 0.0f; |
| 4293 | viewport.width = 512; |
| 4294 | viewport.height = 512; |
| 4295 | viewport.x = 0; |
| 4296 | viewport.y = 0; |
| 4297 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4298 | vkEndCommandBuffer(command_buffer[1]); |
| 4299 | } |
| 4300 | { |
| 4301 | VkSubmitInfo submit_info{}; |
| 4302 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4303 | submit_info.commandBufferCount = 1; |
| 4304 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4305 | submit_info.signalSemaphoreCount = 1; |
| 4306 | submit_info.pSignalSemaphores = &semaphore; |
| 4307 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4308 | } |
| 4309 | { |
| 4310 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4311 | VkSubmitInfo submit_info{}; |
| 4312 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4313 | submit_info.commandBufferCount = 1; |
| 4314 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4315 | submit_info.waitSemaphoreCount = 1; |
| 4316 | submit_info.pWaitSemaphores = &semaphore; |
| 4317 | submit_info.pWaitDstStageMask = flags; |
| 4318 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4319 | } |
| 4320 | |
| 4321 | vkQueueWaitIdle(m_device->m_queue); |
| 4322 | |
| 4323 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4324 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4325 | &command_buffer[0]); |
| 4326 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4327 | |
| 4328 | m_errorMonitor->VerifyNotFound(); |
| 4329 | } |
| 4330 | |
| 4331 | // This is a positive test. No errors should be generated. |
| 4332 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 4333 | |
| 4334 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4335 | "submitted on separate queues, the second having a fence" |
| 4336 | "followed by a QueueWaitIdle."); |
| 4337 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4338 | if ((m_device->queue_props.empty()) || |
| 4339 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4340 | return; |
| 4341 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4342 | m_errorMonitor->ExpectSuccess(); |
| 4343 | |
| 4344 | VkFence fence; |
| 4345 | VkFenceCreateInfo fence_create_info{}; |
| 4346 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4347 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4348 | |
| 4349 | VkSemaphore semaphore; |
| 4350 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4351 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4352 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4353 | &semaphore); |
| 4354 | |
| 4355 | VkCommandPool command_pool; |
| 4356 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4357 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4358 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4359 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4360 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4361 | &command_pool); |
| 4362 | |
| 4363 | VkCommandBuffer command_buffer[2]; |
| 4364 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4365 | command_buffer_allocate_info.sType = |
| 4366 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4367 | command_buffer_allocate_info.commandPool = command_pool; |
| 4368 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4369 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4370 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4371 | command_buffer); |
| 4372 | |
| 4373 | VkQueue queue = VK_NULL_HANDLE; |
| 4374 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4375 | 1, &queue); |
| 4376 | |
| 4377 | { |
| 4378 | VkCommandBufferBeginInfo begin_info{}; |
| 4379 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4380 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4381 | |
| 4382 | vkCmdPipelineBarrier(command_buffer[0], |
| 4383 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4384 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4385 | 0, nullptr, 0, nullptr); |
| 4386 | |
| 4387 | VkViewport viewport{}; |
| 4388 | viewport.maxDepth = 1.0f; |
| 4389 | viewport.minDepth = 0.0f; |
| 4390 | viewport.width = 512; |
| 4391 | viewport.height = 512; |
| 4392 | viewport.x = 0; |
| 4393 | viewport.y = 0; |
| 4394 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4395 | vkEndCommandBuffer(command_buffer[0]); |
| 4396 | } |
| 4397 | { |
| 4398 | VkCommandBufferBeginInfo begin_info{}; |
| 4399 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4400 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4401 | |
| 4402 | VkViewport viewport{}; |
| 4403 | viewport.maxDepth = 1.0f; |
| 4404 | viewport.minDepth = 0.0f; |
| 4405 | viewport.width = 512; |
| 4406 | viewport.height = 512; |
| 4407 | viewport.x = 0; |
| 4408 | viewport.y = 0; |
| 4409 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4410 | vkEndCommandBuffer(command_buffer[1]); |
| 4411 | } |
| 4412 | { |
| 4413 | VkSubmitInfo submit_info{}; |
| 4414 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4415 | submit_info.commandBufferCount = 1; |
| 4416 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4417 | submit_info.signalSemaphoreCount = 1; |
| 4418 | submit_info.pSignalSemaphores = &semaphore; |
| 4419 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4420 | } |
| 4421 | { |
| 4422 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4423 | VkSubmitInfo submit_info{}; |
| 4424 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4425 | submit_info.commandBufferCount = 1; |
| 4426 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4427 | submit_info.waitSemaphoreCount = 1; |
| 4428 | submit_info.pWaitSemaphores = &semaphore; |
| 4429 | submit_info.pWaitDstStageMask = flags; |
| 4430 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4431 | } |
| 4432 | |
| 4433 | vkQueueWaitIdle(m_device->m_queue); |
| 4434 | |
| 4435 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4436 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4437 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4438 | &command_buffer[0]); |
| 4439 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4440 | |
| 4441 | m_errorMonitor->VerifyNotFound(); |
| 4442 | } |
| 4443 | |
| 4444 | // This is a positive test. No errors should be generated. |
| 4445 | TEST_F(VkLayerTest, |
| 4446 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 4447 | |
| 4448 | TEST_DESCRIPTION( |
| 4449 | "Two command buffers, each in a separate QueueSubmit call " |
| 4450 | "submitted on separate queues, the second having a fence" |
| 4451 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 4452 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4453 | if ((m_device->queue_props.empty()) || |
| 4454 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4455 | return; |
| 4456 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4457 | m_errorMonitor->ExpectSuccess(); |
| 4458 | |
| 4459 | VkFence fence; |
| 4460 | VkFenceCreateInfo fence_create_info{}; |
| 4461 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4462 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4463 | |
| 4464 | VkSemaphore semaphore; |
| 4465 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4466 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4467 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4468 | &semaphore); |
| 4469 | |
| 4470 | VkCommandPool command_pool; |
| 4471 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4472 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4473 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4474 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4475 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4476 | &command_pool); |
| 4477 | |
| 4478 | VkCommandBuffer command_buffer[2]; |
| 4479 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4480 | command_buffer_allocate_info.sType = |
| 4481 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4482 | command_buffer_allocate_info.commandPool = command_pool; |
| 4483 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4484 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4485 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4486 | command_buffer); |
| 4487 | |
| 4488 | VkQueue queue = VK_NULL_HANDLE; |
| 4489 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4490 | 1, &queue); |
| 4491 | |
| 4492 | { |
| 4493 | VkCommandBufferBeginInfo begin_info{}; |
| 4494 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4495 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4496 | |
| 4497 | vkCmdPipelineBarrier(command_buffer[0], |
| 4498 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4499 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4500 | 0, nullptr, 0, nullptr); |
| 4501 | |
| 4502 | VkViewport viewport{}; |
| 4503 | viewport.maxDepth = 1.0f; |
| 4504 | viewport.minDepth = 0.0f; |
| 4505 | viewport.width = 512; |
| 4506 | viewport.height = 512; |
| 4507 | viewport.x = 0; |
| 4508 | viewport.y = 0; |
| 4509 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4510 | vkEndCommandBuffer(command_buffer[0]); |
| 4511 | } |
| 4512 | { |
| 4513 | VkCommandBufferBeginInfo begin_info{}; |
| 4514 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4515 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4516 | |
| 4517 | VkViewport viewport{}; |
| 4518 | viewport.maxDepth = 1.0f; |
| 4519 | viewport.minDepth = 0.0f; |
| 4520 | viewport.width = 512; |
| 4521 | viewport.height = 512; |
| 4522 | viewport.x = 0; |
| 4523 | viewport.y = 0; |
| 4524 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4525 | vkEndCommandBuffer(command_buffer[1]); |
| 4526 | } |
| 4527 | { |
| 4528 | VkSubmitInfo submit_info{}; |
| 4529 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4530 | submit_info.commandBufferCount = 1; |
| 4531 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4532 | submit_info.signalSemaphoreCount = 1; |
| 4533 | submit_info.pSignalSemaphores = &semaphore; |
| 4534 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4535 | } |
| 4536 | { |
| 4537 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4538 | VkSubmitInfo submit_info{}; |
| 4539 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4540 | submit_info.commandBufferCount = 1; |
| 4541 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4542 | submit_info.waitSemaphoreCount = 1; |
| 4543 | submit_info.pWaitSemaphores = &semaphore; |
| 4544 | submit_info.pWaitDstStageMask = flags; |
| 4545 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4546 | } |
| 4547 | |
| 4548 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4549 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4550 | |
| 4551 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4552 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4553 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4554 | &command_buffer[0]); |
| 4555 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4556 | |
| 4557 | m_errorMonitor->VerifyNotFound(); |
| 4558 | } |
| 4559 | |
Chris Forbes | 0f8126b | 2016-06-20 17:48:22 +1200 | [diff] [blame] | 4560 | #if 0 |
| 4561 | TEST_F(VkLayerTest, TwoQueuesEnsureCorrectRetirementWithWorkStolen) { |
| 4562 | if ((m_device->queue_props.empty()) || |
| 4563 | (m_device->queue_props[0].queueCount < 2)) { |
| 4564 | printf("Test requires two queues, skipping\n"); |
| 4565 | return; |
| 4566 | } |
| 4567 | |
| 4568 | VkResult err; |
| 4569 | |
| 4570 | m_errorMonitor->ExpectSuccess(); |
| 4571 | |
| 4572 | VkQueue q0 = m_device->m_queue; |
| 4573 | VkQueue q1 = nullptr; |
| 4574 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, 1, &q1); |
| 4575 | ASSERT_NE(q1, nullptr); |
| 4576 | |
| 4577 | // An (empty) command buffer. We must have work in the first submission -- |
| 4578 | // the layer treats unfenced work differently from fenced work. |
| 4579 | VkCommandPoolCreateInfo cpci = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, nullptr, 0, 0 }; |
| 4580 | VkCommandPool pool; |
| 4581 | err = vkCreateCommandPool(m_device->device(), &cpci, nullptr, &pool); |
| 4582 | ASSERT_VK_SUCCESS(err); |
| 4583 | VkCommandBufferAllocateInfo cbai = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr, |
| 4584 | pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1 |
| 4585 | }; |
| 4586 | VkCommandBuffer cb; |
| 4587 | err = vkAllocateCommandBuffers(m_device->device(), &cbai, &cb); |
| 4588 | ASSERT_VK_SUCCESS(err); |
| 4589 | VkCommandBufferBeginInfo cbbi = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 4590 | 0, nullptr |
| 4591 | }; |
| 4592 | err = vkBeginCommandBuffer(cb, &cbbi); |
| 4593 | ASSERT_VK_SUCCESS(err); |
| 4594 | err = vkEndCommandBuffer(cb); |
| 4595 | ASSERT_VK_SUCCESS(err); |
| 4596 | |
| 4597 | // A semaphore |
| 4598 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; |
| 4599 | VkSemaphore s; |
| 4600 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s); |
| 4601 | ASSERT_VK_SUCCESS(err); |
| 4602 | |
| 4603 | // First submission, to q0 |
| 4604 | VkSubmitInfo s0 = { |
| 4605 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, |
| 4606 | 0, nullptr, nullptr, |
| 4607 | 1, &cb, |
| 4608 | 1, &s |
| 4609 | }; |
| 4610 | |
| 4611 | err = vkQueueSubmit(q0, 1, &s0, VK_NULL_HANDLE); |
| 4612 | ASSERT_VK_SUCCESS(err); |
| 4613 | |
| 4614 | // Second submission, to q1, waiting on s |
| 4615 | VkFlags waitmask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; // doesn't really matter what this value is. |
| 4616 | VkSubmitInfo s1 = { |
| 4617 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, |
| 4618 | 1, &s, &waitmask, |
| 4619 | 0, nullptr, |
| 4620 | 0, nullptr |
| 4621 | }; |
| 4622 | |
| 4623 | err = vkQueueSubmit(q1, 1, &s1, VK_NULL_HANDLE); |
| 4624 | ASSERT_VK_SUCCESS(err); |
| 4625 | |
| 4626 | // Wait for q0 idle |
| 4627 | err = vkQueueWaitIdle(q0); |
| 4628 | ASSERT_VK_SUCCESS(err); |
| 4629 | |
| 4630 | // Command buffer should have been completed (it was on q0); reset the pool. |
| 4631 | vkFreeCommandBuffers(m_device->device(), pool, 1, &cb); |
| 4632 | |
| 4633 | m_errorMonitor->VerifyNotFound(); |
| 4634 | |
| 4635 | // Force device completely idle and clean up resources |
| 4636 | vkDeviceWaitIdle(m_device->device()); |
| 4637 | vkDestroyCommandPool(m_device->device(), pool, nullptr); |
| 4638 | vkDestroySemaphore(m_device->device(), s, nullptr); |
| 4639 | } |
| 4640 | #endif |
| 4641 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4642 | // This is a positive test. No errors should be generated. |
| 4643 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 4644 | |
| 4645 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4646 | "submitted on separate queues, the second having a fence, " |
| 4647 | "followed by a WaitForFences call."); |
| 4648 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4649 | if ((m_device->queue_props.empty()) || |
| 4650 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4651 | return; |
| 4652 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4653 | m_errorMonitor->ExpectSuccess(); |
| 4654 | |
| 4655 | VkFence fence; |
| 4656 | VkFenceCreateInfo fence_create_info{}; |
| 4657 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4658 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4659 | |
| 4660 | VkSemaphore semaphore; |
| 4661 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4662 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4663 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4664 | &semaphore); |
| 4665 | |
| 4666 | VkCommandPool command_pool; |
| 4667 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4668 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4669 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4670 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4671 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4672 | &command_pool); |
| 4673 | |
| 4674 | VkCommandBuffer command_buffer[2]; |
| 4675 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4676 | command_buffer_allocate_info.sType = |
| 4677 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4678 | command_buffer_allocate_info.commandPool = command_pool; |
| 4679 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4680 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4681 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4682 | command_buffer); |
| 4683 | |
| 4684 | VkQueue queue = VK_NULL_HANDLE; |
| 4685 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4686 | 1, &queue); |
| 4687 | |
| 4688 | |
| 4689 | { |
| 4690 | VkCommandBufferBeginInfo begin_info{}; |
| 4691 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4692 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4693 | |
| 4694 | vkCmdPipelineBarrier(command_buffer[0], |
| 4695 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4696 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4697 | 0, nullptr, 0, nullptr); |
| 4698 | |
| 4699 | VkViewport viewport{}; |
| 4700 | viewport.maxDepth = 1.0f; |
| 4701 | viewport.minDepth = 0.0f; |
| 4702 | viewport.width = 512; |
| 4703 | viewport.height = 512; |
| 4704 | viewport.x = 0; |
| 4705 | viewport.y = 0; |
| 4706 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4707 | vkEndCommandBuffer(command_buffer[0]); |
| 4708 | } |
| 4709 | { |
| 4710 | VkCommandBufferBeginInfo begin_info{}; |
| 4711 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4712 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4713 | |
| 4714 | VkViewport viewport{}; |
| 4715 | viewport.maxDepth = 1.0f; |
| 4716 | viewport.minDepth = 0.0f; |
| 4717 | viewport.width = 512; |
| 4718 | viewport.height = 512; |
| 4719 | viewport.x = 0; |
| 4720 | viewport.y = 0; |
| 4721 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4722 | vkEndCommandBuffer(command_buffer[1]); |
| 4723 | } |
| 4724 | { |
| 4725 | VkSubmitInfo submit_info{}; |
| 4726 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4727 | submit_info.commandBufferCount = 1; |
| 4728 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4729 | submit_info.signalSemaphoreCount = 1; |
| 4730 | submit_info.pSignalSemaphores = &semaphore; |
| 4731 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4732 | } |
| 4733 | { |
| 4734 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4735 | VkSubmitInfo submit_info{}; |
| 4736 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4737 | submit_info.commandBufferCount = 1; |
| 4738 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4739 | submit_info.waitSemaphoreCount = 1; |
| 4740 | submit_info.pWaitSemaphores = &semaphore; |
| 4741 | submit_info.pWaitDstStageMask = flags; |
| 4742 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4743 | } |
| 4744 | |
| 4745 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4746 | |
| 4747 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4748 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4749 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4750 | &command_buffer[0]); |
| 4751 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4752 | |
| 4753 | m_errorMonitor->VerifyNotFound(); |
| 4754 | } |
| 4755 | |
| 4756 | // This is a positive test. No errors should be generated. |
| 4757 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 4758 | |
| 4759 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4760 | "on the same queue, sharing a signal/wait semaphore, the " |
| 4761 | "second having a fence, " |
| 4762 | "followed by a WaitForFences call."); |
| 4763 | |
| 4764 | m_errorMonitor->ExpectSuccess(); |
| 4765 | |
| 4766 | VkFence fence; |
| 4767 | VkFenceCreateInfo fence_create_info{}; |
| 4768 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4769 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4770 | |
| 4771 | VkSemaphore semaphore; |
| 4772 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4773 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4774 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4775 | &semaphore); |
| 4776 | |
| 4777 | VkCommandPool command_pool; |
| 4778 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4779 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4780 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4781 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4782 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4783 | &command_pool); |
| 4784 | |
| 4785 | VkCommandBuffer command_buffer[2]; |
| 4786 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4787 | command_buffer_allocate_info.sType = |
| 4788 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4789 | command_buffer_allocate_info.commandPool = command_pool; |
| 4790 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4791 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4792 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4793 | command_buffer); |
| 4794 | |
| 4795 | { |
| 4796 | VkCommandBufferBeginInfo begin_info{}; |
| 4797 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4798 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4799 | |
| 4800 | vkCmdPipelineBarrier(command_buffer[0], |
| 4801 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4802 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4803 | 0, nullptr, 0, nullptr); |
| 4804 | |
| 4805 | VkViewport viewport{}; |
| 4806 | viewport.maxDepth = 1.0f; |
| 4807 | viewport.minDepth = 0.0f; |
| 4808 | viewport.width = 512; |
| 4809 | viewport.height = 512; |
| 4810 | viewport.x = 0; |
| 4811 | viewport.y = 0; |
| 4812 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4813 | vkEndCommandBuffer(command_buffer[0]); |
| 4814 | } |
| 4815 | { |
| 4816 | VkCommandBufferBeginInfo begin_info{}; |
| 4817 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4818 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4819 | |
| 4820 | VkViewport viewport{}; |
| 4821 | viewport.maxDepth = 1.0f; |
| 4822 | viewport.minDepth = 0.0f; |
| 4823 | viewport.width = 512; |
| 4824 | viewport.height = 512; |
| 4825 | viewport.x = 0; |
| 4826 | viewport.y = 0; |
| 4827 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4828 | vkEndCommandBuffer(command_buffer[1]); |
| 4829 | } |
| 4830 | { |
| 4831 | VkSubmitInfo submit_info{}; |
| 4832 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4833 | submit_info.commandBufferCount = 1; |
| 4834 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4835 | submit_info.signalSemaphoreCount = 1; |
| 4836 | submit_info.pSignalSemaphores = &semaphore; |
| 4837 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4838 | } |
| 4839 | { |
| 4840 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4841 | VkSubmitInfo submit_info{}; |
| 4842 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4843 | submit_info.commandBufferCount = 1; |
| 4844 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4845 | submit_info.waitSemaphoreCount = 1; |
| 4846 | submit_info.pWaitSemaphores = &semaphore; |
| 4847 | submit_info.pWaitDstStageMask = flags; |
| 4848 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4849 | } |
| 4850 | |
| 4851 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4852 | |
| 4853 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4854 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4855 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4856 | &command_buffer[0]); |
| 4857 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4858 | |
| 4859 | m_errorMonitor->VerifyNotFound(); |
| 4860 | } |
| 4861 | |
| 4862 | // This is a positive test. No errors should be generated. |
| 4863 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 4864 | |
| 4865 | TEST_DESCRIPTION( |
| 4866 | "Two command buffers, each in a separate QueueSubmit call " |
| 4867 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 4868 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 4869 | |
| 4870 | m_errorMonitor->ExpectSuccess(); |
| 4871 | |
| 4872 | VkFence fence; |
| 4873 | VkFenceCreateInfo fence_create_info{}; |
| 4874 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4875 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4876 | |
| 4877 | VkCommandPool command_pool; |
| 4878 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4879 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4880 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4881 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4882 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4883 | &command_pool); |
| 4884 | |
| 4885 | VkCommandBuffer command_buffer[2]; |
| 4886 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4887 | command_buffer_allocate_info.sType = |
| 4888 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4889 | command_buffer_allocate_info.commandPool = command_pool; |
| 4890 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4891 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4892 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4893 | command_buffer); |
| 4894 | |
| 4895 | { |
| 4896 | VkCommandBufferBeginInfo begin_info{}; |
| 4897 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4898 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4899 | |
| 4900 | vkCmdPipelineBarrier(command_buffer[0], |
| 4901 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4902 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4903 | 0, nullptr, 0, nullptr); |
| 4904 | |
| 4905 | VkViewport viewport{}; |
| 4906 | viewport.maxDepth = 1.0f; |
| 4907 | viewport.minDepth = 0.0f; |
| 4908 | viewport.width = 512; |
| 4909 | viewport.height = 512; |
| 4910 | viewport.x = 0; |
| 4911 | viewport.y = 0; |
| 4912 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4913 | vkEndCommandBuffer(command_buffer[0]); |
| 4914 | } |
| 4915 | { |
| 4916 | VkCommandBufferBeginInfo begin_info{}; |
| 4917 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4918 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4919 | |
| 4920 | VkViewport viewport{}; |
| 4921 | viewport.maxDepth = 1.0f; |
| 4922 | viewport.minDepth = 0.0f; |
| 4923 | viewport.width = 512; |
| 4924 | viewport.height = 512; |
| 4925 | viewport.x = 0; |
| 4926 | viewport.y = 0; |
| 4927 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4928 | vkEndCommandBuffer(command_buffer[1]); |
| 4929 | } |
| 4930 | { |
| 4931 | VkSubmitInfo submit_info{}; |
| 4932 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4933 | submit_info.commandBufferCount = 1; |
| 4934 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4935 | submit_info.signalSemaphoreCount = 0; |
| 4936 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4937 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4938 | } |
| 4939 | { |
| 4940 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4941 | VkSubmitInfo submit_info{}; |
| 4942 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4943 | submit_info.commandBufferCount = 1; |
| 4944 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4945 | submit_info.waitSemaphoreCount = 0; |
| 4946 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4947 | submit_info.pWaitDstStageMask = flags; |
| 4948 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4949 | } |
| 4950 | |
| 4951 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 4952 | |
Mike Stroyan | cd1c3e5 | 2016-06-21 09:20:01 -0600 | [diff] [blame] | 4953 | VkResult err = |
| 4954 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4955 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4956 | |
| 4957 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4958 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4959 | &command_buffer[0]); |
| 4960 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4961 | |
| 4962 | m_errorMonitor->VerifyNotFound(); |
| 4963 | } |
| 4964 | |
| 4965 | // This is a positive test. No errors should be generated. |
| 4966 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 4967 | |
| 4968 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4969 | "on the same queue, the second having a fence, followed " |
| 4970 | "by a WaitForFences call."); |
| 4971 | |
| 4972 | m_errorMonitor->ExpectSuccess(); |
| 4973 | |
| 4974 | VkFence fence; |
| 4975 | VkFenceCreateInfo fence_create_info{}; |
| 4976 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4977 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4978 | |
| 4979 | VkCommandPool command_pool; |
| 4980 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4981 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4982 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4983 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4984 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4985 | &command_pool); |
| 4986 | |
| 4987 | VkCommandBuffer command_buffer[2]; |
| 4988 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4989 | command_buffer_allocate_info.sType = |
| 4990 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4991 | command_buffer_allocate_info.commandPool = command_pool; |
| 4992 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4993 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4994 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4995 | command_buffer); |
| 4996 | |
| 4997 | { |
| 4998 | VkCommandBufferBeginInfo begin_info{}; |
| 4999 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5000 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 5001 | |
| 5002 | vkCmdPipelineBarrier(command_buffer[0], |
| 5003 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 5004 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 5005 | 0, nullptr, 0, nullptr); |
| 5006 | |
| 5007 | VkViewport viewport{}; |
| 5008 | viewport.maxDepth = 1.0f; |
| 5009 | viewport.minDepth = 0.0f; |
| 5010 | viewport.width = 512; |
| 5011 | viewport.height = 512; |
| 5012 | viewport.x = 0; |
| 5013 | viewport.y = 0; |
| 5014 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 5015 | vkEndCommandBuffer(command_buffer[0]); |
| 5016 | } |
| 5017 | { |
| 5018 | VkCommandBufferBeginInfo begin_info{}; |
| 5019 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5020 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 5021 | |
| 5022 | VkViewport viewport{}; |
| 5023 | viewport.maxDepth = 1.0f; |
| 5024 | viewport.minDepth = 0.0f; |
| 5025 | viewport.width = 512; |
| 5026 | viewport.height = 512; |
| 5027 | viewport.x = 0; |
| 5028 | viewport.y = 0; |
| 5029 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 5030 | vkEndCommandBuffer(command_buffer[1]); |
| 5031 | } |
| 5032 | { |
| 5033 | VkSubmitInfo submit_info{}; |
| 5034 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5035 | submit_info.commandBufferCount = 1; |
| 5036 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 5037 | submit_info.signalSemaphoreCount = 0; |
| 5038 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 5039 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5040 | } |
| 5041 | { |
| 5042 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 5043 | VkSubmitInfo submit_info{}; |
| 5044 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5045 | submit_info.commandBufferCount = 1; |
| 5046 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 5047 | submit_info.waitSemaphoreCount = 0; |
| 5048 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 5049 | submit_info.pWaitDstStageMask = flags; |
| 5050 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 5051 | } |
| 5052 | |
| 5053 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 5054 | |
| 5055 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 5056 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 5057 | &command_buffer[0]); |
| 5058 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 5059 | |
| 5060 | m_errorMonitor->VerifyNotFound(); |
| 5061 | } |
| 5062 | |
| 5063 | // This is a positive test. No errors should be generated. |
| 5064 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 5065 | |
| 5066 | TEST_DESCRIPTION( |
| 5067 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 5068 | "QueueSubmit call followed by a WaitForFences call."); |
| 5069 | |
| 5070 | m_errorMonitor->ExpectSuccess(); |
| 5071 | |
| 5072 | VkFence fence; |
| 5073 | VkFenceCreateInfo fence_create_info{}; |
| 5074 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 5075 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 5076 | |
| 5077 | VkSemaphore semaphore; |
| 5078 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 5079 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 5080 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 5081 | &semaphore); |
| 5082 | |
| 5083 | VkCommandPool command_pool; |
| 5084 | VkCommandPoolCreateInfo pool_create_info{}; |
| 5085 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 5086 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 5087 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 5088 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 5089 | &command_pool); |
| 5090 | |
| 5091 | VkCommandBuffer command_buffer[2]; |
| 5092 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 5093 | command_buffer_allocate_info.sType = |
| 5094 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 5095 | command_buffer_allocate_info.commandPool = command_pool; |
| 5096 | command_buffer_allocate_info.commandBufferCount = 2; |
| 5097 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 5098 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 5099 | command_buffer); |
| 5100 | |
| 5101 | { |
| 5102 | VkCommandBufferBeginInfo begin_info{}; |
| 5103 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5104 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 5105 | |
| 5106 | vkCmdPipelineBarrier(command_buffer[0], |
| 5107 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 5108 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 5109 | 0, nullptr, 0, nullptr); |
| 5110 | |
| 5111 | VkViewport viewport{}; |
| 5112 | viewport.maxDepth = 1.0f; |
| 5113 | viewport.minDepth = 0.0f; |
| 5114 | viewport.width = 512; |
| 5115 | viewport.height = 512; |
| 5116 | viewport.x = 0; |
| 5117 | viewport.y = 0; |
| 5118 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 5119 | vkEndCommandBuffer(command_buffer[0]); |
| 5120 | } |
| 5121 | { |
| 5122 | VkCommandBufferBeginInfo begin_info{}; |
| 5123 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5124 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 5125 | |
| 5126 | VkViewport viewport{}; |
| 5127 | viewport.maxDepth = 1.0f; |
| 5128 | viewport.minDepth = 0.0f; |
| 5129 | viewport.width = 512; |
| 5130 | viewport.height = 512; |
| 5131 | viewport.x = 0; |
| 5132 | viewport.y = 0; |
| 5133 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 5134 | vkEndCommandBuffer(command_buffer[1]); |
| 5135 | } |
| 5136 | { |
| 5137 | VkSubmitInfo submit_info[2]; |
| 5138 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 5139 | |
| 5140 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5141 | submit_info[0].pNext = NULL; |
| 5142 | submit_info[0].commandBufferCount = 1; |
| 5143 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 5144 | submit_info[0].signalSemaphoreCount = 1; |
| 5145 | submit_info[0].pSignalSemaphores = &semaphore; |
| 5146 | submit_info[0].waitSemaphoreCount = 0; |
| 5147 | submit_info[0].pWaitSemaphores = NULL; |
| 5148 | submit_info[0].pWaitDstStageMask = 0; |
| 5149 | |
| 5150 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5151 | submit_info[1].pNext = NULL; |
| 5152 | submit_info[1].commandBufferCount = 1; |
| 5153 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 5154 | submit_info[1].waitSemaphoreCount = 1; |
| 5155 | submit_info[1].pWaitSemaphores = &semaphore; |
| 5156 | submit_info[1].pWaitDstStageMask = flags; |
| 5157 | submit_info[1].signalSemaphoreCount = 0; |
| 5158 | submit_info[1].pSignalSemaphores = NULL; |
| 5159 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 5160 | } |
| 5161 | |
| 5162 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 5163 | |
| 5164 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 5165 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 5166 | &command_buffer[0]); |
| 5167 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5168 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5169 | |
| 5170 | m_errorMonitor->VerifyNotFound(); |
| 5171 | } |
| 5172 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5173 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5174 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5175 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 5176 | "state is required but not correctly bound."); |
| 5177 | |
| 5178 | // Dynamic depth bias |
| 5179 | m_errorMonitor->SetDesiredFailureMsg( |
| 5180 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5181 | "Dynamic depth bias state not set for this command buffer"); |
| 5182 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5183 | BsoFailDepthBias); |
| 5184 | m_errorMonitor->VerifyFound(); |
| 5185 | } |
| 5186 | |
| 5187 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 5188 | TEST_DESCRIPTION( |
| 5189 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 5190 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5191 | |
| 5192 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5193 | m_errorMonitor->SetDesiredFailureMsg( |
| 5194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5195 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5196 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5197 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5198 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5199 | } |
| 5200 | |
| 5201 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 5202 | TEST_DESCRIPTION( |
| 5203 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 5204 | "state is required but not correctly bound."); |
| 5205 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5206 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5207 | m_errorMonitor->SetDesiredFailureMsg( |
| 5208 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5209 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5210 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5211 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5212 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5213 | } |
| 5214 | |
| 5215 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 5216 | TEST_DESCRIPTION( |
| 5217 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 5218 | "state is required but not correctly bound."); |
| 5219 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5220 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5221 | m_errorMonitor->SetDesiredFailureMsg( |
| 5222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5223 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5224 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5225 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5226 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5227 | } |
| 5228 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5229 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5230 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5231 | "Run a simple draw calls to validate failure when Blend Constants " |
| 5232 | "dynamic state is required but not correctly bound."); |
| 5233 | // Dynamic blend constant state |
| 5234 | m_errorMonitor->SetDesiredFailureMsg( |
| 5235 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5236 | "Dynamic blend constants state not set for this command buffer"); |
| 5237 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5238 | BsoFailBlend); |
| 5239 | m_errorMonitor->VerifyFound(); |
| 5240 | } |
| 5241 | |
| 5242 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 5243 | TEST_DESCRIPTION( |
| 5244 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5245 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5246 | if (!m_device->phy().features().depthBounds) { |
| 5247 | printf("Device does not support depthBounds test; skipped.\n"); |
| 5248 | return; |
| 5249 | } |
| 5250 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5251 | m_errorMonitor->SetDesiredFailureMsg( |
| 5252 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5253 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5254 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5255 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5256 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5257 | } |
| 5258 | |
| 5259 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 5260 | TEST_DESCRIPTION( |
| 5261 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 5262 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5263 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5264 | m_errorMonitor->SetDesiredFailureMsg( |
| 5265 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5266 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5267 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5268 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5269 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5270 | } |
| 5271 | |
| 5272 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 5273 | TEST_DESCRIPTION( |
| 5274 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 5275 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5276 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5277 | m_errorMonitor->SetDesiredFailureMsg( |
| 5278 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5279 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5280 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5281 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5282 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5283 | } |
| 5284 | |
| 5285 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 5286 | TEST_DESCRIPTION( |
| 5287 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 5288 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5289 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5290 | m_errorMonitor->SetDesiredFailureMsg( |
| 5291 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5292 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5294 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5295 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 5296 | } |
| 5297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5298 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5299 | m_errorMonitor->SetDesiredFailureMsg( |
| 5300 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5301 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 5302 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5303 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5305 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5306 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5307 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5308 | // We luck out b/c by default the framework creates CB w/ the |
| 5309 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5310 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5311 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 5312 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5313 | EndCommandBuffer(); |
| 5314 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5315 | // Bypass framework since it does the waits automatically |
| 5316 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5317 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 5318 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5319 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5320 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5321 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 5322 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5323 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5324 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5325 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5326 | submit_info.pSignalSemaphores = NULL; |
| 5327 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 5328 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5329 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5331 | // Cause validation error by re-submitting cmd buffer that should only be |
| 5332 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 5333 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5334 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5335 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5336 | } |
| 5337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5338 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5339 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5340 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5341 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5342 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5343 | "Unable to allocate 1 descriptors of " |
| 5344 | "type " |
| 5345 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5346 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5348 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 5351 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5352 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5353 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5354 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5355 | |
| 5356 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5358 | ds_pool_ci.pNext = NULL; |
| 5359 | ds_pool_ci.flags = 0; |
| 5360 | ds_pool_ci.maxSets = 1; |
| 5361 | ds_pool_ci.poolSizeCount = 1; |
| 5362 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5363 | |
| 5364 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5365 | err = |
| 5366 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5367 | ASSERT_VK_SUCCESS(err); |
| 5368 | |
| 5369 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | dsl_binding.binding = 0; |
| 5371 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5372 | dsl_binding.descriptorCount = 1; |
| 5373 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5374 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5375 | |
| 5376 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5377 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5378 | ds_layout_ci.pNext = NULL; |
| 5379 | ds_layout_ci.bindingCount = 1; |
| 5380 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5381 | |
| 5382 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5383 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5384 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5385 | ASSERT_VK_SUCCESS(err); |
| 5386 | |
| 5387 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5388 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5389 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5390 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5391 | alloc_info.descriptorPool = ds_pool; |
| 5392 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5393 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5394 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5395 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5396 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5397 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5398 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5399 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5400 | } |
| 5401 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5402 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 5403 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5405 | m_errorMonitor->SetDesiredFailureMsg( |
| 5406 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5407 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 5408 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5409 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5410 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5411 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5412 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5413 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5414 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5415 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5416 | |
| 5417 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5418 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5419 | ds_pool_ci.pNext = NULL; |
| 5420 | ds_pool_ci.maxSets = 1; |
| 5421 | ds_pool_ci.poolSizeCount = 1; |
| 5422 | ds_pool_ci.flags = 0; |
| 5423 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 5424 | // app can only call vkResetDescriptorPool on this pool.; |
| 5425 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5426 | |
| 5427 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | err = |
| 5429 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5430 | ASSERT_VK_SUCCESS(err); |
| 5431 | |
| 5432 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5433 | dsl_binding.binding = 0; |
| 5434 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5435 | dsl_binding.descriptorCount = 1; |
| 5436 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5437 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5438 | |
| 5439 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5440 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5441 | ds_layout_ci.pNext = NULL; |
| 5442 | ds_layout_ci.bindingCount = 1; |
| 5443 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5444 | |
| 5445 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5447 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5448 | ASSERT_VK_SUCCESS(err); |
| 5449 | |
| 5450 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5451 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5452 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5453 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5454 | alloc_info.descriptorPool = ds_pool; |
| 5455 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5456 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5457 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5458 | ASSERT_VK_SUCCESS(err); |
| 5459 | |
| 5460 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5461 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5462 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5463 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5464 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5465 | } |
| 5466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5467 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5468 | // Attempt to clear Descriptor Pool with bad object. |
| 5469 | // ObjectTracker should catch this. |
| 5470 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5471 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5472 | uint64_t fake_pool_handle = 0xbaad6001; |
| 5473 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 5474 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5475 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5476 | } |
| 5477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5479 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 5480 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5481 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5482 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5483 | |
| 5484 | uint64_t fake_set_handle = 0xbaad6001; |
| 5485 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5486 | VkResult err; |
| 5487 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5488 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 5489 | |
| 5490 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5491 | |
| 5492 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 5493 | layout_bindings[0].binding = 0; |
| 5494 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5495 | layout_bindings[0].descriptorCount = 1; |
| 5496 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 5497 | layout_bindings[0].pImmutableSamplers = NULL; |
| 5498 | |
| 5499 | VkDescriptorSetLayout descriptor_set_layout; |
| 5500 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 5501 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5502 | dslci.pNext = NULL; |
| 5503 | dslci.bindingCount = 1; |
| 5504 | dslci.pBindings = layout_bindings; |
| 5505 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 5506 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5507 | |
| 5508 | VkPipelineLayout pipeline_layout; |
| 5509 | VkPipelineLayoutCreateInfo plci = {}; |
| 5510 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5511 | plci.pNext = NULL; |
| 5512 | plci.setLayoutCount = 1; |
| 5513 | plci.pSetLayouts = &descriptor_set_layout; |
| 5514 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 5515 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5516 | |
| 5517 | BeginCommandBuffer(); |
| 5518 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5519 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5520 | m_errorMonitor->VerifyFound(); |
| 5521 | EndCommandBuffer(); |
| 5522 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 5523 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5524 | } |
| 5525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5526 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5527 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 5528 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5529 | uint64_t fake_layout_handle = 0xbaad6001; |
| 5530 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5531 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5532 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 5533 | |
| 5534 | VkPipelineLayout pipeline_layout; |
| 5535 | VkPipelineLayoutCreateInfo plci = {}; |
| 5536 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5537 | plci.pNext = NULL; |
| 5538 | plci.setLayoutCount = 1; |
| 5539 | plci.pSetLayouts = &bad_layout; |
| 5540 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 5541 | |
| 5542 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5543 | } |
| 5544 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5545 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
| 5546 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " |
| 5547 | "1) A uniform buffer update must have a valid buffer index." |
| 5548 | "2) When using an array of descriptors in a single WriteDescriptor," |
| 5549 | " the descriptor types and stageflags must all be the same." |
| 5550 | "3) Immutable Sampler state must match across descriptors"); |
| 5551 | |
| 5552 | const char *invalid_BufferInfo_ErrorMessage = |
| 5553 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " |
| 5554 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " |
| 5555 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; |
| 5556 | const char *stateFlag_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5557 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5558 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5559 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5560 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5561 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
| 5562 | |
| 5563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5564 | VkDescriptorPoolSize ds_type_count[4] = {}; |
| 5565 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5566 | ds_type_count[0].descriptorCount = 1; |
| 5567 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5568 | ds_type_count[1].descriptorCount = 1; |
| 5569 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5570 | ds_type_count[2].descriptorCount = 1; |
| 5571 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5572 | ds_type_count[3].descriptorCount = 1; |
| 5573 | |
| 5574 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5575 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5576 | ds_pool_ci.maxSets = 1; |
| 5577 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); |
| 5578 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 5579 | |
| 5580 | VkDescriptorPool ds_pool; |
| 5581 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5582 | ASSERT_VK_SUCCESS(err); |
| 5583 | |
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5584 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5585 | layout_binding[0].binding = 0; |
| 5586 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5587 | layout_binding[0].descriptorCount = 1; |
| 5588 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5589 | layout_binding[0].pImmutableSamplers = NULL; |
| 5590 | |
| 5591 | layout_binding[1].binding = 1; |
| 5592 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5593 | layout_binding[1].descriptorCount = 1; |
| 5594 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 5595 | layout_binding[1].pImmutableSamplers = NULL; |
| 5596 | |
| 5597 | VkSamplerCreateInfo sampler_ci = {}; |
| 5598 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5599 | sampler_ci.pNext = NULL; |
| 5600 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5601 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5602 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5603 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5604 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5605 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5606 | sampler_ci.mipLodBias = 1.0; |
| 5607 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5608 | sampler_ci.maxAnisotropy = 1; |
| 5609 | sampler_ci.compareEnable = VK_FALSE; |
| 5610 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5611 | sampler_ci.minLod = 1.0; |
| 5612 | sampler_ci.maxLod = 1.0; |
| 5613 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5614 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5615 | VkSampler sampler; |
| 5616 | |
| 5617 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5618 | ASSERT_VK_SUCCESS(err); |
| 5619 | |
| 5620 | layout_binding[2].binding = 2; |
| 5621 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5622 | layout_binding[2].descriptorCount = 1; |
| 5623 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 5624 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); |
| 5625 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5626 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5627 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5628 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); |
| 5629 | ds_layout_ci.pBindings = layout_binding; |
| 5630 | VkDescriptorSetLayout ds_layout; |
| 5631 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 5632 | ASSERT_VK_SUCCESS(err); |
| 5633 | |
| 5634 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5635 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5636 | alloc_info.descriptorSetCount = 1; |
| 5637 | alloc_info.descriptorPool = ds_pool; |
| 5638 | alloc_info.pSetLayouts = &ds_layout; |
| 5639 | VkDescriptorSet descriptorSet; |
| 5640 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 5641 | ASSERT_VK_SUCCESS(err); |
| 5642 | |
| 5643 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5644 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5645 | pipeline_layout_ci.pNext = NULL; |
| 5646 | pipeline_layout_ci.setLayoutCount = 1; |
| 5647 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5648 | |
| 5649 | VkPipelineLayout pipeline_layout; |
| 5650 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 5651 | ASSERT_VK_SUCCESS(err); |
| 5652 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5653 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5654 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5655 | descriptor_write.dstSet = descriptorSet; |
| 5656 | descriptor_write.dstBinding = 0; |
| 5657 | descriptor_write.descriptorCount = 1; |
| 5658 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5659 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5660 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5661 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5662 | m_errorMonitor->VerifyFound(); |
| 5663 | |
| 5664 | // Create a buffer to update the descriptor with |
| 5665 | uint32_t qfi = 0; |
| 5666 | VkBufferCreateInfo buffCI = {}; |
| 5667 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5668 | buffCI.size = 1024; |
| 5669 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5670 | buffCI.queueFamilyIndexCount = 1; |
| 5671 | buffCI.pQueueFamilyIndices = &qfi; |
| 5672 | |
| 5673 | VkBuffer dyub; |
| 5674 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5675 | ASSERT_VK_SUCCESS(err); |
| 5676 | VkDescriptorBufferInfo buffInfo = {}; |
| 5677 | buffInfo.buffer = dyub; |
| 5678 | buffInfo.offset = 0; |
| 5679 | buffInfo.range = 1024; |
| 5680 | |
| 5681 | descriptor_write.pBufferInfo = &buffInfo; |
| 5682 | descriptor_write.descriptorCount = 2; |
| 5683 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5684 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
| 5686 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5687 | m_errorMonitor->VerifyFound(); |
| 5688 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5689 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
| 5690 | // the third descriptor contains an immutable sampler |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5691 | descriptor_write.dstBinding = 1; |
| 5692 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5693 | |
| 5694 | |
| 5695 | // Make pImageInfo index non-null to avoid complaints of it missing |
| 5696 | VkDescriptorImageInfo imageInfo = {}; |
| 5697 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5698 | descriptor_write.pImageInfo = &imageInfo; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5699 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
| 5700 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5701 | m_errorMonitor->VerifyFound(); |
| 5702 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5703 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5704 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5705 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5706 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5707 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5708 | } |
| 5709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5710 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5711 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 5712 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5713 | // Create a valid cmd buffer |
| 5714 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5715 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 5716 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5717 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5718 | "Invalid VkPipeline Object 0xbaad6001"); |
| 5719 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5720 | BeginCommandBuffer(); |
| 5721 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5722 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 5723 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5724 | // Now issue a draw call with no pipeline bound |
| 5725 | m_errorMonitor->SetDesiredFailureMsg( |
| 5726 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5727 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5728 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5729 | BeginCommandBuffer(); |
| 5730 | Draw(1, 0, 0, 0); |
| 5731 | m_errorMonitor->VerifyFound(); |
| 5732 | // Finally same check once more but with Dispatch/Compute |
| 5733 | m_errorMonitor->SetDesiredFailureMsg( |
| 5734 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5735 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5736 | BeginCommandBuffer(); |
| 5737 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 5738 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5739 | } |
| 5740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5741 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 5742 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 5743 | // CommandBuffer |
| 5744 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5745 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5746 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5747 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5748 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5750 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5751 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5752 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5753 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5754 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5755 | |
| 5756 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5757 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5758 | ds_pool_ci.pNext = NULL; |
| 5759 | ds_pool_ci.maxSets = 1; |
| 5760 | ds_pool_ci.poolSizeCount = 1; |
| 5761 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5762 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5763 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5764 | err = |
| 5765 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5766 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5767 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5768 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5769 | dsl_binding.binding = 0; |
| 5770 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5771 | dsl_binding.descriptorCount = 1; |
| 5772 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5773 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5774 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5775 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5776 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5777 | ds_layout_ci.pNext = NULL; |
| 5778 | ds_layout_ci.bindingCount = 1; |
| 5779 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5780 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5781 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5782 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5783 | ASSERT_VK_SUCCESS(err); |
| 5784 | |
| 5785 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5786 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5787 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5788 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5789 | alloc_info.descriptorPool = ds_pool; |
| 5790 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5791 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5792 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5793 | ASSERT_VK_SUCCESS(err); |
| 5794 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5795 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5796 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5797 | pipeline_layout_ci.pNext = NULL; |
| 5798 | pipeline_layout_ci.setLayoutCount = 1; |
| 5799 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5800 | |
| 5801 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5802 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5803 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5804 | ASSERT_VK_SUCCESS(err); |
| 5805 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5806 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5807 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5808 | // 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] | 5809 | // on more devices |
| 5810 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5811 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5812 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5813 | VkPipelineObj pipe(m_device); |
| 5814 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5815 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5816 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5817 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5818 | |
| 5819 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5821 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5822 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5823 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5824 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5825 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5826 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5827 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5828 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5829 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5830 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5831 | } |
| 5832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5833 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5834 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5835 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5836 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5838 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 5839 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5840 | |
| 5841 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5842 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5843 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5844 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5845 | |
| 5846 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5847 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5848 | ds_pool_ci.pNext = NULL; |
| 5849 | ds_pool_ci.maxSets = 1; |
| 5850 | ds_pool_ci.poolSizeCount = 1; |
| 5851 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5852 | |
| 5853 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | err = |
| 5855 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5856 | ASSERT_VK_SUCCESS(err); |
| 5857 | |
| 5858 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | dsl_binding.binding = 0; |
| 5860 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5861 | dsl_binding.descriptorCount = 1; |
| 5862 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5863 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5864 | |
| 5865 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5866 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5867 | ds_layout_ci.pNext = NULL; |
| 5868 | ds_layout_ci.bindingCount = 1; |
| 5869 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5870 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5871 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5872 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5873 | ASSERT_VK_SUCCESS(err); |
| 5874 | |
| 5875 | VkDescriptorSet descriptorSet; |
| 5876 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5877 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5878 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5879 | alloc_info.descriptorPool = ds_pool; |
| 5880 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5882 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5883 | ASSERT_VK_SUCCESS(err); |
| 5884 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5885 | VkBufferView view = |
| 5886 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5887 | VkWriteDescriptorSet descriptor_write; |
| 5888 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5889 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5890 | descriptor_write.dstSet = descriptorSet; |
| 5891 | descriptor_write.dstBinding = 0; |
| 5892 | descriptor_write.descriptorCount = 1; |
| 5893 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5894 | descriptor_write.pTexelBufferView = &view; |
| 5895 | |
| 5896 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5897 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5898 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5899 | |
| 5900 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5901 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5902 | } |
| 5903 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5904 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 5905 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 5906 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5907 | // 1. No dynamicOffset supplied |
| 5908 | // 2. Too many dynamicOffsets supplied |
| 5909 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5910 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5911 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5912 | " requires 1 dynamicOffsets, but only " |
| 5913 | "0 dynamicOffsets are left in " |
| 5914 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5915 | |
| 5916 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5917 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5919 | |
| 5920 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5921 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5922 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5923 | |
| 5924 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5925 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5926 | ds_pool_ci.pNext = NULL; |
| 5927 | ds_pool_ci.maxSets = 1; |
| 5928 | ds_pool_ci.poolSizeCount = 1; |
| 5929 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5930 | |
| 5931 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5932 | err = |
| 5933 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5934 | ASSERT_VK_SUCCESS(err); |
| 5935 | |
| 5936 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | dsl_binding.binding = 0; |
| 5938 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5939 | dsl_binding.descriptorCount = 1; |
| 5940 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5941 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5942 | |
| 5943 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5944 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5945 | ds_layout_ci.pNext = NULL; |
| 5946 | ds_layout_ci.bindingCount = 1; |
| 5947 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5948 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5950 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5951 | ASSERT_VK_SUCCESS(err); |
| 5952 | |
| 5953 | VkDescriptorSet descriptorSet; |
| 5954 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5955 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5956 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5957 | alloc_info.descriptorPool = ds_pool; |
| 5958 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5959 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5960 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5961 | ASSERT_VK_SUCCESS(err); |
| 5962 | |
| 5963 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5964 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5965 | pipeline_layout_ci.pNext = NULL; |
| 5966 | pipeline_layout_ci.setLayoutCount = 1; |
| 5967 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5968 | |
| 5969 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5970 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5971 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5972 | ASSERT_VK_SUCCESS(err); |
| 5973 | |
| 5974 | // Create a buffer to update the descriptor with |
| 5975 | uint32_t qfi = 0; |
| 5976 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5978 | buffCI.size = 1024; |
| 5979 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5980 | buffCI.queueFamilyIndexCount = 1; |
| 5981 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5982 | |
| 5983 | VkBuffer dyub; |
| 5984 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5985 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5986 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 5987 | // error |
| 5988 | VkMemoryAllocateInfo mem_alloc = {}; |
| 5989 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5990 | mem_alloc.pNext = NULL; |
| 5991 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 5992 | mem_alloc.memoryTypeIndex = 0; |
| 5993 | |
| 5994 | VkMemoryRequirements memReqs; |
| 5995 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 5996 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 5997 | 0); |
| 5998 | if (!pass) { |
| 5999 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 6000 | return; |
| 6001 | } |
| 6002 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6003 | VkDeviceMemory mem; |
| 6004 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 6005 | ASSERT_VK_SUCCESS(err); |
| 6006 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 6007 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6008 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6009 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6010 | buffInfo.buffer = dyub; |
| 6011 | buffInfo.offset = 0; |
| 6012 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6013 | |
| 6014 | VkWriteDescriptorSet descriptor_write; |
| 6015 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6016 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6017 | descriptor_write.dstSet = descriptorSet; |
| 6018 | descriptor_write.dstBinding = 0; |
| 6019 | descriptor_write.descriptorCount = 1; |
| 6020 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 6021 | descriptor_write.pBufferInfo = &buffInfo; |
| 6022 | |
| 6023 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6024 | |
| 6025 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6026 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6027 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6028 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6029 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6030 | uint32_t pDynOff[2] = {512, 756}; |
| 6031 | // 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] | 6032 | m_errorMonitor->SetDesiredFailureMsg( |
| 6033 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6034 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6036 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6037 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6038 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6039 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6040 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6041 | " dynamic offset 512 combined with " |
| 6042 | "offset 0 and range 1024 that " |
| 6043 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6044 | // Create PSO to be used for draw-time errors below |
| 6045 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6046 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6047 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6048 | "out gl_PerVertex { \n" |
| 6049 | " vec4 gl_Position;\n" |
| 6050 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6051 | "void main(){\n" |
| 6052 | " gl_Position = vec4(1);\n" |
| 6053 | "}\n"; |
| 6054 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6055 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6056 | "\n" |
| 6057 | "layout(location=0) out vec4 x;\n" |
| 6058 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6059 | "void main(){\n" |
| 6060 | " x = vec4(bar.y);\n" |
| 6061 | "}\n"; |
| 6062 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6063 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6064 | VkPipelineObj pipe(m_device); |
| 6065 | pipe.AddShader(&vs); |
| 6066 | pipe.AddShader(&fs); |
| 6067 | pipe.AddColorAttachment(); |
| 6068 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6069 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6070 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6071 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6072 | // This update should succeed, but offset size of 512 will overstep buffer |
| 6073 | // /w range 1024 & size 1024 |
| 6074 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6075 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6076 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6077 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6078 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6079 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6080 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 6081 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6082 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6083 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6084 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6085 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6086 | } |
| 6087 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6088 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6089 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6090 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6091 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6092 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6093 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6094 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6095 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6096 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6097 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6098 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 6099 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 6100 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6101 | // |
| 6102 | // Check for invalid push constant ranges in pipeline layouts. |
| 6103 | // |
| 6104 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6105 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6106 | char const *msg; |
| 6107 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6108 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6109 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 6110 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 6111 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 6112 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6113 | "size 0."}, |
| 6114 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 6115 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6116 | "size 1."}, |
| 6117 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 6118 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6119 | "size 1."}, |
| 6120 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 6121 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6122 | "size 0."}, |
| 6123 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 6124 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6125 | "offset 1. Offset must"}, |
| 6126 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 6127 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 6128 | "with offset "}, |
| 6129 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 6130 | "vkCreatePipelineLayout() call has push constants " |
| 6131 | "index 0 with offset "}, |
| 6132 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 6133 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 6134 | "with offset "}, |
| 6135 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 6136 | "vkCreatePipelineLayout() call has push " |
| 6137 | "constants index 0 with offset "}, |
| 6138 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 6139 | "vkCreatePipelineLayout() call has push " |
| 6140 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6141 | }}; |
| 6142 | |
| 6143 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6144 | for (const auto &iter : range_tests) { |
| 6145 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6146 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6147 | iter.msg); |
| 6148 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6149 | NULL, &pipeline_layout); |
| 6150 | m_errorMonitor->VerifyFound(); |
| 6151 | if (VK_SUCCESS == err) { |
| 6152 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6153 | } |
| 6154 | } |
| 6155 | |
| 6156 | // Check for invalid stage flag |
| 6157 | pc_range.offset = 0; |
| 6158 | pc_range.size = 16; |
| 6159 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6160 | m_errorMonitor->SetDesiredFailureMsg( |
| 6161 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6162 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6163 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6164 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6165 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6166 | if (VK_SUCCESS == err) { |
| 6167 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6168 | } |
| 6169 | |
| 6170 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6171 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6172 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6173 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6174 | char const *msg; |
| 6175 | }; |
| 6176 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6177 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6178 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6179 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6180 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6181 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6182 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6183 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 6184 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 6185 | { |
| 6186 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6187 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6188 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6189 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6190 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 6191 | "vkCreatePipelineLayout() call has push constants with " |
| 6192 | "overlapping " |
| 6193 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 6194 | }, |
| 6195 | { |
| 6196 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6197 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6198 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6199 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6200 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6201 | "vkCreatePipelineLayout() call has push constants with " |
| 6202 | "overlapping " |
| 6203 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 6204 | }, |
| 6205 | { |
| 6206 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6207 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6208 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6209 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6210 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6211 | "vkCreatePipelineLayout() call has push constants with " |
| 6212 | "overlapping " |
| 6213 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 6214 | }, |
| 6215 | { |
| 6216 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6217 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 6218 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 6219 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 6220 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 6221 | "vkCreatePipelineLayout() call has push constants with " |
| 6222 | "overlapping " |
| 6223 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 6224 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6225 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6226 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6227 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6228 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 6229 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6230 | iter.msg); |
| 6231 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6232 | NULL, &pipeline_layout); |
| 6233 | m_errorMonitor->VerifyFound(); |
| 6234 | if (VK_SUCCESS == err) { |
| 6235 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6236 | } |
| 6237 | } |
| 6238 | |
| 6239 | // Run some positive tests to make sure overlap checking in the layer is OK |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6240 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 6241 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6242 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6243 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6244 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 6245 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 6246 | ""}, |
| 6247 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 6248 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 6249 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 6250 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 6251 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6252 | ""}}}; |
| 6253 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6254 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 6255 | m_errorMonitor->ExpectSuccess(); |
| 6256 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6257 | NULL, &pipeline_layout); |
| 6258 | m_errorMonitor->VerifyNotFound(); |
| 6259 | if (VK_SUCCESS == err) { |
| 6260 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6261 | } |
| 6262 | } |
| 6263 | |
| 6264 | // |
| 6265 | // CmdPushConstants tests |
| 6266 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6267 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6268 | |
| 6269 | // Check for invalid offset and size and if range is within layout range(s) |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6270 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 6271 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 6272 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 6273 | "must be greater than zero and a multiple of 4."}, |
| 6274 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 6275 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 6276 | "must be greater than zero and a multiple of 4."}, |
| 6277 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 6278 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 6279 | "must be greater than zero and a multiple of 4."}, |
| 6280 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 6281 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 6282 | "Offset must be a multiple of 4."}, |
| 6283 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 6284 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 6285 | "Offset must be a multiple of 4."}, |
| 6286 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 6287 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 6288 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6289 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 6290 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 6291 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6292 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 6293 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 6294 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6295 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 6296 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 6297 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6298 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 6299 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 6300 | "any of the ranges in pipeline layout"}, |
| 6301 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 6302 | 0, 16}, |
| 6303 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 6304 | "any of the ranges in pipeline layout"}, |
| 6305 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6306 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6307 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6308 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6309 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6310 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6311 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6312 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6313 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6314 | "vkCmdPushConstants() call has push constants with offset "}, |
| 6315 | }}; |
| 6316 | |
| 6317 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6318 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6319 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6320 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6321 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6322 | pipeline_layout_ci.pushConstantRangeCount = |
| 6323 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6324 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6325 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6326 | &pipeline_layout); |
| 6327 | ASSERT_VK_SUCCESS(err); |
| 6328 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6329 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6330 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6331 | iter.msg); |
| 6332 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6333 | iter.range.stageFlags, iter.range.offset, |
| 6334 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6335 | m_errorMonitor->VerifyFound(); |
| 6336 | } |
| 6337 | |
| 6338 | // Check for invalid stage flag |
| 6339 | m_errorMonitor->SetDesiredFailureMsg( |
| 6340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6341 | "vkCmdPushConstants() call has no stageFlags set."); |
| 6342 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6343 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6344 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6345 | EndCommandBuffer(); |
| 6346 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 6347 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6348 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6349 | // overlapping range tests with cmd |
| 6350 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 6351 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 6352 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 6353 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6354 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6355 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 6356 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6357 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 6358 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 6359 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6360 | }}; |
| 6361 | const VkPushConstantRange pc_range3[] = { |
| 6362 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 6363 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 6364 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6365 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 6366 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 6367 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 6368 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 6369 | }; |
| 6370 | pipeline_layout_ci.pushConstantRangeCount = |
| 6371 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 6372 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 6373 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6374 | &pipeline_layout); |
| 6375 | ASSERT_VK_SUCCESS(err); |
| 6376 | BeginCommandBuffer(); |
| 6377 | for (const auto &iter : cmd_overlap_tests) { |
| 6378 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6379 | iter.msg); |
| 6380 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 6381 | iter.range.stageFlags, iter.range.offset, |
| 6382 | iter.range.size, dummy_values); |
| 6383 | m_errorMonitor->VerifyFound(); |
| 6384 | } |
| 6385 | EndCommandBuffer(); |
| 6386 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 6387 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6388 | |
| 6389 | // positive overlapping range tests with cmd |
| 6390 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 6391 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 6392 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 6393 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 6394 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 6395 | }}; |
| 6396 | const VkPushConstantRange pc_range4[] = { |
| 6397 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 6398 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 6399 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 6400 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6401 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 6402 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 6403 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 6404 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 6405 | }; |
| 6406 | pipeline_layout_ci.pushConstantRangeCount = |
| 6407 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 6408 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 6409 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6410 | &pipeline_layout); |
| 6411 | ASSERT_VK_SUCCESS(err); |
| 6412 | BeginCommandBuffer(); |
| 6413 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 6414 | m_errorMonitor->ExpectSuccess(); |
| 6415 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 6416 | iter.range.stageFlags, iter.range.offset, |
| 6417 | iter.range.size, dummy_values); |
| 6418 | m_errorMonitor->VerifyNotFound(); |
| 6419 | } |
| 6420 | EndCommandBuffer(); |
| 6421 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6422 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6423 | } |
| 6424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6425 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6426 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6427 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6428 | |
| 6429 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6430 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6431 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6432 | |
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 6433 | const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 6434 | VkImageTiling tiling; |
| 6435 | VkFormatProperties format_properties; |
| 6436 | vkGetPhysicalDeviceFormatProperties(gpu(), tex_format, &format_properties); |
| 6437 | if (format_properties.linearTilingFeatures & |
| 6438 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { |
| 6439 | tiling = VK_IMAGE_TILING_LINEAR; |
| 6440 | } else if (format_properties.optimalTilingFeatures & |
| 6441 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { |
| 6442 | tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6443 | } else { |
| 6444 | printf("Device does not support VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; " |
| 6445 | "skipped.\n"); |
| 6446 | return; |
| 6447 | } |
| 6448 | |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6449 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 6450 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6451 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6452 | ds_type_count[0].descriptorCount = 10; |
| 6453 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6454 | ds_type_count[1].descriptorCount = 2; |
| 6455 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 6456 | ds_type_count[2].descriptorCount = 2; |
| 6457 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6458 | ds_type_count[3].descriptorCount = 5; |
| 6459 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 6460 | // type |
| 6461 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 6462 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 6463 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6464 | |
| 6465 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6466 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6467 | ds_pool_ci.pNext = NULL; |
| 6468 | ds_pool_ci.maxSets = 5; |
| 6469 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 6470 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6471 | |
| 6472 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6473 | err = |
| 6474 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6475 | ASSERT_VK_SUCCESS(err); |
| 6476 | |
| 6477 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 6478 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6479 | dsl_binding[0].binding = 0; |
| 6480 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6481 | dsl_binding[0].descriptorCount = 5; |
| 6482 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6483 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6484 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6485 | // Create layout identical to set0 layout but w/ different stageFlags |
| 6486 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6487 | dsl_fs_stage_only.binding = 0; |
| 6488 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6489 | dsl_fs_stage_only.descriptorCount = 5; |
| 6490 | dsl_fs_stage_only.stageFlags = |
| 6491 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 6492 | // bind time |
| 6493 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6494 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6495 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6496 | ds_layout_ci.pNext = NULL; |
| 6497 | ds_layout_ci.bindingCount = 1; |
| 6498 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6499 | static const uint32_t NUM_LAYOUTS = 4; |
| 6500 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6501 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6502 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 6503 | // layout for error case |
| 6504 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6505 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6506 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6507 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6509 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6510 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6511 | dsl_binding[0].binding = 0; |
| 6512 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6513 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6514 | dsl_binding[1].binding = 1; |
| 6515 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 6516 | dsl_binding[1].descriptorCount = 2; |
| 6517 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6518 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6519 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6520 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6521 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6522 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6523 | ASSERT_VK_SUCCESS(err); |
| 6524 | dsl_binding[0].binding = 0; |
| 6525 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6526 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6527 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6528 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6529 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6530 | ASSERT_VK_SUCCESS(err); |
| 6531 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6532 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6534 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6535 | ASSERT_VK_SUCCESS(err); |
| 6536 | |
| 6537 | static const uint32_t NUM_SETS = 4; |
| 6538 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 6539 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6540 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6541 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6542 | alloc_info.descriptorPool = ds_pool; |
| 6543 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6544 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6545 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6546 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6547 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6548 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6549 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6550 | err = |
| 6551 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6552 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6553 | |
| 6554 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6555 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6556 | pipeline_layout_ci.pNext = NULL; |
| 6557 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 6558 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6559 | |
| 6560 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6561 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6562 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6563 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6564 | // Create pipelineLayout with only one setLayout |
| 6565 | pipeline_layout_ci.setLayoutCount = 1; |
| 6566 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6567 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6568 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6569 | ASSERT_VK_SUCCESS(err); |
| 6570 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 6571 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 6572 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6573 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6574 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6575 | ASSERT_VK_SUCCESS(err); |
| 6576 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 6577 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 6578 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6579 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6580 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6581 | ASSERT_VK_SUCCESS(err); |
| 6582 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 6583 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 6584 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6586 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6587 | ASSERT_VK_SUCCESS(err); |
| 6588 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 6589 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 6590 | pl_bad_s0[0] = ds_layout_fs_only; |
| 6591 | pl_bad_s0[1] = ds_layout[1]; |
| 6592 | pipeline_layout_ci.setLayoutCount = 2; |
| 6593 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 6594 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6595 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6596 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6597 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6598 | |
| 6599 | // Create a buffer to update the descriptor with |
| 6600 | uint32_t qfi = 0; |
| 6601 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6602 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6603 | buffCI.size = 1024; |
| 6604 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 6605 | buffCI.queueFamilyIndexCount = 1; |
| 6606 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6607 | |
| 6608 | VkBuffer dyub; |
| 6609 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 6610 | ASSERT_VK_SUCCESS(err); |
| 6611 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6612 | static const uint32_t NUM_BUFFS = 5; |
| 6613 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6615 | buffInfo[i].buffer = dyub; |
| 6616 | buffInfo[i].offset = 0; |
| 6617 | buffInfo[i].range = 1024; |
| 6618 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6619 | VkImage image; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6620 | const int32_t tex_width = 32; |
| 6621 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6622 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6623 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6624 | image_create_info.pNext = NULL; |
| 6625 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6626 | image_create_info.format = tex_format; |
| 6627 | image_create_info.extent.width = tex_width; |
| 6628 | image_create_info.extent.height = tex_height; |
| 6629 | image_create_info.extent.depth = 1; |
| 6630 | image_create_info.mipLevels = 1; |
| 6631 | image_create_info.arrayLayers = 1; |
| 6632 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 6633 | image_create_info.tiling = tiling; |
| 6634 | image_create_info.usage = |
| 6635 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6636 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6637 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 6638 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6640 | VkMemoryRequirements memReqs; |
| 6641 | VkDeviceMemory imageMem; |
| 6642 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6643 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6644 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6645 | memAlloc.pNext = NULL; |
| 6646 | memAlloc.allocationSize = 0; |
| 6647 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6648 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 6649 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | pass = |
| 6651 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6652 | ASSERT_TRUE(pass); |
| 6653 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 6654 | ASSERT_VK_SUCCESS(err); |
| 6655 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 6656 | ASSERT_VK_SUCCESS(err); |
| 6657 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6658 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6659 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 6660 | image_view_create_info.image = image; |
| 6661 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6662 | image_view_create_info.format = tex_format; |
| 6663 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6664 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6665 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6666 | image_view_create_info.subresourceRange.aspectMask = |
| 6667 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6668 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6669 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6670 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6671 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6672 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6673 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6674 | imageInfo[0].imageView = view; |
| 6675 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6676 | imageInfo[1].imageView = view; |
| 6677 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6678 | imageInfo[2].imageView = view; |
| 6679 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6680 | imageInfo[3].imageView = view; |
| 6681 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6682 | |
| 6683 | static const uint32_t NUM_SET_UPDATES = 3; |
| 6684 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 6685 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6686 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 6687 | descriptor_write[0].dstBinding = 0; |
| 6688 | descriptor_write[0].descriptorCount = 5; |
| 6689 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6690 | descriptor_write[0].pBufferInfo = buffInfo; |
| 6691 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6692 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 6693 | descriptor_write[1].dstBinding = 0; |
| 6694 | descriptor_write[1].descriptorCount = 2; |
| 6695 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6696 | descriptor_write[1].pImageInfo = imageInfo; |
| 6697 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6698 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 6699 | descriptor_write[2].dstBinding = 1; |
| 6700 | descriptor_write[2].descriptorCount = 2; |
| 6701 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6702 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6703 | |
| 6704 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6705 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6706 | // Create PSO to be used for draw-time errors below |
| 6707 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6708 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6709 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6710 | "out gl_PerVertex {\n" |
| 6711 | " vec4 gl_Position;\n" |
| 6712 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6713 | "void main(){\n" |
| 6714 | " gl_Position = vec4(1);\n" |
| 6715 | "}\n"; |
| 6716 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6717 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6718 | "\n" |
| 6719 | "layout(location=0) out vec4 x;\n" |
| 6720 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6721 | "void main(){\n" |
| 6722 | " x = vec4(bar.y);\n" |
| 6723 | "}\n"; |
| 6724 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6725 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6726 | VkPipelineObj pipe(m_device); |
| 6727 | pipe.AddShader(&vs); |
| 6728 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6729 | pipe.AddColorAttachment(); |
| 6730 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6731 | |
| 6732 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6733 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6734 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6735 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6736 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 6737 | // of PSO |
| 6738 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 6739 | // cmd_pipeline.c |
| 6740 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 6741 | // cmd_bind_graphics_pipeline() |
| 6742 | // TODO : Want to cause various binding incompatibility issues here to test |
| 6743 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6744 | // First cause various verify_layout_compatibility() fails |
| 6745 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6746 | // verify_set_layout_compatibility fail cases: |
| 6747 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6748 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6749 | " due to: invalid VkPipelineLayout "); |
| 6750 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6751 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6752 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 6753 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6754 | m_errorMonitor->VerifyFound(); |
| 6755 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6756 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6757 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6758 | " attempting to bind set to index 1"); |
| 6759 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6760 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 6761 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6762 | m_errorMonitor->VerifyFound(); |
| 6763 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6764 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6765 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 6766 | // descriptors |
| 6767 | m_errorMonitor->SetDesiredFailureMsg( |
| 6768 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6769 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6770 | vkCmdBindDescriptorSets( |
| 6771 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6772 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6773 | m_errorMonitor->VerifyFound(); |
| 6774 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6775 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 6776 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6777 | m_errorMonitor->SetDesiredFailureMsg( |
| 6778 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6779 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6780 | vkCmdBindDescriptorSets( |
| 6781 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6782 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6783 | m_errorMonitor->VerifyFound(); |
| 6784 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6785 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 6786 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6787 | m_errorMonitor->SetDesiredFailureMsg( |
| 6788 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6789 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6790 | vkCmdBindDescriptorSets( |
| 6791 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6792 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6793 | m_errorMonitor->VerifyFound(); |
| 6794 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6795 | // Cause INFO messages due to disturbing previously bound Sets |
| 6796 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6797 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6798 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6799 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6800 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6801 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6802 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6803 | " previously bound as set #0 was disturbed "); |
| 6804 | vkCmdBindDescriptorSets( |
| 6805 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6806 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6807 | m_errorMonitor->VerifyFound(); |
| 6808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6809 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6810 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6811 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6812 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6813 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6814 | " newly bound as set #0 so set #1 and " |
| 6815 | "any subsequent sets were disturbed "); |
| 6816 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6817 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6818 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6819 | m_errorMonitor->VerifyFound(); |
| 6820 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6821 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6822 | // 1. Error due to not binding required set (we actually use same code as |
| 6823 | // above to disturb set0) |
| 6824 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6825 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6826 | 2, &descriptorSet[0], 0, NULL); |
| 6827 | vkCmdBindDescriptorSets( |
| 6828 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6829 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 6830 | m_errorMonitor->SetDesiredFailureMsg( |
| 6831 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6832 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6833 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6834 | m_errorMonitor->VerifyFound(); |
| 6835 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6836 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6837 | // 2. Error due to bound set not being compatible with PSO's |
| 6838 | // VkPipelineLayout (diff stageFlags in this case) |
| 6839 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6840 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6841 | 2, &descriptorSet[0], 0, NULL); |
| 6842 | m_errorMonitor->SetDesiredFailureMsg( |
| 6843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6844 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6845 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6846 | m_errorMonitor->VerifyFound(); |
| 6847 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6848 | // Remaining clean-up |
| 6849 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6850 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6851 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 6852 | } |
| 6853 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 6854 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 6855 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6856 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6857 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6858 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6859 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 6860 | vkDestroyImage(m_device->device(), image, NULL); |
| 6861 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6862 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6864 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6866 | m_errorMonitor->SetDesiredFailureMsg( |
| 6867 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6868 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6869 | |
| 6870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6871 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6872 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6873 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6874 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6875 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6876 | } |
| 6877 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6878 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 6879 | VkResult err; |
| 6880 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6882 | m_errorMonitor->SetDesiredFailureMsg( |
| 6883 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 6884 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6885 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6887 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6888 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6889 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6890 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6891 | cmd.commandPool = m_commandPool; |
| 6892 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6893 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6894 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6895 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6896 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6897 | |
| 6898 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6899 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6900 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6901 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6902 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6903 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 6904 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6905 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6906 | |
| 6907 | // The error should be caught by validation of the BeginCommandBuffer call |
| 6908 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 6909 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6910 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6911 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6912 | } |
| 6913 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6914 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6915 | // Cause error due to Begin while recording CB |
| 6916 | // Then cause 2 errors for attempting to reset CB w/o having |
| 6917 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 6918 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6919 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6920 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6921 | |
| 6922 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6923 | |
| 6924 | // Calls AllocateCommandBuffers |
| 6925 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 6926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6927 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 6928 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6929 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6930 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6931 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6932 | cmd_buf_info.pNext = NULL; |
| 6933 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6934 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6935 | |
| 6936 | // Begin CB to transition to recording state |
| 6937 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 6938 | // Can't re-begin. This should trigger error |
| 6939 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6940 | m_errorMonitor->VerifyFound(); |
| 6941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6943 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6944 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 6945 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 6946 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6947 | m_errorMonitor->VerifyFound(); |
| 6948 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6949 | m_errorMonitor->SetDesiredFailureMsg( |
| 6950 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6951 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6952 | // Transition CB to RECORDED state |
| 6953 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 6954 | // Now attempting to Begin will implicitly reset, which triggers error |
| 6955 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6956 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6957 | } |
| 6958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6959 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6960 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6961 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6962 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6963 | m_errorMonitor->SetDesiredFailureMsg( |
| 6964 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6965 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 6966 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6967 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6968 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6969 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6970 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6971 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6972 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6973 | |
| 6974 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6975 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6976 | ds_pool_ci.pNext = NULL; |
| 6977 | ds_pool_ci.maxSets = 1; |
| 6978 | ds_pool_ci.poolSizeCount = 1; |
| 6979 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6980 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6981 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6982 | err = |
| 6983 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6984 | ASSERT_VK_SUCCESS(err); |
| 6985 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6986 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6987 | dsl_binding.binding = 0; |
| 6988 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6989 | dsl_binding.descriptorCount = 1; |
| 6990 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6991 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6992 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6993 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6994 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6995 | ds_layout_ci.pNext = NULL; |
| 6996 | ds_layout_ci.bindingCount = 1; |
| 6997 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6998 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6999 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7000 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7001 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7002 | ASSERT_VK_SUCCESS(err); |
| 7003 | |
| 7004 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7005 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7006 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7007 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7008 | alloc_info.descriptorPool = ds_pool; |
| 7009 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7010 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7011 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7012 | ASSERT_VK_SUCCESS(err); |
| 7013 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7014 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7015 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7016 | pipeline_layout_ci.setLayoutCount = 1; |
| 7017 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7018 | |
| 7019 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7020 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7021 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7022 | ASSERT_VK_SUCCESS(err); |
| 7023 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7024 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7025 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7026 | |
| 7027 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7028 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7029 | vp_state_ci.scissorCount = 1; |
| 7030 | vp_state_ci.pScissors = ≻ |
| 7031 | vp_state_ci.viewportCount = 1; |
| 7032 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7033 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7034 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7035 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7036 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7037 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7038 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7039 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7040 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7041 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7042 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7043 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7044 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7045 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7046 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7047 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7048 | gp_ci.layout = pipeline_layout; |
| 7049 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7050 | |
| 7051 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7052 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7053 | pc_ci.initialDataSize = 0; |
| 7054 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7055 | |
| 7056 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7057 | VkPipelineCache pipelineCache; |
| 7058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7059 | err = |
| 7060 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7061 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7062 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7063 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7064 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7065 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7066 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7067 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7068 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7069 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7070 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7071 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7072 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 7073 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 7074 | { |
| 7075 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7076 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7077 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7078 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7079 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 7080 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7081 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7082 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7083 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7084 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7085 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7086 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7087 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7088 | |
| 7089 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7090 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7091 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7092 | ds_pool_ci.poolSizeCount = 1; |
| 7093 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7094 | |
| 7095 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7096 | err = vkCreateDescriptorPool(m_device->device(), |
| 7097 | 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] | 7098 | ASSERT_VK_SUCCESS(err); |
| 7099 | |
| 7100 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7101 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7102 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7103 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7104 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7105 | dsl_binding.pImmutableSamplers = NULL; |
| 7106 | |
| 7107 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7108 | ds_layout_ci.sType = |
| 7109 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7110 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7111 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7112 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7113 | |
| 7114 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7115 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7116 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7117 | ASSERT_VK_SUCCESS(err); |
| 7118 | |
| 7119 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7120 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 7121 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7122 | ASSERT_VK_SUCCESS(err); |
| 7123 | |
| 7124 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7125 | pipeline_layout_ci.sType = |
| 7126 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7127 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7128 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7129 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7130 | |
| 7131 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7132 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7133 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7134 | ASSERT_VK_SUCCESS(err); |
| 7135 | |
| 7136 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 7137 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7138 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7139 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 7140 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7141 | // 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] | 7142 | VkShaderObj |
| 7143 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 7144 | this); |
| 7145 | VkShaderObj |
| 7146 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 7147 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7149 | shaderStages[0].sType = |
| 7150 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7151 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7152 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7153 | shaderStages[1].sType = |
| 7154 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7155 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7156 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7157 | shaderStages[2].sType = |
| 7158 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7159 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7160 | shaderStages[2].shader = te.handle(); |
| 7161 | |
| 7162 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7163 | iaCI.sType = |
| 7164 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7165 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7166 | |
| 7167 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 7168 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 7169 | tsCI.patchControlPoints = 0; // This will cause an error |
| 7170 | |
| 7171 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7172 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7173 | gp_ci.pNext = NULL; |
| 7174 | gp_ci.stageCount = 3; |
| 7175 | gp_ci.pStages = shaderStages; |
| 7176 | gp_ci.pVertexInputState = NULL; |
| 7177 | gp_ci.pInputAssemblyState = &iaCI; |
| 7178 | gp_ci.pTessellationState = &tsCI; |
| 7179 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7180 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7181 | gp_ci.pMultisampleState = NULL; |
| 7182 | gp_ci.pDepthStencilState = NULL; |
| 7183 | gp_ci.pColorBlendState = NULL; |
| 7184 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7185 | gp_ci.layout = pipeline_layout; |
| 7186 | gp_ci.renderPass = renderPass(); |
| 7187 | |
| 7188 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7189 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7190 | pc_ci.pNext = NULL; |
| 7191 | pc_ci.initialSize = 0; |
| 7192 | pc_ci.initialData = 0; |
| 7193 | pc_ci.maxSize = 0; |
| 7194 | |
| 7195 | VkPipeline pipeline; |
| 7196 | VkPipelineCache pipelineCache; |
| 7197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7198 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 7199 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7200 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7201 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7202 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7203 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7204 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7205 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7206 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7207 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7208 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7209 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7210 | } |
| 7211 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7212 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7213 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7214 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7215 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7216 | m_errorMonitor->SetDesiredFailureMsg( |
| 7217 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7218 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 7219 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7220 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7221 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7222 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7223 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7224 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7225 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7226 | |
| 7227 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7228 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7229 | ds_pool_ci.maxSets = 1; |
| 7230 | ds_pool_ci.poolSizeCount = 1; |
| 7231 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7232 | |
| 7233 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7234 | err = |
| 7235 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7236 | ASSERT_VK_SUCCESS(err); |
| 7237 | |
| 7238 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7239 | dsl_binding.binding = 0; |
| 7240 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7241 | dsl_binding.descriptorCount = 1; |
| 7242 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7243 | |
| 7244 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7245 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7246 | ds_layout_ci.bindingCount = 1; |
| 7247 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7248 | |
| 7249 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7250 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7251 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7252 | ASSERT_VK_SUCCESS(err); |
| 7253 | |
| 7254 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7255 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7256 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7257 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7258 | alloc_info.descriptorPool = ds_pool; |
| 7259 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7260 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7261 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7262 | ASSERT_VK_SUCCESS(err); |
| 7263 | |
| 7264 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7265 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7266 | pipeline_layout_ci.setLayoutCount = 1; |
| 7267 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7268 | |
| 7269 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7270 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7271 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7272 | ASSERT_VK_SUCCESS(err); |
| 7273 | |
| 7274 | VkViewport vp = {}; // Just need dummy vp to point to |
| 7275 | |
| 7276 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7277 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7278 | vp_state_ci.scissorCount = 0; |
| 7279 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 7280 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7281 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7282 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7283 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7284 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7285 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7286 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7287 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7288 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7289 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7290 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7291 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7292 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7294 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7295 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7296 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7297 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7298 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7299 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7300 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7301 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7302 | |
| 7303 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7304 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7305 | gp_ci.stageCount = 2; |
| 7306 | gp_ci.pStages = shaderStages; |
| 7307 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7308 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7309 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7310 | gp_ci.layout = pipeline_layout; |
| 7311 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7312 | |
| 7313 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7314 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7315 | |
| 7316 | VkPipeline pipeline; |
| 7317 | VkPipelineCache pipelineCache; |
| 7318 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7319 | err = |
| 7320 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7321 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7322 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7323 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7324 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7325 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7326 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7327 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7328 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7329 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7330 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7331 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7332 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 7333 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7334 | // 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] | 7335 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7336 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7337 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7339 | m_errorMonitor->SetDesiredFailureMsg( |
| 7340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7341 | "Gfx Pipeline pViewportState is null. Even if "); |
| 7342 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7343 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7344 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7345 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7346 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7347 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7348 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7349 | |
| 7350 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7351 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7352 | ds_pool_ci.maxSets = 1; |
| 7353 | ds_pool_ci.poolSizeCount = 1; |
| 7354 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7355 | |
| 7356 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7357 | err = |
| 7358 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7359 | ASSERT_VK_SUCCESS(err); |
| 7360 | |
| 7361 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7362 | dsl_binding.binding = 0; |
| 7363 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7364 | dsl_binding.descriptorCount = 1; |
| 7365 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7366 | |
| 7367 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7368 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7369 | ds_layout_ci.bindingCount = 1; |
| 7370 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7371 | |
| 7372 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7373 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7374 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7375 | ASSERT_VK_SUCCESS(err); |
| 7376 | |
| 7377 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7378 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7379 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7380 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7381 | alloc_info.descriptorPool = ds_pool; |
| 7382 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7383 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7384 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7385 | ASSERT_VK_SUCCESS(err); |
| 7386 | |
| 7387 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7388 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7389 | pipeline_layout_ci.setLayoutCount = 1; |
| 7390 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7391 | |
| 7392 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7393 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7394 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7395 | ASSERT_VK_SUCCESS(err); |
| 7396 | |
| 7397 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 7398 | // Set scissor as dynamic to avoid second error |
| 7399 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7400 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7401 | dyn_state_ci.dynamicStateCount = 1; |
| 7402 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7403 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7404 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7405 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7406 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7407 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7408 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7409 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7410 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7411 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7412 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7413 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7414 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7415 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7416 | |
| 7417 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7418 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7419 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7420 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7421 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7422 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7423 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7424 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7425 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7426 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7427 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7428 | gp_ci.stageCount = 2; |
| 7429 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7430 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7431 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 7432 | // should cause validation error |
| 7433 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7434 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7435 | gp_ci.layout = pipeline_layout; |
| 7436 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7437 | |
| 7438 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7439 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7440 | |
| 7441 | VkPipeline pipeline; |
| 7442 | VkPipelineCache pipelineCache; |
| 7443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7444 | err = |
| 7445 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7446 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7447 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7448 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7449 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7450 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7451 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7452 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7453 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7454 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7455 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7456 | } |
| 7457 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7458 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 7459 | // count |
| 7460 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 7461 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7463 | m_errorMonitor->SetDesiredFailureMsg( |
| 7464 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7465 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 7466 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7467 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7468 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7469 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7470 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7471 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7472 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7473 | |
| 7474 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7475 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7476 | ds_pool_ci.maxSets = 1; |
| 7477 | ds_pool_ci.poolSizeCount = 1; |
| 7478 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7479 | |
| 7480 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7481 | err = |
| 7482 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7483 | ASSERT_VK_SUCCESS(err); |
| 7484 | |
| 7485 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7486 | dsl_binding.binding = 0; |
| 7487 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7488 | dsl_binding.descriptorCount = 1; |
| 7489 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7490 | |
| 7491 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7492 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7493 | ds_layout_ci.bindingCount = 1; |
| 7494 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7495 | |
| 7496 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7497 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7498 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7499 | ASSERT_VK_SUCCESS(err); |
| 7500 | |
| 7501 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7502 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7503 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7504 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7505 | alloc_info.descriptorPool = ds_pool; |
| 7506 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7507 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7508 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7509 | ASSERT_VK_SUCCESS(err); |
| 7510 | |
| 7511 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7512 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7513 | pipeline_layout_ci.setLayoutCount = 1; |
| 7514 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7515 | |
| 7516 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7517 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7518 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7519 | ASSERT_VK_SUCCESS(err); |
| 7520 | |
| 7521 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7522 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7523 | vp_state_ci.viewportCount = 1; |
| 7524 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 7525 | vp_state_ci.scissorCount = 1; |
| 7526 | vp_state_ci.pScissors = |
| 7527 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7528 | |
| 7529 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 7530 | // Set scissor as dynamic to avoid that error |
| 7531 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7532 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7533 | dyn_state_ci.dynamicStateCount = 1; |
| 7534 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7535 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7536 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7537 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7539 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7540 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7541 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7542 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7543 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7544 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7545 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7546 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7547 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7548 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7549 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7550 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7551 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7552 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7553 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7554 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7555 | |
| 7556 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7557 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7558 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7559 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7560 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7561 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7562 | rs_ci.pNext = nullptr; |
| 7563 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7564 | VkPipelineColorBlendAttachmentState att = {}; |
| 7565 | att.blendEnable = VK_FALSE; |
| 7566 | att.colorWriteMask = 0xf; |
| 7567 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7568 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7569 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7570 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7571 | cb_ci.attachmentCount = 1; |
| 7572 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7573 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7574 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7575 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7576 | gp_ci.stageCount = 2; |
| 7577 | gp_ci.pStages = shaderStages; |
| 7578 | gp_ci.pVertexInputState = &vi_ci; |
| 7579 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7580 | gp_ci.pViewportState = &vp_state_ci; |
| 7581 | gp_ci.pRasterizationState = &rs_ci; |
| 7582 | gp_ci.pColorBlendState = &cb_ci; |
| 7583 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7584 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7585 | gp_ci.layout = pipeline_layout; |
| 7586 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7587 | |
| 7588 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7589 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7590 | |
| 7591 | VkPipeline pipeline; |
| 7592 | VkPipelineCache pipelineCache; |
| 7593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7594 | err = |
| 7595 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7596 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7597 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7598 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7599 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7600 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7601 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7602 | // 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] | 7603 | // First need to successfully create the PSO from above by setting |
| 7604 | // pViewports |
| 7605 | m_errorMonitor->SetDesiredFailureMsg( |
| 7606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7607 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 7608 | "scissorCount is 1. These counts must match."); |
| 7609 | |
| 7610 | VkViewport vp = {}; // Just need dummy vp to point to |
| 7611 | vp_state_ci.pViewports = &vp; |
| 7612 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7613 | &gp_ci, NULL, &pipeline); |
| 7614 | ASSERT_VK_SUCCESS(err); |
| 7615 | BeginCommandBuffer(); |
| 7616 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7617 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7618 | VkRect2D scissors[2] = {}; // don't care about data |
| 7619 | // Count of 2 doesn't match PSO count of 1 |
| 7620 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 7621 | Draw(1, 0, 0, 0); |
| 7622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7623 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7624 | |
| 7625 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7626 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7627 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7628 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7629 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7630 | } |
| 7631 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 7632 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 7633 | // viewportCount |
| 7634 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 7635 | VkResult err; |
| 7636 | |
| 7637 | m_errorMonitor->SetDesiredFailureMsg( |
| 7638 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7639 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 7640 | |
| 7641 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7642 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7643 | |
| 7644 | VkDescriptorPoolSize ds_type_count = {}; |
| 7645 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7646 | ds_type_count.descriptorCount = 1; |
| 7647 | |
| 7648 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7649 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7650 | ds_pool_ci.maxSets = 1; |
| 7651 | ds_pool_ci.poolSizeCount = 1; |
| 7652 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7653 | |
| 7654 | VkDescriptorPool ds_pool; |
| 7655 | err = |
| 7656 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7657 | ASSERT_VK_SUCCESS(err); |
| 7658 | |
| 7659 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7660 | dsl_binding.binding = 0; |
| 7661 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7662 | dsl_binding.descriptorCount = 1; |
| 7663 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7664 | |
| 7665 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7666 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7667 | ds_layout_ci.bindingCount = 1; |
| 7668 | ds_layout_ci.pBindings = &dsl_binding; |
| 7669 | |
| 7670 | VkDescriptorSetLayout ds_layout; |
| 7671 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7672 | &ds_layout); |
| 7673 | ASSERT_VK_SUCCESS(err); |
| 7674 | |
| 7675 | VkDescriptorSet descriptorSet; |
| 7676 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7677 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7678 | alloc_info.descriptorSetCount = 1; |
| 7679 | alloc_info.descriptorPool = ds_pool; |
| 7680 | alloc_info.pSetLayouts = &ds_layout; |
| 7681 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7682 | &descriptorSet); |
| 7683 | ASSERT_VK_SUCCESS(err); |
| 7684 | |
| 7685 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7686 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7687 | pipeline_layout_ci.setLayoutCount = 1; |
| 7688 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7689 | |
| 7690 | VkPipelineLayout pipeline_layout; |
| 7691 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7692 | &pipeline_layout); |
| 7693 | ASSERT_VK_SUCCESS(err); |
| 7694 | |
| 7695 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7696 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7697 | vp_state_ci.scissorCount = 1; |
| 7698 | vp_state_ci.pScissors = |
| 7699 | NULL; // Null scissor w/ count of 1 should cause error |
| 7700 | vp_state_ci.viewportCount = 1; |
| 7701 | vp_state_ci.pViewports = |
| 7702 | NULL; // vp is dynamic (below) so this won't cause error |
| 7703 | |
| 7704 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 7705 | // Set scissor as dynamic to avoid that error |
| 7706 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7707 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7708 | dyn_state_ci.dynamicStateCount = 1; |
| 7709 | dyn_state_ci.pDynamicStates = &vp_state; |
| 7710 | |
| 7711 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7712 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7713 | |
| 7714 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7715 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7716 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7717 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7718 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7719 | // but add it to be able to run on more devices |
| 7720 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7721 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7722 | |
| 7723 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7724 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7725 | vi_ci.pNext = nullptr; |
| 7726 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7727 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7728 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7729 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7730 | |
| 7731 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7732 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7733 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7734 | |
| 7735 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7736 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7737 | rs_ci.pNext = nullptr; |
| 7738 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7739 | VkPipelineColorBlendAttachmentState att = {}; |
| 7740 | att.blendEnable = VK_FALSE; |
| 7741 | att.colorWriteMask = 0xf; |
| 7742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7743 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7744 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7745 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7746 | cb_ci.attachmentCount = 1; |
| 7747 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7748 | |
| 7749 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7750 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7751 | gp_ci.stageCount = 2; |
| 7752 | gp_ci.pStages = shaderStages; |
| 7753 | gp_ci.pVertexInputState = &vi_ci; |
| 7754 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7755 | gp_ci.pViewportState = &vp_state_ci; |
| 7756 | gp_ci.pRasterizationState = &rs_ci; |
| 7757 | gp_ci.pColorBlendState = &cb_ci; |
| 7758 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7759 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7760 | gp_ci.layout = pipeline_layout; |
| 7761 | gp_ci.renderPass = renderPass(); |
| 7762 | |
| 7763 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7764 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7765 | |
| 7766 | VkPipeline pipeline; |
| 7767 | VkPipelineCache pipelineCache; |
| 7768 | |
| 7769 | err = |
| 7770 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7771 | ASSERT_VK_SUCCESS(err); |
| 7772 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7773 | &gp_ci, NULL, &pipeline); |
| 7774 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7775 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7776 | |
| 7777 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 7778 | // First need to successfully create the PSO from above by setting |
| 7779 | // pViewports |
| 7780 | m_errorMonitor->SetDesiredFailureMsg( |
| 7781 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7782 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 7783 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7784 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7785 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 7786 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7787 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7788 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7789 | ASSERT_VK_SUCCESS(err); |
| 7790 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7791 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7792 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7793 | VkViewport viewports[2] = {}; // don't care about data |
| 7794 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 7795 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7796 | Draw(1, 0, 0, 0); |
| 7797 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7798 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7799 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7800 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7801 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7802 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7803 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7804 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7805 | } |
| 7806 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7807 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 7808 | VkResult err; |
| 7809 | |
| 7810 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7811 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7812 | |
| 7813 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7814 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7815 | |
| 7816 | VkDescriptorPoolSize ds_type_count = {}; |
| 7817 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7818 | ds_type_count.descriptorCount = 1; |
| 7819 | |
| 7820 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7821 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7822 | ds_pool_ci.maxSets = 1; |
| 7823 | ds_pool_ci.poolSizeCount = 1; |
| 7824 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7825 | |
| 7826 | VkDescriptorPool ds_pool; |
| 7827 | err = |
| 7828 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7829 | ASSERT_VK_SUCCESS(err); |
| 7830 | |
| 7831 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7832 | dsl_binding.binding = 0; |
| 7833 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7834 | dsl_binding.descriptorCount = 1; |
| 7835 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7836 | |
| 7837 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7838 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7839 | ds_layout_ci.bindingCount = 1; |
| 7840 | ds_layout_ci.pBindings = &dsl_binding; |
| 7841 | |
| 7842 | VkDescriptorSetLayout ds_layout; |
| 7843 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7844 | &ds_layout); |
| 7845 | ASSERT_VK_SUCCESS(err); |
| 7846 | |
| 7847 | VkDescriptorSet descriptorSet; |
| 7848 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7849 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7850 | alloc_info.descriptorSetCount = 1; |
| 7851 | alloc_info.descriptorPool = ds_pool; |
| 7852 | alloc_info.pSetLayouts = &ds_layout; |
| 7853 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7854 | &descriptorSet); |
| 7855 | ASSERT_VK_SUCCESS(err); |
| 7856 | |
| 7857 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7858 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7859 | pipeline_layout_ci.setLayoutCount = 1; |
| 7860 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7861 | |
| 7862 | VkPipelineLayout pipeline_layout; |
| 7863 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7864 | &pipeline_layout); |
| 7865 | ASSERT_VK_SUCCESS(err); |
| 7866 | |
| 7867 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7868 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7869 | vp_state_ci.scissorCount = 1; |
| 7870 | vp_state_ci.pScissors = NULL; |
| 7871 | vp_state_ci.viewportCount = 1; |
| 7872 | vp_state_ci.pViewports = NULL; |
| 7873 | |
| 7874 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 7875 | VK_DYNAMIC_STATE_SCISSOR, |
| 7876 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 7877 | // Set scissor as dynamic to avoid that error |
| 7878 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7879 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7880 | dyn_state_ci.dynamicStateCount = 2; |
| 7881 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 7882 | |
| 7883 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7884 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7885 | |
| 7886 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7887 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7888 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7889 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 7890 | this); // TODO - We shouldn't need a fragment shader |
| 7891 | // but add it to be able to run on more devices |
| 7892 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7893 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7894 | |
| 7895 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7896 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7897 | vi_ci.pNext = nullptr; |
| 7898 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7899 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7900 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7901 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7902 | |
| 7903 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7904 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7905 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7906 | |
| 7907 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7908 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7909 | rs_ci.pNext = nullptr; |
| 7910 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7911 | // Check too low (line width of -1.0f). |
| 7912 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7913 | |
| 7914 | VkPipelineColorBlendAttachmentState att = {}; |
| 7915 | att.blendEnable = VK_FALSE; |
| 7916 | att.colorWriteMask = 0xf; |
| 7917 | |
| 7918 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7919 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7920 | cb_ci.pNext = nullptr; |
| 7921 | cb_ci.attachmentCount = 1; |
| 7922 | cb_ci.pAttachments = &att; |
| 7923 | |
| 7924 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7925 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7926 | gp_ci.stageCount = 2; |
| 7927 | gp_ci.pStages = shaderStages; |
| 7928 | gp_ci.pVertexInputState = &vi_ci; |
| 7929 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7930 | gp_ci.pViewportState = &vp_state_ci; |
| 7931 | gp_ci.pRasterizationState = &rs_ci; |
| 7932 | gp_ci.pColorBlendState = &cb_ci; |
| 7933 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7934 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7935 | gp_ci.layout = pipeline_layout; |
| 7936 | gp_ci.renderPass = renderPass(); |
| 7937 | |
| 7938 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7939 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7940 | |
| 7941 | VkPipeline pipeline; |
| 7942 | VkPipelineCache pipelineCache; |
| 7943 | |
| 7944 | err = |
| 7945 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7946 | ASSERT_VK_SUCCESS(err); |
| 7947 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7948 | &gp_ci, NULL, &pipeline); |
| 7949 | |
| 7950 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7951 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7952 | |
| 7953 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7954 | "Attempt to set lineWidth to 65536"); |
| 7955 | |
| 7956 | // Check too high (line width of 65536.0f). |
| 7957 | rs_ci.lineWidth = 65536.0f; |
| 7958 | |
| 7959 | err = |
| 7960 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7961 | ASSERT_VK_SUCCESS(err); |
| 7962 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7963 | &gp_ci, NULL, &pipeline); |
| 7964 | |
| 7965 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7966 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7967 | |
| 7968 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7969 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7970 | |
| 7971 | dyn_state_ci.dynamicStateCount = 3; |
| 7972 | |
| 7973 | rs_ci.lineWidth = 1.0f; |
| 7974 | |
| 7975 | err = |
| 7976 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7977 | ASSERT_VK_SUCCESS(err); |
| 7978 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7979 | &gp_ci, NULL, &pipeline); |
| 7980 | BeginCommandBuffer(); |
| 7981 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7982 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7983 | |
| 7984 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7985 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7986 | m_errorMonitor->VerifyFound(); |
| 7987 | |
| 7988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7989 | "Attempt to set lineWidth to 65536"); |
| 7990 | |
| 7991 | // Check too high with dynamic setting. |
| 7992 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 7993 | m_errorMonitor->VerifyFound(); |
| 7994 | EndCommandBuffer(); |
| 7995 | |
| 7996 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7997 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7998 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7999 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8000 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8001 | } |
| 8002 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8003 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8004 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8005 | m_errorMonitor->SetDesiredFailureMsg( |
| 8006 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8007 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8008 | |
| 8009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8011 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8012 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8013 | // Don't care about RenderPass handle b/c error should be flagged before |
| 8014 | // that |
| 8015 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 8016 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8017 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8018 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8019 | } |
| 8020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8021 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8022 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8023 | m_errorMonitor->SetDesiredFailureMsg( |
| 8024 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8025 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8026 | |
| 8027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8029 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8030 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8031 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 8032 | // proper error |
Chris Forbes | 38ae7c4 | 2016-06-21 20:51:44 +1200 | [diff] [blame] | 8033 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8034 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8035 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8036 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8037 | } |
| 8038 | |
Chris Forbes | 2eeabe3 | 2016-06-21 20:52:34 +1200 | [diff] [blame] | 8039 | TEST_F(VkLayerTest, RenderPassSecondaryCommandBuffersMultipleTimes) { |
| 8040 | m_errorMonitor->ExpectSuccess(); |
| 8041 | |
| 8042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8043 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8044 | |
| 8045 | BeginCommandBuffer(); // framework implicitly begins the renderpass. |
| 8046 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); // end implicit. |
| 8047 | |
| 8048 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 8049 | VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 8050 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8051 | m_errorMonitor->VerifyNotFound(); |
| 8052 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 8053 | VK_SUBPASS_CONTENTS_INLINE); |
| 8054 | m_errorMonitor->VerifyNotFound(); |
| 8055 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8056 | m_errorMonitor->VerifyNotFound(); |
| 8057 | |
| 8058 | m_commandBuffer->EndCommandBuffer(); |
| 8059 | m_errorMonitor->VerifyNotFound(); |
| 8060 | } |
| 8061 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 8062 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 8063 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 8064 | "the number of renderPass attachments that use loadOp" |
| 8065 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 8066 | |
| 8067 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8068 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8069 | |
| 8070 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 8071 | VkAttachmentReference attach = {}; |
| 8072 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8073 | VkSubpassDescription subpass = {}; |
| 8074 | subpass.inputAttachmentCount = 1; |
| 8075 | subpass.pInputAttachments = &attach; |
| 8076 | VkRenderPassCreateInfo rpci = {}; |
| 8077 | rpci.subpassCount = 1; |
| 8078 | rpci.pSubpasses = &subpass; |
| 8079 | rpci.attachmentCount = 1; |
| 8080 | VkAttachmentDescription attach_desc = {}; |
| 8081 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8082 | // Set loadOp to CLEAR |
| 8083 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8084 | rpci.pAttachments = &attach_desc; |
| 8085 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8086 | VkRenderPass rp; |
| 8087 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8088 | |
| 8089 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 8090 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 8091 | hinfo.renderPass = VK_NULL_HANDLE; |
| 8092 | hinfo.subpass = 0; |
| 8093 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 8094 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 8095 | hinfo.queryFlags = 0; |
| 8096 | hinfo.pipelineStatistics = 0; |
| 8097 | VkCommandBufferBeginInfo info = {}; |
| 8098 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 8099 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 8100 | info.pInheritanceInfo = &hinfo; |
| 8101 | |
| 8102 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 8103 | VkRenderPassBeginInfo rp_begin = {}; |
| 8104 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 8105 | rp_begin.pNext = NULL; |
| 8106 | rp_begin.renderPass = renderPass(); |
| 8107 | rp_begin.framebuffer = framebuffer(); |
| 8108 | rp_begin.clearValueCount = 0; // Should be 1 |
| 8109 | |
| 8110 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8111 | " has a clearValueCount of 0 but the " |
| 8112 | "actual number of attachments in " |
| 8113 | "renderPass "); |
| 8114 | |
| 8115 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 8116 | VK_SUBPASS_CONTENTS_INLINE); |
| 8117 | |
| 8118 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 8119 | |
| 8120 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 8121 | } |
| 8122 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 8123 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 8124 | |
| 8125 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 8126 | |
| 8127 | m_errorMonitor->SetDesiredFailureMsg( |
| 8128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8129 | "It is invalid to issue this call inside an active render pass"); |
| 8130 | |
| 8131 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8132 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8133 | |
| 8134 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 8135 | BeginCommandBuffer(); |
| 8136 | |
| 8137 | // Call directly into vkEndCommandBuffer instead of the |
| 8138 | // the framework's EndCommandBuffer, which inserts a |
| 8139 | // vkEndRenderPass |
| 8140 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 8141 | |
| 8142 | m_errorMonitor->VerifyFound(); |
| 8143 | |
| 8144 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 8145 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 8146 | } |
| 8147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8148 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8149 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8150 | m_errorMonitor->SetDesiredFailureMsg( |
| 8151 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8152 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8153 | |
| 8154 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8155 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8156 | |
| 8157 | // Renderpass is started here |
| 8158 | BeginCommandBuffer(); |
| 8159 | |
| 8160 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8161 | vk_testing::Buffer dstBuffer; |
| 8162 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8163 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8164 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8165 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8166 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8167 | } |
| 8168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8169 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8170 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8171 | m_errorMonitor->SetDesiredFailureMsg( |
| 8172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8173 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8174 | |
| 8175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8176 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8177 | |
| 8178 | // Renderpass is started here |
| 8179 | BeginCommandBuffer(); |
| 8180 | |
| 8181 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8182 | vk_testing::Buffer dstBuffer; |
| 8183 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8185 | VkDeviceSize dstOffset = 0; |
| 8186 | VkDeviceSize dataSize = 1024; |
| 8187 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8189 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 8190 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8191 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8192 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8193 | } |
| 8194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8195 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8196 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8197 | m_errorMonitor->SetDesiredFailureMsg( |
| 8198 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8199 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8200 | |
| 8201 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8202 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8203 | |
| 8204 | // Renderpass is started here |
| 8205 | BeginCommandBuffer(); |
| 8206 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 8207 | VkClearColorValue clear_color; |
| 8208 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8209 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8210 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8211 | const int32_t tex_width = 32; |
| 8212 | const int32_t tex_height = 32; |
| 8213 | VkImageCreateInfo image_create_info = {}; |
| 8214 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8215 | image_create_info.pNext = NULL; |
| 8216 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8217 | image_create_info.format = tex_format; |
| 8218 | image_create_info.extent.width = tex_width; |
| 8219 | image_create_info.extent.height = tex_height; |
| 8220 | image_create_info.extent.depth = 1; |
| 8221 | image_create_info.mipLevels = 1; |
| 8222 | image_create_info.arrayLayers = 1; |
| 8223 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8224 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8225 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8226 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8227 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8228 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 8229 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8231 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 8232 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8233 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8234 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 8235 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8236 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8237 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8238 | } |
| 8239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8240 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8241 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8242 | m_errorMonitor->SetDesiredFailureMsg( |
| 8243 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8244 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8245 | |
| 8246 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8247 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8248 | |
| 8249 | // Renderpass is started here |
| 8250 | BeginCommandBuffer(); |
| 8251 | |
| 8252 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 8253 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8254 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 8255 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8256 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8257 | image_create_info.extent.width = 64; |
| 8258 | image_create_info.extent.height = 64; |
| 8259 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8260 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8261 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8262 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8263 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 8264 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8265 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8266 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 8267 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8268 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8269 | vkCmdClearDepthStencilImage( |
| 8270 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 8271 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 8272 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8273 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8274 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8275 | } |
| 8276 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8277 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8278 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8279 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8280 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8281 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8282 | "vkCmdClearAttachments: This call " |
| 8283 | "must be issued inside an active " |
| 8284 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8285 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8287 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8288 | |
| 8289 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8290 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8291 | ASSERT_VK_SUCCESS(err); |
| 8292 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8293 | VkClearAttachment color_attachment; |
| 8294 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8295 | color_attachment.clearValue.color.float32[0] = 0; |
| 8296 | color_attachment.clearValue.color.float32[1] = 0; |
| 8297 | color_attachment.clearValue.color.float32[2] = 0; |
| 8298 | color_attachment.clearValue.color.float32[3] = 0; |
| 8299 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8300 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 8301 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8302 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8303 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8304 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8305 | } |
| 8306 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 8307 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 8308 | // Try to add a buffer memory barrier with no buffer. |
| 8309 | m_errorMonitor->SetDesiredFailureMsg( |
| 8310 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8311 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 8312 | |
| 8313 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8314 | BeginCommandBuffer(); |
| 8315 | |
| 8316 | VkBufferMemoryBarrier buf_barrier = {}; |
| 8317 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 8318 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8319 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8320 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8321 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8322 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 8323 | buf_barrier.offset = 0; |
| 8324 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8325 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8326 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 8327 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 8328 | |
| 8329 | m_errorMonitor->VerifyFound(); |
| 8330 | } |
| 8331 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 8332 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 8333 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 8334 | |
| 8335 | m_errorMonitor->SetDesiredFailureMsg( |
| 8336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 8337 | |
| 8338 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8340 | |
| 8341 | VkMemoryBarrier mem_barrier = {}; |
| 8342 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 8343 | mem_barrier.pNext = NULL; |
| 8344 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8345 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8346 | BeginCommandBuffer(); |
| 8347 | // BeginCommandBuffer() starts a render pass |
| 8348 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8349 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8350 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 8351 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 8352 | m_errorMonitor->VerifyFound(); |
| 8353 | |
| 8354 | m_errorMonitor->SetDesiredFailureMsg( |
| 8355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8356 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 8357 | VkImageObj image(m_device); |
| 8358 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8359 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 8360 | ASSERT_TRUE(image.initialized()); |
| 8361 | VkImageMemoryBarrier img_barrier = {}; |
| 8362 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 8363 | img_barrier.pNext = NULL; |
| 8364 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8365 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8366 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8367 | // New layout can't be UNDEFINED |
| 8368 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8369 | img_barrier.image = image.handle(); |
| 8370 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8371 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8372 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8373 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8374 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8375 | img_barrier.subresourceRange.layerCount = 1; |
| 8376 | img_barrier.subresourceRange.levelCount = 1; |
| 8377 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8378 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8379 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8380 | nullptr, 1, &img_barrier); |
| 8381 | m_errorMonitor->VerifyFound(); |
| 8382 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8383 | |
| 8384 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8385 | "Subresource must have the sum of the " |
| 8386 | "baseArrayLayer"); |
| 8387 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 8388 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 8389 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8390 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8391 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8392 | nullptr, 1, &img_barrier); |
| 8393 | m_errorMonitor->VerifyFound(); |
| 8394 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8395 | |
| 8396 | m_errorMonitor->SetDesiredFailureMsg( |
| 8397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8398 | "Subresource must have the sum of the baseMipLevel"); |
| 8399 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 8400 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 8401 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8402 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8403 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8404 | nullptr, 1, &img_barrier); |
| 8405 | m_errorMonitor->VerifyFound(); |
| 8406 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8407 | |
| 8408 | m_errorMonitor->SetDesiredFailureMsg( |
| 8409 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8410 | "Buffer Barriers cannot be used during a render pass"); |
| 8411 | vk_testing::Buffer buffer; |
| 8412 | buffer.init(*m_device, 256); |
| 8413 | VkBufferMemoryBarrier buf_barrier = {}; |
| 8414 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 8415 | buf_barrier.pNext = NULL; |
| 8416 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8417 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8418 | buf_barrier.buffer = buffer.handle(); |
| 8419 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8420 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8421 | buf_barrier.offset = 0; |
| 8422 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8423 | // Can't send buffer barrier during a render pass |
| 8424 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8425 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8426 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8427 | &buf_barrier, 0, nullptr); |
| 8428 | m_errorMonitor->VerifyFound(); |
| 8429 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8430 | |
| 8431 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8432 | "which is not less than total size"); |
| 8433 | buf_barrier.offset = 257; |
| 8434 | // Offset greater than total size |
| 8435 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8436 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8437 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8438 | &buf_barrier, 0, nullptr); |
| 8439 | m_errorMonitor->VerifyFound(); |
| 8440 | buf_barrier.offset = 0; |
| 8441 | |
| 8442 | m_errorMonitor->SetDesiredFailureMsg( |
| 8443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 8444 | buf_barrier.size = 257; |
| 8445 | // Size greater than total size |
| 8446 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8447 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8448 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8449 | &buf_barrier, 0, nullptr); |
| 8450 | m_errorMonitor->VerifyFound(); |
| 8451 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8452 | |
| 8453 | m_errorMonitor->SetDesiredFailureMsg( |
| 8454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8455 | "Image is a depth and stencil format and thus must " |
| 8456 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 8457 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 8458 | VkDepthStencilObj ds_image(m_device); |
| 8459 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 8460 | ASSERT_TRUE(ds_image.initialized()); |
| 8461 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8462 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 8463 | img_barrier.image = ds_image.handle(); |
| 8464 | // Leave aspectMask at COLOR on purpose |
| 8465 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8466 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8467 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8468 | nullptr, 1, &img_barrier); |
| 8469 | m_errorMonitor->VerifyFound(); |
| 8470 | } |
| 8471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8472 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8473 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8474 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8476 | m_errorMonitor->SetDesiredFailureMsg( |
| 8477 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8478 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 8479 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8482 | uint32_t qfi = 0; |
| 8483 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8484 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8485 | buffCI.size = 1024; |
| 8486 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 8487 | buffCI.queueFamilyIndexCount = 1; |
| 8488 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8489 | |
| 8490 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8491 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8492 | ASSERT_VK_SUCCESS(err); |
| 8493 | |
| 8494 | BeginCommandBuffer(); |
| 8495 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8496 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8497 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8498 | // 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] | 8499 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 8500 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8501 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8502 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8503 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8504 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8505 | } |
| 8506 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8507 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 8508 | // Create an out-of-range queueFamilyIndex |
| 8509 | m_errorMonitor->SetDesiredFailureMsg( |
| 8510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 8511 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 8512 | "of the indices specified when the device was created, via the " |
| 8513 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8514 | |
| 8515 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8516 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8517 | VkBufferCreateInfo buffCI = {}; |
| 8518 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8519 | buffCI.size = 1024; |
| 8520 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 8521 | buffCI.queueFamilyIndexCount = 1; |
| 8522 | // Introduce failure by specifying invalid queue_family_index |
| 8523 | uint32_t qfi = 777; |
| 8524 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 8525 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8526 | |
| 8527 | VkBuffer ib; |
| 8528 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 8529 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8530 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8531 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8532 | } |
| 8533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8534 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 8535 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 8536 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8537 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8538 | m_errorMonitor->SetDesiredFailureMsg( |
| 8539 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8540 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8541 | |
| 8542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8543 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8544 | |
| 8545 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8546 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8547 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 8548 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8549 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8550 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8551 | } |
| 8552 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 8553 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 8554 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 8555 | "that do not have correct usage bits sets."); |
| 8556 | VkResult err; |
| 8557 | |
| 8558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8559 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 8560 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8561 | ds_type_count[i].type = VkDescriptorType(i); |
| 8562 | ds_type_count[i].descriptorCount = 1; |
| 8563 | } |
| 8564 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8565 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8566 | ds_pool_ci.pNext = NULL; |
| 8567 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8568 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8569 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 8570 | |
| 8571 | VkDescriptorPool ds_pool; |
| 8572 | err = |
| 8573 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8574 | ASSERT_VK_SUCCESS(err); |
| 8575 | |
| 8576 | // Create 10 layouts where each has a single descriptor of different type |
| 8577 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 8578 | {}; |
| 8579 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8580 | dsl_binding[i].binding = 0; |
| 8581 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 8582 | dsl_binding[i].descriptorCount = 1; |
| 8583 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 8584 | dsl_binding[i].pImmutableSamplers = NULL; |
| 8585 | } |
| 8586 | |
| 8587 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8588 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8589 | ds_layout_ci.pNext = NULL; |
| 8590 | ds_layout_ci.bindingCount = 1; |
| 8591 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 8592 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8593 | ds_layout_ci.pBindings = dsl_binding + i; |
| 8594 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 8595 | NULL, ds_layouts + i); |
| 8596 | ASSERT_VK_SUCCESS(err); |
| 8597 | } |
| 8598 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 8599 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8600 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8601 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8602 | alloc_info.descriptorPool = ds_pool; |
| 8603 | alloc_info.pSetLayouts = ds_layouts; |
| 8604 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8605 | descriptor_sets); |
| 8606 | ASSERT_VK_SUCCESS(err); |
| 8607 | |
| 8608 | // Create a buffer & bufferView to be used for invalid updates |
| 8609 | VkBufferCreateInfo buff_ci = {}; |
| 8610 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8611 | // This usage is not valid for any descriptor type |
| 8612 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 8613 | buff_ci.size = 256; |
| 8614 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8615 | VkBuffer buffer; |
| 8616 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 8617 | ASSERT_VK_SUCCESS(err); |
| 8618 | |
| 8619 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 8620 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 8621 | buff_view_ci.buffer = buffer; |
| 8622 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 8623 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 8624 | VkBufferView buff_view; |
| 8625 | err = |
| 8626 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 8627 | ASSERT_VK_SUCCESS(err); |
| 8628 | |
| 8629 | // Create an image to be used for invalid updates |
| 8630 | VkImageCreateInfo image_ci = {}; |
| 8631 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8632 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8633 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8634 | image_ci.extent.width = 64; |
| 8635 | image_ci.extent.height = 64; |
| 8636 | image_ci.extent.depth = 1; |
| 8637 | image_ci.mipLevels = 1; |
| 8638 | image_ci.arrayLayers = 1; |
| 8639 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8640 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8641 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8642 | // This usage is not valid for any descriptor type |
| 8643 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8644 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8645 | VkImage image; |
| 8646 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8647 | ASSERT_VK_SUCCESS(err); |
| 8648 | // Bind memory to image |
| 8649 | VkMemoryRequirements mem_reqs; |
| 8650 | VkDeviceMemory image_mem; |
| 8651 | bool pass; |
| 8652 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8653 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8654 | mem_alloc.pNext = NULL; |
| 8655 | mem_alloc.allocationSize = 0; |
| 8656 | mem_alloc.memoryTypeIndex = 0; |
| 8657 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8658 | mem_alloc.allocationSize = mem_reqs.size; |
| 8659 | pass = |
| 8660 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8661 | ASSERT_TRUE(pass); |
| 8662 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8663 | ASSERT_VK_SUCCESS(err); |
| 8664 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8665 | ASSERT_VK_SUCCESS(err); |
| 8666 | // Now create view for image |
| 8667 | VkImageViewCreateInfo image_view_ci = {}; |
| 8668 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8669 | image_view_ci.image = image; |
| 8670 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8671 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8672 | image_view_ci.subresourceRange.layerCount = 1; |
| 8673 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8674 | image_view_ci.subresourceRange.levelCount = 1; |
| 8675 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8676 | VkImageView image_view; |
| 8677 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8678 | &image_view); |
| 8679 | ASSERT_VK_SUCCESS(err); |
| 8680 | |
| 8681 | VkDescriptorBufferInfo buff_info = {}; |
| 8682 | buff_info.buffer = buffer; |
| 8683 | VkDescriptorImageInfo img_info = {}; |
| 8684 | img_info.imageView = image_view; |
| 8685 | VkWriteDescriptorSet descriptor_write = {}; |
| 8686 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8687 | descriptor_write.dstBinding = 0; |
| 8688 | descriptor_write.descriptorCount = 1; |
| 8689 | descriptor_write.pTexelBufferView = &buff_view; |
| 8690 | descriptor_write.pBufferInfo = &buff_info; |
| 8691 | descriptor_write.pImageInfo = &img_info; |
| 8692 | |
| 8693 | // These error messages align with VkDescriptorType struct |
| 8694 | const char *error_msgs[] = { |
| 8695 | "", // placeholder, no error for SAMPLER descriptor |
| 8696 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8697 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8698 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 8699 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 8700 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 8701 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8702 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8703 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8704 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8705 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 8706 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 8707 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8708 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 8709 | descriptor_write.dstSet = descriptor_sets[i]; |
| 8710 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8711 | error_msgs[i]); |
| 8712 | |
| 8713 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 8714 | NULL); |
| 8715 | |
| 8716 | m_errorMonitor->VerifyFound(); |
| 8717 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 8718 | } |
| 8719 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 8720 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8721 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 8722 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8723 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 8724 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 8725 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 8726 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 8727 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8728 | } |
| 8729 | |
Tobin Ehlis | 2fc296b | 2016-06-15 14:05:27 -0600 | [diff] [blame] | 8730 | TEST_F(VkLayerTest, DSAspectBitsErrors) { |
| 8731 | // TODO : Initially only catching case where DEPTH & STENCIL aspect bits |
| 8732 | // are set, but could expand this test to hit more cases. |
| 8733 | TEST_DESCRIPTION("Attempt to update descriptor sets for images " |
| 8734 | "that do not have correct aspect bits sets."); |
| 8735 | VkResult err; |
| 8736 | |
| 8737 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8738 | VkDescriptorPoolSize ds_type_count = {}; |
| 8739 | ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8740 | ds_type_count.descriptorCount = 1; |
| 8741 | |
| 8742 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8743 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8744 | ds_pool_ci.pNext = NULL; |
| 8745 | ds_pool_ci.maxSets = 5; |
| 8746 | ds_pool_ci.poolSizeCount = 1; |
| 8747 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8748 | |
| 8749 | VkDescriptorPool ds_pool; |
| 8750 | err = |
| 8751 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8752 | ASSERT_VK_SUCCESS(err); |
| 8753 | |
| 8754 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8755 | dsl_binding.binding = 0; |
| 8756 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8757 | dsl_binding.descriptorCount = 1; |
| 8758 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8759 | dsl_binding.pImmutableSamplers = NULL; |
| 8760 | |
| 8761 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8762 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8763 | ds_layout_ci.pNext = NULL; |
| 8764 | ds_layout_ci.bindingCount = 1; |
| 8765 | ds_layout_ci.pBindings = &dsl_binding; |
| 8766 | VkDescriptorSetLayout ds_layout; |
| 8767 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8768 | &ds_layout); |
| 8769 | ASSERT_VK_SUCCESS(err); |
| 8770 | |
| 8771 | VkDescriptorSet descriptor_set = {}; |
| 8772 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8773 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8774 | alloc_info.descriptorSetCount = 1; |
| 8775 | alloc_info.descriptorPool = ds_pool; |
| 8776 | alloc_info.pSetLayouts = &ds_layout; |
| 8777 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8778 | &descriptor_set); |
| 8779 | ASSERT_VK_SUCCESS(err); |
| 8780 | |
| 8781 | // Create an image to be used for invalid updates |
| 8782 | VkImageCreateInfo image_ci = {}; |
| 8783 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8784 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8785 | image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8786 | image_ci.extent.width = 64; |
| 8787 | image_ci.extent.height = 64; |
| 8788 | image_ci.extent.depth = 1; |
| 8789 | image_ci.mipLevels = 1; |
| 8790 | image_ci.arrayLayers = 1; |
| 8791 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8792 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8793 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8794 | image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8795 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8796 | VkImage image; |
| 8797 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8798 | ASSERT_VK_SUCCESS(err); |
| 8799 | // Bind memory to image |
| 8800 | VkMemoryRequirements mem_reqs; |
| 8801 | VkDeviceMemory image_mem; |
| 8802 | bool pass; |
| 8803 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8804 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8805 | mem_alloc.pNext = NULL; |
| 8806 | mem_alloc.allocationSize = 0; |
| 8807 | mem_alloc.memoryTypeIndex = 0; |
| 8808 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8809 | mem_alloc.allocationSize = mem_reqs.size; |
| 8810 | pass = |
| 8811 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8812 | ASSERT_TRUE(pass); |
| 8813 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8814 | ASSERT_VK_SUCCESS(err); |
| 8815 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8816 | ASSERT_VK_SUCCESS(err); |
| 8817 | // Now create view for image |
| 8818 | VkImageViewCreateInfo image_view_ci = {}; |
| 8819 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8820 | image_view_ci.image = image; |
| 8821 | image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8822 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8823 | image_view_ci.subresourceRange.layerCount = 1; |
| 8824 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8825 | image_view_ci.subresourceRange.levelCount = 1; |
| 8826 | // Setting both depth & stencil aspect bits is illegal for descriptor |
| 8827 | image_view_ci.subresourceRange.aspectMask = |
| 8828 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 8829 | |
| 8830 | VkImageView image_view; |
| 8831 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8832 | &image_view); |
| 8833 | ASSERT_VK_SUCCESS(err); |
| 8834 | |
| 8835 | VkDescriptorImageInfo img_info = {}; |
| 8836 | img_info.imageView = image_view; |
| 8837 | VkWriteDescriptorSet descriptor_write = {}; |
| 8838 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8839 | descriptor_write.dstBinding = 0; |
| 8840 | descriptor_write.descriptorCount = 1; |
| 8841 | descriptor_write.pTexelBufferView = NULL; |
| 8842 | descriptor_write.pBufferInfo = NULL; |
| 8843 | descriptor_write.pImageInfo = &img_info; |
| 8844 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8845 | descriptor_write.dstSet = descriptor_set; |
| 8846 | const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT " |
| 8847 | "or VK_IMAGE_ASPECT_STENCIL_BIT "; |
| 8848 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8849 | error_msg); |
| 8850 | |
| 8851 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8852 | |
| 8853 | m_errorMonitor->VerifyFound(); |
| 8854 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8855 | vkDestroyImage(m_device->device(), image, NULL); |
| 8856 | vkFreeMemory(m_device->device(), image_mem, NULL); |
| 8857 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8858 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); |
| 8859 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8860 | } |
| 8861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8862 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8863 | // 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] | 8864 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8866 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8867 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8868 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 8869 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8870 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8871 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8872 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8873 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8874 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8875 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8876 | |
| 8877 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8878 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8879 | ds_pool_ci.pNext = NULL; |
| 8880 | ds_pool_ci.maxSets = 1; |
| 8881 | ds_pool_ci.poolSizeCount = 1; |
| 8882 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8883 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8884 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8885 | err = |
| 8886 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8887 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8888 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8889 | dsl_binding.binding = 0; |
| 8890 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8891 | dsl_binding.descriptorCount = 1; |
| 8892 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8893 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8894 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8895 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8896 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8897 | ds_layout_ci.pNext = NULL; |
| 8898 | ds_layout_ci.bindingCount = 1; |
| 8899 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8900 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8901 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8902 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8903 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8904 | ASSERT_VK_SUCCESS(err); |
| 8905 | |
| 8906 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8907 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8908 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8909 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8910 | alloc_info.descriptorPool = ds_pool; |
| 8911 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8912 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8913 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8914 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8915 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 8916 | VkSamplerCreateInfo sampler_ci = {}; |
| 8917 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8918 | sampler_ci.pNext = NULL; |
| 8919 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8920 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8921 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8922 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8923 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8924 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8925 | sampler_ci.mipLodBias = 1.0; |
| 8926 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8927 | sampler_ci.maxAnisotropy = 1; |
| 8928 | sampler_ci.compareEnable = VK_FALSE; |
| 8929 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8930 | sampler_ci.minLod = 1.0; |
| 8931 | sampler_ci.maxLod = 1.0; |
| 8932 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8933 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 8934 | VkSampler sampler; |
| 8935 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 8936 | ASSERT_VK_SUCCESS(err); |
| 8937 | |
| 8938 | VkDescriptorImageInfo info = {}; |
| 8939 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8940 | |
| 8941 | VkWriteDescriptorSet descriptor_write; |
| 8942 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8943 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8944 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8945 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8946 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8947 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8948 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8949 | |
| 8950 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8951 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8952 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8953 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8954 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8955 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8956 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8957 | } |
| 8958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8959 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8960 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8961 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8962 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8963 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8964 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8965 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 8966 | "starting at binding offset of 0 combined with update array element " |
| 8967 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8968 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8969 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8970 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8971 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8972 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8973 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8974 | |
| 8975 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8976 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8977 | ds_pool_ci.pNext = NULL; |
| 8978 | ds_pool_ci.maxSets = 1; |
| 8979 | ds_pool_ci.poolSizeCount = 1; |
| 8980 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8981 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8982 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8983 | err = |
| 8984 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8985 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8986 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8987 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8988 | dsl_binding.binding = 0; |
| 8989 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8990 | dsl_binding.descriptorCount = 1; |
| 8991 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8992 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8993 | |
| 8994 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8995 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8996 | ds_layout_ci.pNext = NULL; |
| 8997 | ds_layout_ci.bindingCount = 1; |
| 8998 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8999 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9000 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9001 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9002 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9003 | ASSERT_VK_SUCCESS(err); |
| 9004 | |
| 9005 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9006 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9007 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9008 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9009 | alloc_info.descriptorPool = ds_pool; |
| 9010 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9011 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9012 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9013 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9014 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 9015 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 9016 | VkDescriptorBufferInfo buff_info = {}; |
| 9017 | buff_info.buffer = |
| 9018 | VkBuffer(0); // Don't care about buffer handle for this test |
| 9019 | buff_info.offset = 0; |
| 9020 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9021 | |
| 9022 | VkWriteDescriptorSet descriptor_write; |
| 9023 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9024 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9025 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9026 | descriptor_write.dstArrayElement = |
| 9027 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9028 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9029 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9030 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9031 | |
| 9032 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9033 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9034 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9035 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9036 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9037 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9038 | } |
| 9039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9040 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 9041 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 9042 | // index 2 |
| 9043 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9044 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9045 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9046 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9047 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9049 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9050 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9051 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9052 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9053 | |
| 9054 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9055 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9056 | ds_pool_ci.pNext = NULL; |
| 9057 | ds_pool_ci.maxSets = 1; |
| 9058 | ds_pool_ci.poolSizeCount = 1; |
| 9059 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9060 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9061 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9062 | err = |
| 9063 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9064 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9065 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9066 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9067 | dsl_binding.binding = 0; |
| 9068 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9069 | dsl_binding.descriptorCount = 1; |
| 9070 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9071 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9072 | |
| 9073 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9074 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9075 | ds_layout_ci.pNext = NULL; |
| 9076 | ds_layout_ci.bindingCount = 1; |
| 9077 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9078 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9079 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9080 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9081 | ASSERT_VK_SUCCESS(err); |
| 9082 | |
| 9083 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9084 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9085 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9086 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9087 | alloc_info.descriptorPool = ds_pool; |
| 9088 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9089 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9090 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9091 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9092 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9093 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9094 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9095 | sampler_ci.pNext = NULL; |
| 9096 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9097 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9098 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9099 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9100 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9101 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9102 | sampler_ci.mipLodBias = 1.0; |
| 9103 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9104 | sampler_ci.maxAnisotropy = 1; |
| 9105 | sampler_ci.compareEnable = VK_FALSE; |
| 9106 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9107 | sampler_ci.minLod = 1.0; |
| 9108 | sampler_ci.maxLod = 1.0; |
| 9109 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9110 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9111 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9112 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9113 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9114 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9115 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9116 | VkDescriptorImageInfo info = {}; |
| 9117 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9118 | |
| 9119 | VkWriteDescriptorSet descriptor_write; |
| 9120 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9121 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9122 | descriptor_write.dstSet = descriptorSet; |
| 9123 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9124 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9125 | // 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] | 9126 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9127 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9128 | |
| 9129 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9130 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9131 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9132 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9133 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9134 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9135 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9136 | } |
| 9137 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9138 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 9139 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 9140 | // types |
| 9141 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9142 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9143 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 9144 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9145 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9147 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9148 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9149 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9150 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9151 | |
| 9152 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9153 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9154 | ds_pool_ci.pNext = NULL; |
| 9155 | ds_pool_ci.maxSets = 1; |
| 9156 | ds_pool_ci.poolSizeCount = 1; |
| 9157 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9158 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9159 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9160 | err = |
| 9161 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9162 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9163 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9164 | dsl_binding.binding = 0; |
| 9165 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9166 | dsl_binding.descriptorCount = 1; |
| 9167 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9168 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9169 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9170 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9171 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9172 | ds_layout_ci.pNext = NULL; |
| 9173 | ds_layout_ci.bindingCount = 1; |
| 9174 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9175 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9176 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9177 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9178 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9179 | ASSERT_VK_SUCCESS(err); |
| 9180 | |
| 9181 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9182 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9183 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9184 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9185 | alloc_info.descriptorPool = ds_pool; |
| 9186 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9187 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9188 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9189 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9190 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9191 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9192 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9193 | sampler_ci.pNext = NULL; |
| 9194 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9195 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9196 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9197 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9198 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9199 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9200 | sampler_ci.mipLodBias = 1.0; |
| 9201 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9202 | sampler_ci.maxAnisotropy = 1; |
| 9203 | sampler_ci.compareEnable = VK_FALSE; |
| 9204 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9205 | sampler_ci.minLod = 1.0; |
| 9206 | sampler_ci.maxLod = 1.0; |
| 9207 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9208 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9209 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9210 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9211 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9212 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9213 | VkDescriptorImageInfo info = {}; |
| 9214 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9215 | |
| 9216 | VkWriteDescriptorSet descriptor_write; |
| 9217 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9218 | descriptor_write.sType = |
| 9219 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9220 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9221 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9222 | // 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] | 9223 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9224 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9225 | |
| 9226 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9227 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9228 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9229 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9230 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9231 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9232 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9233 | } |
| 9234 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9235 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9236 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9237 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9239 | m_errorMonitor->SetDesiredFailureMsg( |
| 9240 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9241 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9242 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9244 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 9245 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9246 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9247 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9248 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9249 | |
| 9250 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9251 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9252 | ds_pool_ci.pNext = NULL; |
| 9253 | ds_pool_ci.maxSets = 1; |
| 9254 | ds_pool_ci.poolSizeCount = 1; |
| 9255 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9256 | |
| 9257 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9258 | err = |
| 9259 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9260 | ASSERT_VK_SUCCESS(err); |
| 9261 | |
| 9262 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9263 | dsl_binding.binding = 0; |
| 9264 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9265 | dsl_binding.descriptorCount = 1; |
| 9266 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9267 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9268 | |
| 9269 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9270 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9271 | ds_layout_ci.pNext = NULL; |
| 9272 | ds_layout_ci.bindingCount = 1; |
| 9273 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9274 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9275 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9276 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9277 | ASSERT_VK_SUCCESS(err); |
| 9278 | |
| 9279 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9280 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9281 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9282 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9283 | alloc_info.descriptorPool = ds_pool; |
| 9284 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9285 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9286 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9287 | ASSERT_VK_SUCCESS(err); |
| 9288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9289 | VkSampler sampler = |
| 9290 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9291 | |
| 9292 | VkDescriptorImageInfo descriptor_info; |
| 9293 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 9294 | descriptor_info.sampler = sampler; |
| 9295 | |
| 9296 | VkWriteDescriptorSet descriptor_write; |
| 9297 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9298 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9299 | descriptor_write.dstSet = descriptorSet; |
| 9300 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9301 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9302 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9303 | descriptor_write.pImageInfo = &descriptor_info; |
| 9304 | |
| 9305 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9306 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9307 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9308 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9309 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9310 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9311 | } |
| 9312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9313 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 9314 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 9315 | // imageView |
| 9316 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9317 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9318 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9319 | "Attempted write update to combined " |
| 9320 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 9321 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9322 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9323 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9324 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9325 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9326 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9327 | |
| 9328 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9329 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9330 | ds_pool_ci.pNext = NULL; |
| 9331 | ds_pool_ci.maxSets = 1; |
| 9332 | ds_pool_ci.poolSizeCount = 1; |
| 9333 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9334 | |
| 9335 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9336 | err = |
| 9337 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9338 | ASSERT_VK_SUCCESS(err); |
| 9339 | |
| 9340 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9341 | dsl_binding.binding = 0; |
| 9342 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9343 | dsl_binding.descriptorCount = 1; |
| 9344 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9345 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9346 | |
| 9347 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9348 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9349 | ds_layout_ci.pNext = NULL; |
| 9350 | ds_layout_ci.bindingCount = 1; |
| 9351 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9352 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9353 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9354 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9355 | ASSERT_VK_SUCCESS(err); |
| 9356 | |
| 9357 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9358 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9359 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9360 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9361 | alloc_info.descriptorPool = ds_pool; |
| 9362 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9363 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9364 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9365 | ASSERT_VK_SUCCESS(err); |
| 9366 | |
| 9367 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9368 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9369 | sampler_ci.pNext = NULL; |
| 9370 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9371 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9372 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9373 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9374 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9375 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9376 | sampler_ci.mipLodBias = 1.0; |
| 9377 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9378 | sampler_ci.maxAnisotropy = 1; |
| 9379 | sampler_ci.compareEnable = VK_FALSE; |
| 9380 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9381 | sampler_ci.minLod = 1.0; |
| 9382 | sampler_ci.maxLod = 1.0; |
| 9383 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9384 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9385 | |
| 9386 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9387 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9388 | ASSERT_VK_SUCCESS(err); |
| 9389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9390 | VkImageView view = |
| 9391 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9392 | |
| 9393 | VkDescriptorImageInfo descriptor_info; |
| 9394 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 9395 | descriptor_info.sampler = sampler; |
| 9396 | descriptor_info.imageView = view; |
| 9397 | |
| 9398 | VkWriteDescriptorSet descriptor_write; |
| 9399 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9400 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9401 | descriptor_write.dstSet = descriptorSet; |
| 9402 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9403 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9404 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9405 | descriptor_write.pImageInfo = &descriptor_info; |
| 9406 | |
| 9407 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9408 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9409 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9410 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9411 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9412 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9413 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9414 | } |
| 9415 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9416 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 9417 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 9418 | // into the other |
| 9419 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9420 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9421 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9422 | " binding #1 with type " |
| 9423 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 9424 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9425 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9426 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9427 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9428 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9429 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9430 | ds_type_count[0].descriptorCount = 1; |
| 9431 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9432 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9433 | |
| 9434 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9435 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9436 | ds_pool_ci.pNext = NULL; |
| 9437 | ds_pool_ci.maxSets = 1; |
| 9438 | ds_pool_ci.poolSizeCount = 2; |
| 9439 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9440 | |
| 9441 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9442 | err = |
| 9443 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9444 | ASSERT_VK_SUCCESS(err); |
| 9445 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9446 | dsl_binding[0].binding = 0; |
| 9447 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9448 | dsl_binding[0].descriptorCount = 1; |
| 9449 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 9450 | dsl_binding[0].pImmutableSamplers = NULL; |
| 9451 | dsl_binding[1].binding = 1; |
| 9452 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9453 | dsl_binding[1].descriptorCount = 1; |
| 9454 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 9455 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9456 | |
| 9457 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9458 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9459 | ds_layout_ci.pNext = NULL; |
| 9460 | ds_layout_ci.bindingCount = 2; |
| 9461 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9462 | |
| 9463 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9464 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9465 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9466 | ASSERT_VK_SUCCESS(err); |
| 9467 | |
| 9468 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9469 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9470 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9471 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9472 | alloc_info.descriptorPool = ds_pool; |
| 9473 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9474 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9475 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9476 | ASSERT_VK_SUCCESS(err); |
| 9477 | |
| 9478 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9479 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9480 | sampler_ci.pNext = NULL; |
| 9481 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9482 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9483 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9484 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9485 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9486 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9487 | sampler_ci.mipLodBias = 1.0; |
| 9488 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9489 | sampler_ci.maxAnisotropy = 1; |
| 9490 | sampler_ci.compareEnable = VK_FALSE; |
| 9491 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9492 | sampler_ci.minLod = 1.0; |
| 9493 | sampler_ci.maxLod = 1.0; |
| 9494 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9495 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9496 | |
| 9497 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9498 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9499 | ASSERT_VK_SUCCESS(err); |
| 9500 | |
| 9501 | VkDescriptorImageInfo info = {}; |
| 9502 | info.sampler = sampler; |
| 9503 | |
| 9504 | VkWriteDescriptorSet descriptor_write; |
| 9505 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 9506 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9507 | descriptor_write.dstSet = descriptorSet; |
| 9508 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9509 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9510 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9511 | descriptor_write.pImageInfo = &info; |
| 9512 | // This write update should succeed |
| 9513 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9514 | // Now perform a copy update that fails due to type mismatch |
| 9515 | VkCopyDescriptorSet copy_ds_update; |
| 9516 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9517 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9518 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9519 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9520 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9521 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9522 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9523 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9524 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9525 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9526 | // 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] | 9527 | m_errorMonitor->SetDesiredFailureMsg( |
| 9528 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9529 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9530 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9531 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9532 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9533 | copy_ds_update.srcBinding = |
| 9534 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9535 | copy_ds_update.dstSet = descriptorSet; |
| 9536 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9537 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9538 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9539 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9540 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9541 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9542 | // 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] | 9543 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9544 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 9545 | "update array offset of 0 and update of " |
| 9546 | "5 descriptors oversteps total number " |
| 9547 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9548 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9549 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9550 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9551 | copy_ds_update.srcSet = descriptorSet; |
| 9552 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9553 | copy_ds_update.dstSet = descriptorSet; |
| 9554 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9555 | copy_ds_update.descriptorCount = |
| 9556 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9557 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9558 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9559 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9560 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9561 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9562 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9563 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9564 | } |
| 9565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9566 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 9567 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 9568 | // sampleCount |
| 9569 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9570 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9571 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9572 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9573 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9574 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9575 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9576 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9577 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9578 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9579 | |
| 9580 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9581 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9582 | ds_pool_ci.pNext = NULL; |
| 9583 | ds_pool_ci.maxSets = 1; |
| 9584 | ds_pool_ci.poolSizeCount = 1; |
| 9585 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9586 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9587 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9588 | err = |
| 9589 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9590 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9591 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9592 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 9593 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9594 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 9595 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9596 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9597 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9598 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9599 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9600 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9601 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9602 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 9603 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9604 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9605 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9606 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9607 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9608 | ASSERT_VK_SUCCESS(err); |
| 9609 | |
| 9610 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9611 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9612 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9613 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9614 | alloc_info.descriptorPool = ds_pool; |
| 9615 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9616 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9617 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9618 | ASSERT_VK_SUCCESS(err); |
| 9619 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9620 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9621 | pipe_ms_state_ci.sType = |
| 9622 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9623 | pipe_ms_state_ci.pNext = NULL; |
| 9624 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9625 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9626 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9627 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9628 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9629 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9630 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9631 | pipeline_layout_ci.pNext = NULL; |
| 9632 | pipeline_layout_ci.setLayoutCount = 1; |
| 9633 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9634 | |
| 9635 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9636 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9637 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9638 | ASSERT_VK_SUCCESS(err); |
| 9639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9640 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9641 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9642 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9643 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9644 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9645 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9646 | VkPipelineObj pipe(m_device); |
| 9647 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9648 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9649 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9650 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9651 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9652 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9653 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9654 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9655 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9656 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9657 | // Render triangle (the error should trigger on the attempt to draw). |
| 9658 | Draw(3, 1, 0, 0); |
| 9659 | |
| 9660 | // Finalize recording of the command buffer |
| 9661 | EndCommandBuffer(); |
| 9662 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9663 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9664 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9665 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9666 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9667 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9668 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9669 | |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9670 | TEST_F(VkLayerTest, RenderPassIncompatible) { |
| 9671 | TEST_DESCRIPTION("Hit RenderPass incompatible cases. " |
| 9672 | "Initial case is drawing with an active renderpass that's " |
| 9673 | "not compatible with the bound PSO's creation renderpass"); |
| 9674 | VkResult err; |
| 9675 | |
| 9676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9677 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9678 | |
| 9679 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9680 | dsl_binding.binding = 0; |
| 9681 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9682 | dsl_binding.descriptorCount = 1; |
| 9683 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9684 | dsl_binding.pImmutableSamplers = NULL; |
| 9685 | |
| 9686 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9687 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9688 | ds_layout_ci.pNext = NULL; |
| 9689 | ds_layout_ci.bindingCount = 1; |
| 9690 | ds_layout_ci.pBindings = &dsl_binding; |
| 9691 | |
| 9692 | VkDescriptorSetLayout ds_layout; |
| 9693 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9694 | &ds_layout); |
| 9695 | ASSERT_VK_SUCCESS(err); |
| 9696 | |
| 9697 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9698 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9699 | pipeline_layout_ci.pNext = NULL; |
| 9700 | pipeline_layout_ci.setLayoutCount = 1; |
| 9701 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9702 | |
| 9703 | VkPipelineLayout pipeline_layout; |
| 9704 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9705 | &pipeline_layout); |
| 9706 | ASSERT_VK_SUCCESS(err); |
| 9707 | |
| 9708 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9709 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9710 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9711 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 9712 | this); // We shouldn't need a fragment shader |
| 9713 | // but add it to be able to run on more devices |
| 9714 | // Create a renderpass that will be incompatible with default renderpass |
| 9715 | VkAttachmentReference attach = {}; |
| 9716 | attach.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 9717 | VkAttachmentReference color_att = {}; |
| 9718 | color_att.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9719 | VkSubpassDescription subpass = {}; |
| 9720 | subpass.inputAttachmentCount = 1; |
| 9721 | subpass.pInputAttachments = &attach; |
| 9722 | subpass.colorAttachmentCount = 1; |
| 9723 | subpass.pColorAttachments = &color_att; |
| 9724 | VkRenderPassCreateInfo rpci = {}; |
| 9725 | rpci.subpassCount = 1; |
| 9726 | rpci.pSubpasses = &subpass; |
| 9727 | rpci.attachmentCount = 1; |
| 9728 | VkAttachmentDescription attach_desc = {}; |
| 9729 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Cody Northrop | bd16af1 | 2016-06-21 09:25:48 -0600 | [diff] [blame] | 9730 | // Format incompatible with PSO RP color attach format B8G8R8A8_UNORM |
| 9731 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9732 | rpci.pAttachments = &attach_desc; |
| 9733 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 9734 | VkRenderPass rp; |
| 9735 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9736 | VkPipelineObj pipe(m_device); |
| 9737 | pipe.AddShader(&vs); |
| 9738 | pipe.AddShader(&fs); |
| 9739 | pipe.AddColorAttachment(); |
| 9740 | VkViewport view_port = {}; |
| 9741 | m_viewports.push_back(view_port); |
| 9742 | pipe.SetViewport(m_viewports); |
| 9743 | VkRect2D rect = {}; |
| 9744 | m_scissors.push_back(rect); |
| 9745 | pipe.SetScissor(m_scissors); |
| 9746 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9747 | |
| 9748 | VkCommandBufferInheritanceInfo cbii = {}; |
| 9749 | cbii.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 9750 | cbii.renderPass = rp; |
| 9751 | cbii.subpass = 0; |
| 9752 | VkCommandBufferBeginInfo cbbi = {}; |
| 9753 | cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 9754 | cbbi.pInheritanceInfo = &cbii; |
| 9755 | vkBeginCommandBuffer(m_commandBuffer->handle(), &cbbi); |
| 9756 | VkRenderPassBeginInfo rpbi = {}; |
| 9757 | rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 9758 | rpbi.framebuffer = m_framebuffer; |
| 9759 | rpbi.renderPass = rp; |
| 9760 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rpbi, |
| 9761 | VK_SUBPASS_CONTENTS_INLINE); |
| 9762 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9763 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9764 | |
| 9765 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9766 | " is incompatible w/ gfx pipeline "); |
| 9767 | // Render triangle (the error should trigger on the attempt to draw). |
| 9768 | Draw(3, 1, 0, 0); |
| 9769 | |
| 9770 | // Finalize recording of the command buffer |
| 9771 | EndCommandBuffer(); |
| 9772 | |
| 9773 | m_errorMonitor->VerifyFound(); |
| 9774 | |
| 9775 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9776 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9777 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 9778 | } |
| 9779 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9780 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 9781 | // Create Pipeline where the number of blend attachments doesn't match the |
| 9782 | // number of color attachments. In this case, we don't add any color |
| 9783 | // blend attachments even though we have a color attachment. |
| 9784 | VkResult err; |
| 9785 | |
| 9786 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9787 | "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] | 9788 | |
| 9789 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9790 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9791 | VkDescriptorPoolSize ds_type_count = {}; |
| 9792 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9793 | ds_type_count.descriptorCount = 1; |
| 9794 | |
| 9795 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 9796 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9797 | ds_pool_ci.pNext = NULL; |
| 9798 | ds_pool_ci.maxSets = 1; |
| 9799 | ds_pool_ci.poolSizeCount = 1; |
| 9800 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 9801 | |
| 9802 | VkDescriptorPool ds_pool; |
| 9803 | err = |
| 9804 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 9805 | ASSERT_VK_SUCCESS(err); |
| 9806 | |
| 9807 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9808 | dsl_binding.binding = 0; |
| 9809 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9810 | dsl_binding.descriptorCount = 1; |
| 9811 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9812 | dsl_binding.pImmutableSamplers = NULL; |
| 9813 | |
| 9814 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9815 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9816 | ds_layout_ci.pNext = NULL; |
| 9817 | ds_layout_ci.bindingCount = 1; |
| 9818 | ds_layout_ci.pBindings = &dsl_binding; |
| 9819 | |
| 9820 | VkDescriptorSetLayout ds_layout; |
| 9821 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9822 | &ds_layout); |
| 9823 | ASSERT_VK_SUCCESS(err); |
| 9824 | |
| 9825 | VkDescriptorSet descriptorSet; |
| 9826 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 9827 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 9828 | alloc_info.descriptorSetCount = 1; |
| 9829 | alloc_info.descriptorPool = ds_pool; |
| 9830 | alloc_info.pSetLayouts = &ds_layout; |
| 9831 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9832 | &descriptorSet); |
| 9833 | ASSERT_VK_SUCCESS(err); |
| 9834 | |
| 9835 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 9836 | pipe_ms_state_ci.sType = |
| 9837 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9838 | pipe_ms_state_ci.pNext = NULL; |
| 9839 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 9840 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9841 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9842 | pipe_ms_state_ci.pSampleMask = NULL; |
| 9843 | |
| 9844 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9845 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9846 | pipeline_layout_ci.pNext = NULL; |
| 9847 | pipeline_layout_ci.setLayoutCount = 1; |
| 9848 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9849 | |
| 9850 | VkPipelineLayout pipeline_layout; |
| 9851 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9852 | &pipeline_layout); |
| 9853 | ASSERT_VK_SUCCESS(err); |
| 9854 | |
| 9855 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9856 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9857 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9858 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9859 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9860 | // but add it to be able to run on more devices |
| 9861 | VkPipelineObj pipe(m_device); |
| 9862 | pipe.AddShader(&vs); |
| 9863 | pipe.AddShader(&fs); |
| 9864 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9865 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9866 | |
| 9867 | BeginCommandBuffer(); |
| 9868 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9869 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9870 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9871 | // Render triangle (the error should trigger on the attempt to draw). |
| 9872 | Draw(3, 1, 0, 0); |
| 9873 | |
| 9874 | // Finalize recording of the command buffer |
| 9875 | EndCommandBuffer(); |
| 9876 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9877 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9878 | |
| 9879 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9880 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9881 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 9882 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9883 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 9884 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 9885 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " |
| 9886 | "structure passed to vkCmdClearAttachments"); |
| 9887 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9888 | "vkCmdClearAttachments() attachment index 1 not found in attachment " |
| 9889 | "reference array of active subpass 0"); |
| 9890 | |
| 9891 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); |
| 9892 | m_errorMonitor->VerifyFound(); |
| 9893 | } |
| 9894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9895 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 9896 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 9897 | // to issuing a Draw |
| 9898 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9899 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9900 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 9901 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9902 | "vkCmdClearAttachments() issued on CB object "); |
| 9903 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9905 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9906 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9907 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9908 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9909 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9910 | |
| 9911 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9912 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9913 | ds_pool_ci.pNext = NULL; |
| 9914 | ds_pool_ci.maxSets = 1; |
| 9915 | ds_pool_ci.poolSizeCount = 1; |
| 9916 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9917 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9918 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9919 | err = |
| 9920 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9921 | ASSERT_VK_SUCCESS(err); |
| 9922 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9923 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9924 | dsl_binding.binding = 0; |
| 9925 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9926 | dsl_binding.descriptorCount = 1; |
| 9927 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9928 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9929 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9930 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9931 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9932 | ds_layout_ci.pNext = NULL; |
| 9933 | ds_layout_ci.bindingCount = 1; |
| 9934 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9935 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9936 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9937 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9938 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9939 | ASSERT_VK_SUCCESS(err); |
| 9940 | |
| 9941 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9942 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9943 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9944 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9945 | alloc_info.descriptorPool = ds_pool; |
| 9946 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9947 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9948 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9949 | ASSERT_VK_SUCCESS(err); |
| 9950 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9951 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9952 | pipe_ms_state_ci.sType = |
| 9953 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9954 | pipe_ms_state_ci.pNext = NULL; |
| 9955 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9956 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9957 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9958 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9959 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9960 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9961 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9962 | pipeline_layout_ci.pNext = NULL; |
| 9963 | pipeline_layout_ci.setLayoutCount = 1; |
| 9964 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9965 | |
| 9966 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9967 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9968 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9969 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9971 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9972 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9973 | // 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] | 9974 | // on more devices |
| 9975 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9976 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9977 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9978 | VkPipelineObj pipe(m_device); |
| 9979 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9980 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9981 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9982 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9983 | |
| 9984 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9986 | // Main thing we care about for this test is that the VkImage obj we're |
| 9987 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9988 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9989 | VkClearAttachment color_attachment; |
| 9990 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9991 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 9992 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 9993 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 9994 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 9995 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9996 | VkClearRect clear_rect = { |
| 9997 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9998 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9999 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 10000 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10001 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10002 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10003 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10004 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 10005 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10006 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10007 | } |
| 10008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10009 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 10010 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10012 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10013 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 10014 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10015 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10016 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 10017 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10018 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10019 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10020 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10021 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 10022 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10023 | |
| 10024 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10025 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10026 | ds_pool_ci.pNext = NULL; |
| 10027 | ds_pool_ci.maxSets = 1; |
| 10028 | ds_pool_ci.poolSizeCount = 1; |
| 10029 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10030 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10031 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10032 | err = |
| 10033 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10034 | ASSERT_VK_SUCCESS(err); |
| 10035 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10036 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10037 | dsl_binding.binding = 0; |
| 10038 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 10039 | dsl_binding.descriptorCount = 1; |
| 10040 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10041 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10042 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10043 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10044 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10045 | ds_layout_ci.pNext = NULL; |
| 10046 | ds_layout_ci.bindingCount = 1; |
| 10047 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10048 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10049 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10050 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10051 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10052 | ASSERT_VK_SUCCESS(err); |
| 10053 | |
| 10054 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10055 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10056 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10057 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10058 | alloc_info.descriptorPool = ds_pool; |
| 10059 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10060 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10061 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10062 | ASSERT_VK_SUCCESS(err); |
| 10063 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10064 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10065 | pipe_ms_state_ci.sType = |
| 10066 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 10067 | pipe_ms_state_ci.pNext = NULL; |
| 10068 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 10069 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 10070 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 10071 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10072 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10073 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10074 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 10075 | pipeline_layout_ci.pNext = NULL; |
| 10076 | pipeline_layout_ci.setLayoutCount = 1; |
| 10077 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 10078 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10079 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10080 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 10081 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10082 | ASSERT_VK_SUCCESS(err); |
| 10083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10084 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 10085 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10086 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 10087 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10088 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10089 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10090 | VkPipelineObj pipe(m_device); |
| 10091 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 10092 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10093 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10094 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 10095 | pipe.SetViewport(m_viewports); |
| 10096 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10097 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 10098 | |
| 10099 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10100 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 10101 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 10102 | // Don't care about actual data, just need to get to draw to flag error |
| 10103 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10104 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 10105 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 10106 | 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] | 10107 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10108 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10109 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10110 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10111 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 10112 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10113 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10114 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10115 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 10116 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 10117 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 10118 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 10119 | "images in the wrong layout when they're copied or transitioned."); |
| 10120 | // 3 in ValidateCmdBufImageLayouts |
| 10121 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 10122 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 10123 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 10124 | m_errorMonitor->SetDesiredFailureMsg( |
| 10125 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10126 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 10127 | |
| 10128 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10129 | // Create src & dst images to use for copy operations |
| 10130 | VkImage src_image; |
| 10131 | VkImage dst_image; |
| 10132 | |
| 10133 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10134 | const int32_t tex_width = 32; |
| 10135 | const int32_t tex_height = 32; |
| 10136 | |
| 10137 | VkImageCreateInfo image_create_info = {}; |
| 10138 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10139 | image_create_info.pNext = NULL; |
| 10140 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10141 | image_create_info.format = tex_format; |
| 10142 | image_create_info.extent.width = tex_width; |
| 10143 | image_create_info.extent.height = tex_height; |
| 10144 | image_create_info.extent.depth = 1; |
| 10145 | image_create_info.mipLevels = 1; |
| 10146 | image_create_info.arrayLayers = 4; |
| 10147 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10148 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10149 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10150 | image_create_info.flags = 0; |
| 10151 | |
| 10152 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 10153 | ASSERT_VK_SUCCESS(err); |
| 10154 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 10155 | ASSERT_VK_SUCCESS(err); |
| 10156 | |
| 10157 | BeginCommandBuffer(); |
| 10158 | VkImageCopy copyRegion; |
| 10159 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10160 | copyRegion.srcSubresource.mipLevel = 0; |
| 10161 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10162 | copyRegion.srcSubresource.layerCount = 1; |
| 10163 | copyRegion.srcOffset.x = 0; |
| 10164 | copyRegion.srcOffset.y = 0; |
| 10165 | copyRegion.srcOffset.z = 0; |
| 10166 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10167 | copyRegion.dstSubresource.mipLevel = 0; |
| 10168 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10169 | copyRegion.dstSubresource.layerCount = 1; |
| 10170 | copyRegion.dstOffset.x = 0; |
| 10171 | copyRegion.dstOffset.y = 0; |
| 10172 | copyRegion.dstOffset.z = 0; |
| 10173 | copyRegion.extent.width = 1; |
| 10174 | copyRegion.extent.height = 1; |
| 10175 | copyRegion.extent.depth = 1; |
| 10176 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10177 | m_errorMonitor->VerifyFound(); |
| 10178 | // Now cause error due to src image layout changing |
| 10179 | m_errorMonitor->SetDesiredFailureMsg( |
| 10180 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10181 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 10182 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10183 | m_errorMonitor->VerifyFound(); |
| 10184 | // Final src error is due to bad layout type |
| 10185 | m_errorMonitor->SetDesiredFailureMsg( |
| 10186 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10187 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 10188 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10189 | m_errorMonitor->VerifyFound(); |
| 10190 | // Now verify same checks for dst |
| 10191 | m_errorMonitor->SetDesiredFailureMsg( |
| 10192 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10193 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 10194 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10195 | m_errorMonitor->VerifyFound(); |
| 10196 | // Now cause error due to src image layout changing |
| 10197 | m_errorMonitor->SetDesiredFailureMsg( |
| 10198 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10199 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 10200 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 10201 | m_errorMonitor->VerifyFound(); |
| 10202 | m_errorMonitor->SetDesiredFailureMsg( |
| 10203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10204 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 10205 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 10206 | m_errorMonitor->VerifyFound(); |
| 10207 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 10208 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 10209 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10210 | image_barrier[0].image = src_image; |
| 10211 | image_barrier[0].subresourceRange.layerCount = 2; |
| 10212 | image_barrier[0].subresourceRange.levelCount = 2; |
| 10213 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10214 | m_errorMonitor->SetDesiredFailureMsg( |
| 10215 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10216 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 10217 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 10218 | m_errorMonitor->VerifyFound(); |
| 10219 | |
| 10220 | // Finally some layout errors at RenderPass create time |
| 10221 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 10222 | VkAttachmentReference attach = {}; |
| 10223 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 10224 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10225 | VkSubpassDescription subpass = {}; |
| 10226 | subpass.inputAttachmentCount = 1; |
| 10227 | subpass.pInputAttachments = &attach; |
| 10228 | VkRenderPassCreateInfo rpci = {}; |
| 10229 | rpci.subpassCount = 1; |
| 10230 | rpci.pSubpasses = &subpass; |
| 10231 | rpci.attachmentCount = 1; |
| 10232 | VkAttachmentDescription attach_desc = {}; |
| 10233 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 10234 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 10235 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10236 | VkRenderPass rp; |
| 10237 | m_errorMonitor->SetDesiredFailureMsg( |
| 10238 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10239 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 10240 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10241 | m_errorMonitor->VerifyFound(); |
| 10242 | // error w/ non-general layout |
| 10243 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10244 | |
| 10245 | m_errorMonitor->SetDesiredFailureMsg( |
| 10246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10247 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 10248 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10249 | m_errorMonitor->VerifyFound(); |
| 10250 | subpass.inputAttachmentCount = 0; |
| 10251 | subpass.colorAttachmentCount = 1; |
| 10252 | subpass.pColorAttachments = &attach; |
| 10253 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10254 | // perf warning for GENERAL layout on color attachment |
| 10255 | m_errorMonitor->SetDesiredFailureMsg( |
| 10256 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10257 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 10258 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10259 | m_errorMonitor->VerifyFound(); |
| 10260 | // error w/ non-color opt or GENERAL layout for color attachment |
| 10261 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10262 | m_errorMonitor->SetDesiredFailureMsg( |
| 10263 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10264 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 10265 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10266 | m_errorMonitor->VerifyFound(); |
| 10267 | subpass.colorAttachmentCount = 0; |
| 10268 | subpass.pDepthStencilAttachment = &attach; |
| 10269 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10270 | // perf warning for GENERAL layout on DS attachment |
| 10271 | m_errorMonitor->SetDesiredFailureMsg( |
| 10272 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10273 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 10274 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10275 | m_errorMonitor->VerifyFound(); |
| 10276 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 10277 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10278 | m_errorMonitor->SetDesiredFailureMsg( |
| 10279 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10280 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 10281 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10282 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 10283 | // For this error we need a valid renderpass so create default one |
| 10284 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10285 | attach.attachment = 0; |
| 10286 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10287 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10288 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 10289 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 10290 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 10291 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 10292 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 10293 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10294 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10295 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10296 | " with invalid first layout " |
| 10297 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 10298 | "ONLY_OPTIMAL"); |
| 10299 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10300 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10301 | |
| 10302 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 10303 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 10304 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10305 | #endif // DRAW_STATE_TESTS |
| 10306 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 10307 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10308 | #if GTEST_IS_THREADSAFE |
| 10309 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10310 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10311 | VkEvent event; |
| 10312 | bool bailout; |
| 10313 | }; |
| 10314 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10315 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 10316 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10318 | for (int i = 0; i < 10000; i++) { |
| 10319 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 10320 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10321 | if (data->bailout) { |
| 10322 | break; |
| 10323 | } |
| 10324 | } |
| 10325 | return NULL; |
| 10326 | } |
| 10327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10328 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10329 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10332 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10333 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10334 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10335 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 10336 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10337 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10338 | // Calls AllocateCommandBuffers |
| 10339 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 10340 | |
| 10341 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10342 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10343 | |
| 10344 | VkEventCreateInfo event_info; |
| 10345 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10346 | VkResult err; |
| 10347 | |
| 10348 | memset(&event_info, 0, sizeof(event_info)); |
| 10349 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 10350 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10351 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10352 | ASSERT_VK_SUCCESS(err); |
| 10353 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10354 | err = vkResetEvent(device(), event); |
| 10355 | ASSERT_VK_SUCCESS(err); |
| 10356 | |
| 10357 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10358 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10359 | data.event = event; |
| 10360 | data.bailout = false; |
| 10361 | m_errorMonitor->SetBailout(&data.bailout); |
| 10362 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10363 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10364 | // Add many entries to command buffer from this thread at the same time. |
| 10365 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 10366 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10367 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10368 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10369 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 10370 | m_errorMonitor->SetBailout(NULL); |
| 10371 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10372 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10373 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10374 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10375 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10376 | #endif // GTEST_IS_THREADSAFE |
| 10377 | #endif // THREADING_TESTS |
| 10378 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10379 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10380 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10381 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10382 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10383 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10385 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10386 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10387 | VkShaderModule module; |
| 10388 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10389 | struct icd_spv_header spv; |
| 10390 | |
| 10391 | spv.magic = ICD_SPV_MAGIC; |
| 10392 | spv.version = ICD_SPV_VERSION; |
| 10393 | spv.gen_magic = 0; |
| 10394 | |
| 10395 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10396 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10397 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10398 | moduleCreateInfo.codeSize = 4; |
| 10399 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10400 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10401 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10402 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10403 | } |
| 10404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10405 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10406 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10407 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10408 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10410 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10411 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10412 | VkShaderModule module; |
| 10413 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10414 | struct icd_spv_header spv; |
| 10415 | |
| 10416 | spv.magic = ~ICD_SPV_MAGIC; |
| 10417 | spv.version = ICD_SPV_VERSION; |
| 10418 | spv.gen_magic = 0; |
| 10419 | |
| 10420 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10421 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10422 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10423 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 10424 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10425 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10426 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10427 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10428 | } |
| 10429 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10430 | #if 0 |
| 10431 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10432 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10433 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10434 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10435 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10437 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10438 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10439 | VkShaderModule module; |
| 10440 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10441 | struct icd_spv_header spv; |
| 10442 | |
| 10443 | spv.magic = ICD_SPV_MAGIC; |
| 10444 | spv.version = ~ICD_SPV_VERSION; |
| 10445 | spv.gen_magic = 0; |
| 10446 | |
| 10447 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10448 | moduleCreateInfo.pNext = NULL; |
| 10449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10450 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10451 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 10452 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10453 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10454 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10455 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10456 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10457 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10458 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10459 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10460 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10461 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10462 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10463 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10464 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10465 | |
| 10466 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10467 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10468 | "\n" |
| 10469 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10470 | "out gl_PerVertex {\n" |
| 10471 | " vec4 gl_Position;\n" |
| 10472 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10473 | "void main(){\n" |
| 10474 | " gl_Position = vec4(1);\n" |
| 10475 | " x = 0;\n" |
| 10476 | "}\n"; |
| 10477 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10478 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10479 | "\n" |
| 10480 | "layout(location=0) out vec4 color;\n" |
| 10481 | "void main(){\n" |
| 10482 | " color = vec4(1);\n" |
| 10483 | "}\n"; |
| 10484 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10485 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10486 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10487 | |
| 10488 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10489 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10490 | pipe.AddShader(&vs); |
| 10491 | pipe.AddShader(&fs); |
| 10492 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10493 | VkDescriptorSetObj descriptorSet(m_device); |
| 10494 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10495 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10496 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10497 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10498 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10499 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10500 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10501 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10502 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10503 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10504 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10505 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10506 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10507 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10508 | |
| 10509 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10510 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10511 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10512 | "out gl_PerVertex {\n" |
| 10513 | " vec4 gl_Position;\n" |
| 10514 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10515 | "void main(){\n" |
| 10516 | " gl_Position = vec4(1);\n" |
| 10517 | "}\n"; |
| 10518 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10519 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10520 | "\n" |
| 10521 | "layout(location=0) in float x;\n" |
| 10522 | "layout(location=0) out vec4 color;\n" |
| 10523 | "void main(){\n" |
| 10524 | " color = vec4(x);\n" |
| 10525 | "}\n"; |
| 10526 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10527 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10528 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10529 | |
| 10530 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10531 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10532 | pipe.AddShader(&vs); |
| 10533 | pipe.AddShader(&fs); |
| 10534 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10535 | VkDescriptorSetObj descriptorSet(m_device); |
| 10536 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10537 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10538 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10539 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10540 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10541 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10542 | } |
| 10543 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10544 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10545 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10546 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10547 | |
| 10548 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10549 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10550 | |
| 10551 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10552 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10553 | "\n" |
| 10554 | "out gl_PerVertex {\n" |
| 10555 | " vec4 gl_Position;\n" |
| 10556 | "};\n" |
| 10557 | "void main(){\n" |
| 10558 | " gl_Position = vec4(1);\n" |
| 10559 | "}\n"; |
| 10560 | char const *fsSource = |
| 10561 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10562 | "\n" |
| 10563 | "in block { layout(location=0) float x; } ins;\n" |
| 10564 | "layout(location=0) out vec4 color;\n" |
| 10565 | "void main(){\n" |
| 10566 | " color = vec4(ins.x);\n" |
| 10567 | "}\n"; |
| 10568 | |
| 10569 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10570 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10571 | |
| 10572 | VkPipelineObj pipe(m_device); |
| 10573 | pipe.AddColorAttachment(); |
| 10574 | pipe.AddShader(&vs); |
| 10575 | pipe.AddShader(&fs); |
| 10576 | |
| 10577 | VkDescriptorSetObj descriptorSet(m_device); |
| 10578 | descriptorSet.AppendDummy(); |
| 10579 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10580 | |
| 10581 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10582 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10583 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10584 | } |
| 10585 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10586 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10587 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10588 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10589 | "output arr[2] of float32' vs 'ptr to " |
| 10590 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10591 | |
| 10592 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10593 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10594 | |
| 10595 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10596 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10597 | "\n" |
| 10598 | "layout(location=0) out float x[2];\n" |
| 10599 | "out gl_PerVertex {\n" |
| 10600 | " vec4 gl_Position;\n" |
| 10601 | "};\n" |
| 10602 | "void main(){\n" |
| 10603 | " x[0] = 0; x[1] = 0;\n" |
| 10604 | " gl_Position = vec4(1);\n" |
| 10605 | "}\n"; |
| 10606 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10607 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10608 | "\n" |
| 10609 | "layout(location=0) in float x[3];\n" |
| 10610 | "layout(location=0) out vec4 color;\n" |
| 10611 | "void main(){\n" |
| 10612 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 10613 | "}\n"; |
| 10614 | |
| 10615 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10616 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10617 | |
| 10618 | VkPipelineObj pipe(m_device); |
| 10619 | pipe.AddColorAttachment(); |
| 10620 | pipe.AddShader(&vs); |
| 10621 | pipe.AddShader(&fs); |
| 10622 | |
| 10623 | VkDescriptorSetObj descriptorSet(m_device); |
| 10624 | descriptorSet.AppendDummy(); |
| 10625 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10626 | |
| 10627 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10628 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10629 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10630 | } |
| 10631 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10632 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10633 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10634 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10635 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10636 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10637 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10638 | |
| 10639 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10640 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10641 | "\n" |
| 10642 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10643 | "out gl_PerVertex {\n" |
| 10644 | " vec4 gl_Position;\n" |
| 10645 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10646 | "void main(){\n" |
| 10647 | " x = 0;\n" |
| 10648 | " gl_Position = vec4(1);\n" |
| 10649 | "}\n"; |
| 10650 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10651 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10652 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10653 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10654 | "layout(location=0) out vec4 color;\n" |
| 10655 | "void main(){\n" |
| 10656 | " color = vec4(x);\n" |
| 10657 | "}\n"; |
| 10658 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10659 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10660 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10661 | |
| 10662 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10663 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10664 | pipe.AddShader(&vs); |
| 10665 | pipe.AddShader(&fs); |
| 10666 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10667 | VkDescriptorSetObj descriptorSet(m_device); |
| 10668 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10669 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10670 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10671 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10672 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10673 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10674 | } |
| 10675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10676 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10677 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10678 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10679 | |
| 10680 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10682 | |
| 10683 | char const *vsSource = |
| 10684 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10685 | "\n" |
| 10686 | "out block { layout(location=0) int x; } outs;\n" |
| 10687 | "out gl_PerVertex {\n" |
| 10688 | " vec4 gl_Position;\n" |
| 10689 | "};\n" |
| 10690 | "void main(){\n" |
| 10691 | " outs.x = 0;\n" |
| 10692 | " gl_Position = vec4(1);\n" |
| 10693 | "}\n"; |
| 10694 | char const *fsSource = |
| 10695 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10696 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10697 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10698 | "layout(location=0) out vec4 color;\n" |
| 10699 | "void main(){\n" |
| 10700 | " color = vec4(ins.x);\n" |
| 10701 | "}\n"; |
| 10702 | |
| 10703 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10704 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10705 | |
| 10706 | VkPipelineObj pipe(m_device); |
| 10707 | pipe.AddColorAttachment(); |
| 10708 | pipe.AddShader(&vs); |
| 10709 | pipe.AddShader(&fs); |
| 10710 | |
| 10711 | VkDescriptorSetObj descriptorSet(m_device); |
| 10712 | descriptorSet.AppendDummy(); |
| 10713 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10714 | |
| 10715 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10716 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10717 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10718 | } |
| 10719 | |
| 10720 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 10721 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10722 | "location 0.0 which is not written by vertex shader"); |
| 10723 | |
| 10724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10725 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10726 | |
| 10727 | char const *vsSource = |
| 10728 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10729 | "\n" |
| 10730 | "out block { layout(location=1) float x; } outs;\n" |
| 10731 | "out gl_PerVertex {\n" |
| 10732 | " vec4 gl_Position;\n" |
| 10733 | "};\n" |
| 10734 | "void main(){\n" |
| 10735 | " outs.x = 0;\n" |
| 10736 | " gl_Position = vec4(1);\n" |
| 10737 | "}\n"; |
| 10738 | char const *fsSource = |
| 10739 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10740 | "\n" |
| 10741 | "in block { layout(location=0) float x; } ins;\n" |
| 10742 | "layout(location=0) out vec4 color;\n" |
| 10743 | "void main(){\n" |
| 10744 | " color = vec4(ins.x);\n" |
| 10745 | "}\n"; |
| 10746 | |
| 10747 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10748 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10749 | |
| 10750 | VkPipelineObj pipe(m_device); |
| 10751 | pipe.AddColorAttachment(); |
| 10752 | pipe.AddShader(&vs); |
| 10753 | pipe.AddShader(&fs); |
| 10754 | |
| 10755 | VkDescriptorSetObj descriptorSet(m_device); |
| 10756 | descriptorSet.AppendDummy(); |
| 10757 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10758 | |
| 10759 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10760 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10761 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10762 | } |
| 10763 | |
| 10764 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 10765 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10766 | "location 0.1 which is not written by vertex shader"); |
| 10767 | |
| 10768 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10769 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10770 | |
| 10771 | char const *vsSource = |
| 10772 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10773 | "\n" |
| 10774 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 10775 | "out gl_PerVertex {\n" |
| 10776 | " vec4 gl_Position;\n" |
| 10777 | "};\n" |
| 10778 | "void main(){\n" |
| 10779 | " outs.x = 0;\n" |
| 10780 | " gl_Position = vec4(1);\n" |
| 10781 | "}\n"; |
| 10782 | char const *fsSource = |
| 10783 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10784 | "\n" |
| 10785 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 10786 | "layout(location=0) out vec4 color;\n" |
| 10787 | "void main(){\n" |
| 10788 | " color = vec4(ins.x);\n" |
| 10789 | "}\n"; |
| 10790 | |
| 10791 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10792 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10793 | |
| 10794 | VkPipelineObj pipe(m_device); |
| 10795 | pipe.AddColorAttachment(); |
| 10796 | pipe.AddShader(&vs); |
| 10797 | pipe.AddShader(&fs); |
| 10798 | |
| 10799 | VkDescriptorSetObj descriptorSet(m_device); |
| 10800 | descriptorSet.AppendDummy(); |
| 10801 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10802 | |
| 10803 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10804 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10805 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10806 | } |
| 10807 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10808 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10809 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10810 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10811 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10813 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10814 | |
| 10815 | VkVertexInputBindingDescription input_binding; |
| 10816 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10817 | |
| 10818 | VkVertexInputAttributeDescription input_attrib; |
| 10819 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10820 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10821 | |
| 10822 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10823 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10824 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10825 | "out gl_PerVertex {\n" |
| 10826 | " vec4 gl_Position;\n" |
| 10827 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10828 | "void main(){\n" |
| 10829 | " gl_Position = vec4(1);\n" |
| 10830 | "}\n"; |
| 10831 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10832 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10833 | "\n" |
| 10834 | "layout(location=0) out vec4 color;\n" |
| 10835 | "void main(){\n" |
| 10836 | " color = vec4(1);\n" |
| 10837 | "}\n"; |
| 10838 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10839 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10840 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10841 | |
| 10842 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10843 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10844 | pipe.AddShader(&vs); |
| 10845 | pipe.AddShader(&fs); |
| 10846 | |
| 10847 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10848 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10849 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10850 | VkDescriptorSetObj descriptorSet(m_device); |
| 10851 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10852 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10853 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10854 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10855 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10856 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10857 | } |
| 10858 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10859 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10860 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10861 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10862 | |
| 10863 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10864 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10865 | |
| 10866 | VkVertexInputBindingDescription input_binding; |
| 10867 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10868 | |
| 10869 | VkVertexInputAttributeDescription input_attrib; |
| 10870 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10871 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10872 | |
| 10873 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10874 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10875 | "\n" |
| 10876 | "layout(location=1) in float x;\n" |
| 10877 | "out gl_PerVertex {\n" |
| 10878 | " vec4 gl_Position;\n" |
| 10879 | "};\n" |
| 10880 | "void main(){\n" |
| 10881 | " gl_Position = vec4(x);\n" |
| 10882 | "}\n"; |
| 10883 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10884 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10885 | "\n" |
| 10886 | "layout(location=0) out vec4 color;\n" |
| 10887 | "void main(){\n" |
| 10888 | " color = vec4(1);\n" |
| 10889 | "}\n"; |
| 10890 | |
| 10891 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10892 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10893 | |
| 10894 | VkPipelineObj pipe(m_device); |
| 10895 | pipe.AddColorAttachment(); |
| 10896 | pipe.AddShader(&vs); |
| 10897 | pipe.AddShader(&fs); |
| 10898 | |
| 10899 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10900 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10901 | |
| 10902 | VkDescriptorSetObj descriptorSet(m_device); |
| 10903 | descriptorSet.AppendDummy(); |
| 10904 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10905 | |
| 10906 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10907 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10908 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10909 | } |
| 10910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10911 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 10912 | m_errorMonitor->SetDesiredFailureMsg( |
| 10913 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10914 | "VS consumes input at location 0 but not provided"); |
| 10915 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10916 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10917 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10918 | |
| 10919 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10920 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10921 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10922 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10923 | "out gl_PerVertex {\n" |
| 10924 | " vec4 gl_Position;\n" |
| 10925 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10926 | "void main(){\n" |
| 10927 | " gl_Position = x;\n" |
| 10928 | "}\n"; |
| 10929 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10930 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10931 | "\n" |
| 10932 | "layout(location=0) out vec4 color;\n" |
| 10933 | "void main(){\n" |
| 10934 | " color = vec4(1);\n" |
| 10935 | "}\n"; |
| 10936 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10937 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10938 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10939 | |
| 10940 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10941 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10942 | pipe.AddShader(&vs); |
| 10943 | pipe.AddShader(&fs); |
| 10944 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10945 | VkDescriptorSetObj descriptorSet(m_device); |
| 10946 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10947 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10948 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10949 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10950 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10951 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10952 | } |
| 10953 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10954 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 10955 | m_errorMonitor->SetDesiredFailureMsg( |
| 10956 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10957 | "location 0 does not match VS input type"); |
| 10958 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10960 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10961 | |
| 10962 | VkVertexInputBindingDescription input_binding; |
| 10963 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10964 | |
| 10965 | VkVertexInputAttributeDescription input_attrib; |
| 10966 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10967 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10968 | |
| 10969 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10970 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10971 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10972 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10973 | "out gl_PerVertex {\n" |
| 10974 | " vec4 gl_Position;\n" |
| 10975 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10976 | "void main(){\n" |
| 10977 | " gl_Position = vec4(x);\n" |
| 10978 | "}\n"; |
| 10979 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10980 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10981 | "\n" |
| 10982 | "layout(location=0) out vec4 color;\n" |
| 10983 | "void main(){\n" |
| 10984 | " color = vec4(1);\n" |
| 10985 | "}\n"; |
| 10986 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10989 | |
| 10990 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10991 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10992 | pipe.AddShader(&vs); |
| 10993 | pipe.AddShader(&fs); |
| 10994 | |
| 10995 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10996 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10997 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10998 | VkDescriptorSetObj descriptorSet(m_device); |
| 10999 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11000 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11001 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11002 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11003 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11004 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11005 | } |
| 11006 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 11007 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 11008 | m_errorMonitor->SetDesiredFailureMsg( |
| 11009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11010 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 11011 | |
| 11012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11013 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11014 | |
| 11015 | char const *vsSource = |
| 11016 | "#version 450\n" |
| 11017 | "\n" |
| 11018 | "out gl_PerVertex {\n" |
| 11019 | " vec4 gl_Position;\n" |
| 11020 | "};\n" |
| 11021 | "void main(){\n" |
| 11022 | " gl_Position = vec4(1);\n" |
| 11023 | "}\n"; |
| 11024 | char const *fsSource = |
| 11025 | "#version 450\n" |
| 11026 | "\n" |
| 11027 | "layout(location=0) out vec4 color;\n" |
| 11028 | "void main(){\n" |
| 11029 | " color = vec4(1);\n" |
| 11030 | "}\n"; |
| 11031 | |
| 11032 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11033 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11034 | |
| 11035 | VkPipelineObj pipe(m_device); |
| 11036 | pipe.AddColorAttachment(); |
| 11037 | pipe.AddShader(&vs); |
| 11038 | pipe.AddShader(&vs); |
| 11039 | pipe.AddShader(&fs); |
| 11040 | |
| 11041 | VkDescriptorSetObj descriptorSet(m_device); |
| 11042 | descriptorSet.AppendDummy(); |
| 11043 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11044 | |
| 11045 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11046 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11047 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 11048 | } |
| 11049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11050 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11051 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11052 | |
| 11053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11054 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11055 | |
| 11056 | VkVertexInputBindingDescription input_binding; |
| 11057 | memset(&input_binding, 0, sizeof(input_binding)); |
| 11058 | |
| 11059 | VkVertexInputAttributeDescription input_attribs[2]; |
| 11060 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11061 | |
| 11062 | for (int i = 0; i < 2; i++) { |
| 11063 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 11064 | input_attribs[i].location = i; |
| 11065 | } |
| 11066 | |
| 11067 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11068 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11069 | "\n" |
| 11070 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11071 | "out gl_PerVertex {\n" |
| 11072 | " vec4 gl_Position;\n" |
| 11073 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11074 | "void main(){\n" |
| 11075 | " gl_Position = x[0] + x[1];\n" |
| 11076 | "}\n"; |
| 11077 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11078 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11079 | "\n" |
| 11080 | "layout(location=0) out vec4 color;\n" |
| 11081 | "void main(){\n" |
| 11082 | " color = vec4(1);\n" |
| 11083 | "}\n"; |
| 11084 | |
| 11085 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11086 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11087 | |
| 11088 | VkPipelineObj pipe(m_device); |
| 11089 | pipe.AddColorAttachment(); |
| 11090 | pipe.AddShader(&vs); |
| 11091 | pipe.AddShader(&fs); |
| 11092 | |
| 11093 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 11094 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 11095 | |
| 11096 | VkDescriptorSetObj descriptorSet(m_device); |
| 11097 | descriptorSet.AppendDummy(); |
| 11098 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11099 | |
| 11100 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11101 | |
| 11102 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11103 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11104 | } |
| 11105 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11106 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 11107 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11108 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11109 | |
| 11110 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11111 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11112 | |
| 11113 | VkVertexInputBindingDescription input_binding; |
| 11114 | memset(&input_binding, 0, sizeof(input_binding)); |
| 11115 | |
| 11116 | VkVertexInputAttributeDescription input_attribs[2]; |
| 11117 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11118 | |
| 11119 | for (int i = 0; i < 2; i++) { |
| 11120 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 11121 | input_attribs[i].location = i; |
| 11122 | } |
| 11123 | |
| 11124 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11125 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11126 | "\n" |
| 11127 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11128 | "out gl_PerVertex {\n" |
| 11129 | " vec4 gl_Position;\n" |
| 11130 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11131 | "void main(){\n" |
| 11132 | " gl_Position = x[0] + x[1];\n" |
| 11133 | "}\n"; |
| 11134 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11135 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11136 | "\n" |
| 11137 | "layout(location=0) out vec4 color;\n" |
| 11138 | "void main(){\n" |
| 11139 | " color = vec4(1);\n" |
| 11140 | "}\n"; |
| 11141 | |
| 11142 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11143 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11144 | |
| 11145 | VkPipelineObj pipe(m_device); |
| 11146 | pipe.AddColorAttachment(); |
| 11147 | pipe.AddShader(&vs); |
| 11148 | pipe.AddShader(&fs); |
| 11149 | |
| 11150 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 11151 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 11152 | |
| 11153 | VkDescriptorSetObj descriptorSet(m_device); |
| 11154 | descriptorSet.AppendDummy(); |
| 11155 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11156 | |
| 11157 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11158 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11159 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11160 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11161 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11162 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 11163 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11164 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11165 | |
| 11166 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11167 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11168 | |
| 11169 | char const *vsSource = |
| 11170 | "#version 450\n" |
| 11171 | "out gl_PerVertex {\n" |
| 11172 | " vec4 gl_Position;\n" |
| 11173 | "};\n" |
| 11174 | "void main(){\n" |
| 11175 | " gl_Position = vec4(0);\n" |
| 11176 | "}\n"; |
| 11177 | char const *fsSource = |
| 11178 | "#version 450\n" |
| 11179 | "\n" |
| 11180 | "layout(location=0) out vec4 color;\n" |
| 11181 | "void main(){\n" |
| 11182 | " color = vec4(1);\n" |
| 11183 | "}\n"; |
| 11184 | |
| 11185 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11186 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11187 | |
| 11188 | VkPipelineObj pipe(m_device); |
| 11189 | pipe.AddColorAttachment(); |
| 11190 | pipe.AddShader(&vs); |
| 11191 | pipe.AddShader(&fs); |
| 11192 | |
| 11193 | VkDescriptorSetObj descriptorSet(m_device); |
| 11194 | descriptorSet.AppendDummy(); |
| 11195 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11196 | |
| 11197 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11198 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11199 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11200 | } |
| 11201 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11202 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 11203 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11204 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11205 | |
| 11206 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 11207 | |
| 11208 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11209 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11210 | |
| 11211 | char const *vsSource = |
| 11212 | "#version 450\n" |
| 11213 | "out gl_PerVertex {\n" |
| 11214 | " vec4 gl_Position;\n" |
| 11215 | "};\n" |
| 11216 | "layout(location=0) out vec3 x;\n" |
| 11217 | "layout(location=1) out ivec3 y;\n" |
| 11218 | "layout(location=2) out vec3 z;\n" |
| 11219 | "void main(){\n" |
| 11220 | " gl_Position = vec4(0);\n" |
| 11221 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 11222 | "}\n"; |
| 11223 | char const *fsSource = |
| 11224 | "#version 450\n" |
| 11225 | "\n" |
| 11226 | "layout(location=0) out vec4 color;\n" |
| 11227 | "layout(location=0) in float x;\n" |
| 11228 | "layout(location=1) flat in int y;\n" |
| 11229 | "layout(location=2) in vec2 z;\n" |
| 11230 | "void main(){\n" |
| 11231 | " color = vec4(1 + x + y + z.x);\n" |
| 11232 | "}\n"; |
| 11233 | |
| 11234 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11235 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11236 | |
| 11237 | VkPipelineObj pipe(m_device); |
| 11238 | pipe.AddColorAttachment(); |
| 11239 | pipe.AddShader(&vs); |
| 11240 | pipe.AddShader(&fs); |
| 11241 | |
| 11242 | VkDescriptorSetObj descriptorSet(m_device); |
| 11243 | descriptorSet.AppendDummy(); |
| 11244 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11245 | |
Mike Stroyan | 255e958 | 2016-06-24 09:49:32 -0600 | [diff] [blame] | 11246 | VkResult err = VK_SUCCESS; |
| 11247 | err = |
| 11248 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11249 | ASSERT_VK_SUCCESS(err); |
| 11250 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11251 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11252 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11253 | } |
| 11254 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11255 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 11256 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11257 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11258 | |
| 11259 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11260 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11261 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 11262 | if (!m_device->phy().features().tessellationShader) { |
| 11263 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 11264 | return; |
| 11265 | } |
| 11266 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11267 | char const *vsSource = |
| 11268 | "#version 450\n" |
| 11269 | "void main(){}\n"; |
| 11270 | char const *tcsSource = |
| 11271 | "#version 450\n" |
| 11272 | "layout(location=0) out int x[];\n" |
| 11273 | "layout(vertices=3) out;\n" |
| 11274 | "void main(){\n" |
| 11275 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 11276 | " gl_TessLevelInner[0] = 1;\n" |
| 11277 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 11278 | "}\n"; |
| 11279 | char const *tesSource = |
| 11280 | "#version 450\n" |
| 11281 | "layout(triangles, equal_spacing, cw) in;\n" |
| 11282 | "layout(location=0) in int x[];\n" |
| 11283 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11284 | "void main(){\n" |
| 11285 | " gl_Position.xyz = gl_TessCoord;\n" |
| 11286 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 11287 | "}\n"; |
| 11288 | char const *fsSource = |
| 11289 | "#version 450\n" |
| 11290 | "layout(location=0) out vec4 color;\n" |
| 11291 | "void main(){\n" |
| 11292 | " color = vec4(1);\n" |
| 11293 | "}\n"; |
| 11294 | |
| 11295 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11296 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 11297 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 11298 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11299 | |
| 11300 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 11301 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 11302 | nullptr, |
| 11303 | 0, |
| 11304 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 11305 | VK_FALSE}; |
| 11306 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 11307 | VkPipelineTessellationStateCreateInfo tsci{ |
| 11308 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 11309 | nullptr, |
| 11310 | 0, |
| 11311 | 3}; |
| 11312 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11313 | VkPipelineObj pipe(m_device); |
| 11314 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 11315 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11316 | pipe.AddColorAttachment(); |
| 11317 | pipe.AddShader(&vs); |
| 11318 | pipe.AddShader(&tcs); |
| 11319 | pipe.AddShader(&tes); |
| 11320 | pipe.AddShader(&fs); |
| 11321 | |
| 11322 | VkDescriptorSetObj descriptorSet(m_device); |
| 11323 | descriptorSet.AppendDummy(); |
| 11324 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11325 | |
| 11326 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11327 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11328 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11329 | } |
| 11330 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 11331 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 11332 | { |
| 11333 | m_errorMonitor->ExpectSuccess(); |
| 11334 | |
| 11335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11336 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11337 | |
| 11338 | if (!m_device->phy().features().geometryShader) { |
| 11339 | printf("Device does not support geometry shaders; skipped.\n"); |
| 11340 | return; |
| 11341 | } |
| 11342 | |
| 11343 | char const *vsSource = |
| 11344 | "#version 450\n" |
| 11345 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 11346 | "void main(){\n" |
| 11347 | " vs_out.x = vec4(1);\n" |
| 11348 | "}\n"; |
| 11349 | char const *gsSource = |
| 11350 | "#version 450\n" |
| 11351 | "layout(triangles) in;\n" |
| 11352 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 11353 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 11354 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11355 | "void main() {\n" |
| 11356 | " gl_Position = gs_in[0].x;\n" |
| 11357 | " EmitVertex();\n" |
| 11358 | "}\n"; |
| 11359 | char const *fsSource = |
| 11360 | "#version 450\n" |
| 11361 | "layout(location=0) out vec4 color;\n" |
| 11362 | "void main(){\n" |
| 11363 | " color = vec4(1);\n" |
| 11364 | "}\n"; |
| 11365 | |
| 11366 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11367 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 11368 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11369 | |
| 11370 | VkPipelineObj pipe(m_device); |
| 11371 | pipe.AddColorAttachment(); |
| 11372 | pipe.AddShader(&vs); |
| 11373 | pipe.AddShader(&gs); |
| 11374 | pipe.AddShader(&fs); |
| 11375 | |
| 11376 | VkDescriptorSetObj descriptorSet(m_device); |
| 11377 | descriptorSet.AppendDummy(); |
| 11378 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11379 | |
| 11380 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11381 | |
| 11382 | m_errorMonitor->VerifyNotFound(); |
| 11383 | } |
| 11384 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11385 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 11386 | { |
| 11387 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11388 | "is per-vertex in tessellation control shader stage " |
| 11389 | "but per-patch in tessellation evaluation shader stage"); |
| 11390 | |
| 11391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11393 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 11394 | if (!m_device->phy().features().tessellationShader) { |
| 11395 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 11396 | return; |
| 11397 | } |
| 11398 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11399 | char const *vsSource = |
| 11400 | "#version 450\n" |
| 11401 | "void main(){}\n"; |
| 11402 | char const *tcsSource = |
| 11403 | "#version 450\n" |
| 11404 | "layout(location=0) out int x[];\n" |
| 11405 | "layout(vertices=3) out;\n" |
| 11406 | "void main(){\n" |
| 11407 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 11408 | " gl_TessLevelInner[0] = 1;\n" |
| 11409 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 11410 | "}\n"; |
| 11411 | char const *tesSource = |
| 11412 | "#version 450\n" |
| 11413 | "layout(triangles, equal_spacing, cw) in;\n" |
| 11414 | "layout(location=0) patch in int x;\n" |
| 11415 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11416 | "void main(){\n" |
| 11417 | " gl_Position.xyz = gl_TessCoord;\n" |
| 11418 | " gl_Position.w = x;\n" |
| 11419 | "}\n"; |
| 11420 | char const *fsSource = |
| 11421 | "#version 450\n" |
| 11422 | "layout(location=0) out vec4 color;\n" |
| 11423 | "void main(){\n" |
| 11424 | " color = vec4(1);\n" |
| 11425 | "}\n"; |
| 11426 | |
| 11427 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11428 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 11429 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 11430 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11431 | |
| 11432 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 11433 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 11434 | nullptr, |
| 11435 | 0, |
| 11436 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 11437 | VK_FALSE}; |
| 11438 | |
| 11439 | VkPipelineTessellationStateCreateInfo tsci{ |
| 11440 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 11441 | nullptr, |
| 11442 | 0, |
| 11443 | 3}; |
| 11444 | |
| 11445 | VkPipelineObj pipe(m_device); |
| 11446 | pipe.SetInputAssembly(&iasci); |
| 11447 | pipe.SetTessellation(&tsci); |
| 11448 | pipe.AddColorAttachment(); |
| 11449 | pipe.AddShader(&vs); |
| 11450 | pipe.AddShader(&tcs); |
| 11451 | pipe.AddShader(&tes); |
| 11452 | pipe.AddShader(&fs); |
| 11453 | |
| 11454 | VkDescriptorSetObj descriptorSet(m_device); |
| 11455 | descriptorSet.AppendDummy(); |
| 11456 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11457 | |
| 11458 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11459 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11460 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11461 | } |
| 11462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11463 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 11464 | m_errorMonitor->SetDesiredFailureMsg( |
| 11465 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11466 | "Duplicate vertex input binding descriptions for binding 0"); |
| 11467 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11468 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 11469 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11470 | |
| 11471 | /* Two binding descriptions for binding 0 */ |
| 11472 | VkVertexInputBindingDescription input_bindings[2]; |
| 11473 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 11474 | |
| 11475 | VkVertexInputAttributeDescription input_attrib; |
| 11476 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 11477 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 11478 | |
| 11479 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11480 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11481 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11482 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11483 | "out gl_PerVertex {\n" |
| 11484 | " vec4 gl_Position;\n" |
| 11485 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11486 | "void main(){\n" |
| 11487 | " gl_Position = vec4(x);\n" |
| 11488 | "}\n"; |
| 11489 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11490 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11491 | "\n" |
| 11492 | "layout(location=0) out vec4 color;\n" |
| 11493 | "void main(){\n" |
| 11494 | " color = vec4(1);\n" |
| 11495 | "}\n"; |
| 11496 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11497 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11498 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11499 | |
| 11500 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11501 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11502 | pipe.AddShader(&vs); |
| 11503 | pipe.AddShader(&fs); |
| 11504 | |
| 11505 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 11506 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 11507 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11508 | VkDescriptorSetObj descriptorSet(m_device); |
| 11509 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11510 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11511 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11512 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11513 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11514 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11515 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 11516 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 11517 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 11518 | m_errorMonitor->ExpectSuccess(); |
| 11519 | |
| 11520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11521 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11522 | |
Chris Forbes | 91cf3a8 | 2016-06-28 17:51:35 +1200 | [diff] [blame] | 11523 | if (!m_device->phy().features().shaderFloat64) { |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 11524 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 11525 | return; |
| 11526 | } |
| 11527 | |
| 11528 | VkVertexInputBindingDescription input_bindings[1]; |
| 11529 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 11530 | |
| 11531 | VkVertexInputAttributeDescription input_attribs[4]; |
| 11532 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11533 | input_attribs[0].location = 0; |
| 11534 | input_attribs[0].offset = 0; |
| 11535 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11536 | input_attribs[1].location = 2; |
| 11537 | input_attribs[1].offset = 32; |
| 11538 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11539 | input_attribs[2].location = 4; |
| 11540 | input_attribs[2].offset = 64; |
| 11541 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11542 | input_attribs[3].location = 6; |
| 11543 | input_attribs[3].offset = 96; |
| 11544 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11545 | |
| 11546 | char const *vsSource = |
| 11547 | "#version 450\n" |
| 11548 | "\n" |
| 11549 | "layout(location=0) in dmat4 x;\n" |
| 11550 | "out gl_PerVertex {\n" |
| 11551 | " vec4 gl_Position;\n" |
| 11552 | "};\n" |
| 11553 | "void main(){\n" |
| 11554 | " gl_Position = vec4(x[0][0]);\n" |
| 11555 | "}\n"; |
| 11556 | char const *fsSource = |
| 11557 | "#version 450\n" |
| 11558 | "\n" |
| 11559 | "layout(location=0) out vec4 color;\n" |
| 11560 | "void main(){\n" |
| 11561 | " color = vec4(1);\n" |
| 11562 | "}\n"; |
| 11563 | |
| 11564 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11565 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11566 | |
| 11567 | VkPipelineObj pipe(m_device); |
| 11568 | pipe.AddColorAttachment(); |
| 11569 | pipe.AddShader(&vs); |
| 11570 | pipe.AddShader(&fs); |
| 11571 | |
| 11572 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 11573 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 11574 | |
| 11575 | VkDescriptorSetObj descriptorSet(m_device); |
| 11576 | descriptorSet.AppendDummy(); |
| 11577 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11578 | |
| 11579 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11580 | |
| 11581 | m_errorMonitor->VerifyNotFound(); |
| 11582 | } |
| 11583 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11584 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11585 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11586 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11587 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11588 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11589 | |
| 11590 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11591 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11592 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11593 | "out gl_PerVertex {\n" |
| 11594 | " vec4 gl_Position;\n" |
| 11595 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11596 | "void main(){\n" |
| 11597 | " gl_Position = vec4(1);\n" |
| 11598 | "}\n"; |
| 11599 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11600 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11601 | "\n" |
| 11602 | "void main(){\n" |
| 11603 | "}\n"; |
| 11604 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11605 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11606 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11607 | |
| 11608 | VkPipelineObj pipe(m_device); |
| 11609 | pipe.AddShader(&vs); |
| 11610 | pipe.AddShader(&fs); |
| 11611 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11612 | /* set up CB 0, not written */ |
| 11613 | pipe.AddColorAttachment(); |
| 11614 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11615 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11616 | VkDescriptorSetObj descriptorSet(m_device); |
| 11617 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11618 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11619 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11620 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11622 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11623 | } |
| 11624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11625 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11626 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11627 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11628 | "FS writes to output location 1 with no matching attachment"); |
| 11629 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11630 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11631 | |
| 11632 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11633 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11634 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11635 | "out gl_PerVertex {\n" |
| 11636 | " vec4 gl_Position;\n" |
| 11637 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11638 | "void main(){\n" |
| 11639 | " gl_Position = vec4(1);\n" |
| 11640 | "}\n"; |
| 11641 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11642 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11643 | "\n" |
| 11644 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11645 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11646 | "void main(){\n" |
| 11647 | " x = vec4(1);\n" |
| 11648 | " y = vec4(1);\n" |
| 11649 | "}\n"; |
| 11650 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11651 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11652 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11653 | |
| 11654 | VkPipelineObj pipe(m_device); |
| 11655 | pipe.AddShader(&vs); |
| 11656 | pipe.AddShader(&fs); |
| 11657 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11658 | /* set up CB 0, not written */ |
| 11659 | pipe.AddColorAttachment(); |
| 11660 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11661 | /* FS writes CB 1, but we don't configure it */ |
| 11662 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11663 | VkDescriptorSetObj descriptorSet(m_device); |
| 11664 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11665 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11666 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11667 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11668 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11669 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11670 | } |
| 11671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11672 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11674 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11675 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11677 | |
| 11678 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11679 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11680 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11681 | "out gl_PerVertex {\n" |
| 11682 | " vec4 gl_Position;\n" |
| 11683 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11684 | "void main(){\n" |
| 11685 | " gl_Position = vec4(1);\n" |
| 11686 | "}\n"; |
| 11687 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11688 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11689 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11690 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11691 | "void main(){\n" |
| 11692 | " x = ivec4(1);\n" |
| 11693 | "}\n"; |
| 11694 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11695 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11696 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11697 | |
| 11698 | VkPipelineObj pipe(m_device); |
| 11699 | pipe.AddShader(&vs); |
| 11700 | pipe.AddShader(&fs); |
| 11701 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11702 | /* set up CB 0; type is UNORM by default */ |
| 11703 | pipe.AddColorAttachment(); |
| 11704 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11705 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11706 | VkDescriptorSetObj descriptorSet(m_device); |
| 11707 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11708 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11709 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11710 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11711 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11712 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11713 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 11714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11715 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11716 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11717 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11718 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11719 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11720 | |
| 11721 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11722 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11723 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11724 | "out gl_PerVertex {\n" |
| 11725 | " vec4 gl_Position;\n" |
| 11726 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11727 | "void main(){\n" |
| 11728 | " gl_Position = vec4(1);\n" |
| 11729 | "}\n"; |
| 11730 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11731 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11732 | "\n" |
| 11733 | "layout(location=0) out vec4 x;\n" |
| 11734 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 11735 | "void main(){\n" |
| 11736 | " x = vec4(bar.y);\n" |
| 11737 | "}\n"; |
| 11738 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11739 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11740 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11741 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11742 | VkPipelineObj pipe(m_device); |
| 11743 | pipe.AddShader(&vs); |
| 11744 | pipe.AddShader(&fs); |
| 11745 | |
| 11746 | /* set up CB 0; type is UNORM by default */ |
| 11747 | pipe.AddColorAttachment(); |
| 11748 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11749 | |
| 11750 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11751 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11752 | |
| 11753 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11754 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11755 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11756 | } |
| 11757 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11758 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 11759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11760 | "not declared in layout"); |
| 11761 | |
| 11762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11763 | |
| 11764 | char const *vsSource = |
| 11765 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11766 | "\n" |
| 11767 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 11768 | "out gl_PerVertex {\n" |
| 11769 | " vec4 gl_Position;\n" |
| 11770 | "};\n" |
| 11771 | "void main(){\n" |
| 11772 | " gl_Position = vec4(consts.x);\n" |
| 11773 | "}\n"; |
| 11774 | char const *fsSource = |
| 11775 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11776 | "\n" |
| 11777 | "layout(location=0) out vec4 x;\n" |
| 11778 | "void main(){\n" |
| 11779 | " x = vec4(1);\n" |
| 11780 | "}\n"; |
| 11781 | |
| 11782 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11783 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11784 | |
| 11785 | VkPipelineObj pipe(m_device); |
| 11786 | pipe.AddShader(&vs); |
| 11787 | pipe.AddShader(&fs); |
| 11788 | |
| 11789 | /* set up CB 0; type is UNORM by default */ |
| 11790 | pipe.AddColorAttachment(); |
| 11791 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11792 | |
| 11793 | VkDescriptorSetObj descriptorSet(m_device); |
| 11794 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11795 | |
| 11796 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11797 | |
| 11798 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11799 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11800 | } |
| 11801 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 11802 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 11803 | m_errorMonitor->SetDesiredFailureMsg( |
| 11804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11805 | "Shader uses descriptor slot 0.0"); |
| 11806 | |
| 11807 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11808 | |
| 11809 | char const *csSource = |
| 11810 | "#version 450\n" |
| 11811 | "\n" |
| 11812 | "layout(local_size_x=1) in;\n" |
| 11813 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11814 | "void main(){\n" |
| 11815 | " x = vec4(1);\n" |
| 11816 | "}\n"; |
| 11817 | |
| 11818 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11819 | |
| 11820 | VkDescriptorSetObj descriptorSet(m_device); |
| 11821 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11822 | |
| 11823 | VkComputePipelineCreateInfo cpci = { |
| 11824 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11825 | nullptr, 0, { |
| 11826 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11827 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11828 | cs.handle(), "main", nullptr |
| 11829 | }, |
| 11830 | descriptorSet.GetPipelineLayout(), |
| 11831 | VK_NULL_HANDLE, -1 |
| 11832 | }; |
| 11833 | |
| 11834 | VkPipeline pipe; |
| 11835 | VkResult err = vkCreateComputePipelines( |
| 11836 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11837 | |
| 11838 | m_errorMonitor->VerifyFound(); |
| 11839 | |
| 11840 | if (err == VK_SUCCESS) { |
| 11841 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11842 | } |
| 11843 | } |
| 11844 | |
| 11845 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 11846 | m_errorMonitor->ExpectSuccess(); |
| 11847 | |
| 11848 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11849 | |
| 11850 | char const *csSource = |
| 11851 | "#version 450\n" |
| 11852 | "\n" |
| 11853 | "layout(local_size_x=1) in;\n" |
| 11854 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11855 | "void main(){\n" |
| 11856 | " // x is not used.\n" |
| 11857 | "}\n"; |
| 11858 | |
| 11859 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11860 | |
| 11861 | VkDescriptorSetObj descriptorSet(m_device); |
| 11862 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11863 | |
| 11864 | VkComputePipelineCreateInfo cpci = { |
| 11865 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11866 | nullptr, 0, { |
| 11867 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11868 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11869 | cs.handle(), "main", nullptr |
| 11870 | }, |
| 11871 | descriptorSet.GetPipelineLayout(), |
| 11872 | VK_NULL_HANDLE, -1 |
| 11873 | }; |
| 11874 | |
| 11875 | VkPipeline pipe; |
| 11876 | VkResult err = vkCreateComputePipelines( |
| 11877 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11878 | |
| 11879 | m_errorMonitor->VerifyNotFound(); |
| 11880 | |
| 11881 | if (err == VK_SUCCESS) { |
| 11882 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11883 | } |
| 11884 | } |
| 11885 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11886 | #endif // SHADER_CHECKER_TESTS |
| 11887 | |
| 11888 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11889 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11890 | m_errorMonitor->SetDesiredFailureMsg( |
| 11891 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11892 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11893 | |
| 11894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11895 | |
| 11896 | // Create an image |
| 11897 | VkImage image; |
| 11898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11899 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11900 | const int32_t tex_width = 32; |
| 11901 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11902 | |
| 11903 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11904 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11905 | image_create_info.pNext = NULL; |
| 11906 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11907 | image_create_info.format = tex_format; |
| 11908 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11909 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11910 | image_create_info.extent.depth = 1; |
| 11911 | image_create_info.mipLevels = 1; |
| 11912 | image_create_info.arrayLayers = 1; |
| 11913 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11914 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11915 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11916 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11917 | |
| 11918 | // Introduce error by sending down a bogus width extent |
| 11919 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11920 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11921 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11922 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11923 | } |
| 11924 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11925 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 11926 | m_errorMonitor->SetDesiredFailureMsg( |
| 11927 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11928 | "CreateImage extents is 0 for at least one required dimension"); |
| 11929 | |
| 11930 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11931 | |
| 11932 | // Create an image |
| 11933 | VkImage image; |
| 11934 | |
| 11935 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11936 | const int32_t tex_width = 32; |
| 11937 | const int32_t tex_height = 32; |
| 11938 | |
| 11939 | VkImageCreateInfo image_create_info = {}; |
| 11940 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11941 | image_create_info.pNext = NULL; |
| 11942 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11943 | image_create_info.format = tex_format; |
| 11944 | image_create_info.extent.width = tex_width; |
| 11945 | image_create_info.extent.height = tex_height; |
| 11946 | image_create_info.extent.depth = 1; |
| 11947 | image_create_info.mipLevels = 1; |
| 11948 | image_create_info.arrayLayers = 1; |
| 11949 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11950 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11951 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11952 | image_create_info.flags = 0; |
| 11953 | |
| 11954 | // Introduce error by sending down a bogus width extent |
| 11955 | image_create_info.extent.width = 0; |
| 11956 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 11957 | |
| 11958 | m_errorMonitor->VerifyFound(); |
| 11959 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11960 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11961 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11962 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11963 | TEST_F(VkLayerTest, InvalidImageView) { |
| 11964 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11965 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11966 | m_errorMonitor->SetDesiredFailureMsg( |
| 11967 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11968 | "vkCreateImageView called with baseMipLevel 10 "); |
| 11969 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11970 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11971 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11972 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11973 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11974 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11975 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11976 | const int32_t tex_width = 32; |
| 11977 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11978 | |
| 11979 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11980 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11981 | image_create_info.pNext = NULL; |
| 11982 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11983 | image_create_info.format = tex_format; |
| 11984 | image_create_info.extent.width = tex_width; |
| 11985 | image_create_info.extent.height = tex_height; |
| 11986 | image_create_info.extent.depth = 1; |
| 11987 | image_create_info.mipLevels = 1; |
| 11988 | image_create_info.arrayLayers = 1; |
| 11989 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11990 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11991 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11992 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11993 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11994 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11995 | ASSERT_VK_SUCCESS(err); |
| 11996 | |
| 11997 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11998 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11999 | image_view_create_info.image = image; |
| 12000 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12001 | image_view_create_info.format = tex_format; |
| 12002 | image_view_create_info.subresourceRange.layerCount = 1; |
| 12003 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 12004 | image_view_create_info.subresourceRange.levelCount = 1; |
| 12005 | image_view_create_info.subresourceRange.aspectMask = |
| 12006 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12007 | |
| 12008 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12009 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 12010 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12011 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12012 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 12013 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12014 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12016 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12017 | TEST_DESCRIPTION( |
| 12018 | "Create an image and try to create a view with an invalid aspectMask"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12020 | "vkCreateImageView: Color image " |
| 12021 | "formats must have ONLY the " |
| 12022 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12023 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12026 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12027 | VkImageObj image(m_device); |
| 12028 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 12029 | VK_IMAGE_TILING_LINEAR, 0); |
| 12030 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12031 | |
| 12032 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12033 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12034 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12035 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12036 | image_view_create_info.format = tex_format; |
| 12037 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 12038 | image_view_create_info.subresourceRange.levelCount = 1; |
| 12039 | // Cause an error by setting an invalid image aspect |
| 12040 | image_view_create_info.subresourceRange.aspectMask = |
| 12041 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12042 | |
| 12043 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12044 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12045 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12046 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12047 | } |
| 12048 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12049 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12050 | VkResult err; |
| 12051 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12053 | m_errorMonitor->SetDesiredFailureMsg( |
| 12054 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12055 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12056 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12057 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12058 | |
| 12059 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12060 | VkImage srcImage; |
| 12061 | VkImage dstImage; |
| 12062 | VkDeviceMemory srcMem; |
| 12063 | VkDeviceMemory destMem; |
| 12064 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12065 | |
| 12066 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12067 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12068 | image_create_info.pNext = NULL; |
| 12069 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12070 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12071 | image_create_info.extent.width = 32; |
| 12072 | image_create_info.extent.height = 32; |
| 12073 | image_create_info.extent.depth = 1; |
| 12074 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12075 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12076 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12077 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12078 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12079 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12081 | err = |
| 12082 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12083 | ASSERT_VK_SUCCESS(err); |
| 12084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12085 | err = |
| 12086 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12087 | ASSERT_VK_SUCCESS(err); |
| 12088 | |
| 12089 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12090 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12091 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12092 | memAlloc.pNext = NULL; |
| 12093 | memAlloc.allocationSize = 0; |
| 12094 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12095 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12096 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12097 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12098 | pass = |
| 12099 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12100 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12101 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12102 | ASSERT_VK_SUCCESS(err); |
| 12103 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12104 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12105 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12106 | pass = |
| 12107 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12108 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12109 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12110 | ASSERT_VK_SUCCESS(err); |
| 12111 | |
| 12112 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12113 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12114 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12115 | ASSERT_VK_SUCCESS(err); |
| 12116 | |
| 12117 | BeginCommandBuffer(); |
| 12118 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12119 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12120 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12121 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12122 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12123 | copyRegion.srcOffset.x = 0; |
| 12124 | copyRegion.srcOffset.y = 0; |
| 12125 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12126 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12127 | copyRegion.dstSubresource.mipLevel = 0; |
| 12128 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12129 | // Introduce failure by forcing the dst layerCount to differ from src |
| 12130 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12131 | copyRegion.dstOffset.x = 0; |
| 12132 | copyRegion.dstOffset.y = 0; |
| 12133 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12134 | copyRegion.extent.width = 1; |
| 12135 | copyRegion.extent.height = 1; |
| 12136 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12137 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12138 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12139 | EndCommandBuffer(); |
| 12140 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12141 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12142 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12143 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12144 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12145 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12146 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12147 | } |
| 12148 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12149 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 12150 | |
| 12151 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 12152 | |
| 12153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12154 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 12155 | VkImageObj image(m_device); |
| 12156 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12157 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12158 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12159 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12160 | ASSERT_TRUE(image.initialized()); |
| 12161 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12162 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 12163 | VkImageCreateInfo image_create_info; |
| 12164 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12165 | image_create_info.pNext = NULL; |
| 12166 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12167 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 12168 | image_create_info.extent.width = 32; |
| 12169 | image_create_info.extent.height = 32; |
| 12170 | image_create_info.extent.depth = 1; |
| 12171 | image_create_info.mipLevels = 1; |
| 12172 | image_create_info.arrayLayers = 1; |
| 12173 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12174 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12175 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12176 | image_create_info.flags = 0; |
| 12177 | |
| 12178 | m_errorMonitor->SetDesiredFailureMsg( |
| 12179 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12180 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 12181 | |
| 12182 | VkImage localImage; |
| 12183 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 12184 | m_errorMonitor->VerifyFound(); |
| 12185 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12186 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12187 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12188 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 12189 | VkFormat format = static_cast<VkFormat>(f); |
| 12190 | VkFormatProperties fProps = m_device->format_properties(format); |
| 12191 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 12192 | fProps.optimalTilingFeatures == 0) { |
| 12193 | unsupported = format; |
| 12194 | break; |
| 12195 | } |
| 12196 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12197 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12198 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12199 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12200 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12201 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12202 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12203 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12204 | m_errorMonitor->VerifyFound(); |
| 12205 | } |
| 12206 | } |
| 12207 | |
| 12208 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 12209 | VkResult ret; |
| 12210 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 12211 | |
| 12212 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12213 | |
| 12214 | VkImageObj image(m_device); |
| 12215 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12216 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12217 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12218 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12219 | ASSERT_TRUE(image.initialized()); |
| 12220 | |
| 12221 | VkImageView imgView; |
| 12222 | VkImageViewCreateInfo imgViewInfo = {}; |
| 12223 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 12224 | imgViewInfo.image = image.handle(); |
| 12225 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12226 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12227 | imgViewInfo.subresourceRange.layerCount = 1; |
| 12228 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 12229 | imgViewInfo.subresourceRange.levelCount = 1; |
| 12230 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12231 | |
| 12232 | m_errorMonitor->SetDesiredFailureMsg( |
| 12233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12234 | "vkCreateImageView called with baseMipLevel"); |
| 12235 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 12236 | // VIEW_CREATE_ERROR |
| 12237 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 12238 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12239 | m_errorMonitor->VerifyFound(); |
| 12240 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 12241 | |
| 12242 | m_errorMonitor->SetDesiredFailureMsg( |
| 12243 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12244 | "vkCreateImageView called with baseArrayLayer"); |
| 12245 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 12246 | // VIEW_CREATE_ERROR |
| 12247 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 12248 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12249 | m_errorMonitor->VerifyFound(); |
| 12250 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 12251 | |
| 12252 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12253 | "vkCreateImageView called with 0 in " |
| 12254 | "pCreateInfo->subresourceRange." |
| 12255 | "levelCount"); |
| 12256 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 12257 | imgViewInfo.subresourceRange.levelCount = 0; |
| 12258 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12259 | m_errorMonitor->VerifyFound(); |
| 12260 | imgViewInfo.subresourceRange.levelCount = 1; |
| 12261 | |
| 12262 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12263 | "vkCreateImageView called with 0 in " |
| 12264 | "pCreateInfo->subresourceRange." |
| 12265 | "layerCount"); |
| 12266 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 12267 | imgViewInfo.subresourceRange.layerCount = 0; |
| 12268 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12269 | m_errorMonitor->VerifyFound(); |
| 12270 | imgViewInfo.subresourceRange.layerCount = 1; |
| 12271 | |
| 12272 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12273 | "but both must be color formats"); |
| 12274 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 12275 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12276 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12277 | m_errorMonitor->VerifyFound(); |
| 12278 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12279 | |
| 12280 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12281 | "Formats MUST be IDENTICAL unless " |
| 12282 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 12283 | "was set on image creation."); |
| 12284 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 12285 | // VIEW_CREATE_ERROR |
| 12286 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 12287 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12288 | m_errorMonitor->VerifyFound(); |
| 12289 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12290 | |
| 12291 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12292 | "can support ImageViews with " |
| 12293 | "differing formats but they must be " |
| 12294 | "in the same compatibility class."); |
| 12295 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 12296 | // VIEW_CREATE_ERROR |
| 12297 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 12298 | VkImage mutImage; |
| 12299 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 12300 | assert( |
| 12301 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 12302 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 12303 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 12304 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12305 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 12306 | ASSERT_VK_SUCCESS(ret); |
| 12307 | imgViewInfo.image = mutImage; |
| 12308 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12309 | m_errorMonitor->VerifyFound(); |
| 12310 | imgViewInfo.image = image.handle(); |
| 12311 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 12312 | } |
| 12313 | |
| 12314 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 12315 | |
| 12316 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 12317 | |
| 12318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12319 | |
| 12320 | VkImageObj image(m_device); |
| 12321 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12322 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12323 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12324 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12325 | ASSERT_TRUE(image.initialized()); |
| 12326 | |
| 12327 | m_errorMonitor->SetDesiredFailureMsg( |
| 12328 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12329 | "number of layers in image subresource is zero"); |
| 12330 | vk_testing::Buffer buffer; |
| 12331 | VkMemoryPropertyFlags reqs = 0; |
| 12332 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 12333 | VkBufferImageCopy region = {}; |
| 12334 | region.bufferRowLength = 128; |
| 12335 | region.bufferImageHeight = 128; |
| 12336 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12337 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 12338 | region.imageSubresource.layerCount = 0; |
| 12339 | region.imageExtent.height = 4; |
| 12340 | region.imageExtent.width = 4; |
| 12341 | region.imageExtent.depth = 1; |
| 12342 | m_commandBuffer->BeginCommandBuffer(); |
| 12343 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 12344 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 12345 | 1, ®ion); |
| 12346 | m_errorMonitor->VerifyFound(); |
| 12347 | region.imageSubresource.layerCount = 1; |
| 12348 | |
| 12349 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12350 | "aspectMasks for each region must " |
| 12351 | "specify only COLOR or DEPTH or " |
| 12352 | "STENCIL"); |
| 12353 | // Expect MISMATCHED_IMAGE_ASPECT |
| 12354 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 12355 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 12356 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 12357 | 1, ®ion); |
| 12358 | m_errorMonitor->VerifyFound(); |
| 12359 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12360 | |
| 12361 | m_errorMonitor->SetDesiredFailureMsg( |
| 12362 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12363 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 12364 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 12365 | // Expect INVALID_FILTER |
| 12366 | VkImageObj intImage1(m_device); |
| 12367 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 12368 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 12369 | 0); |
| 12370 | VkImageObj intImage2(m_device); |
| 12371 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 12372 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 12373 | 0); |
| 12374 | VkImageBlit blitRegion = {}; |
| 12375 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12376 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 12377 | blitRegion.srcSubresource.layerCount = 1; |
| 12378 | blitRegion.srcSubresource.mipLevel = 0; |
| 12379 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12380 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 12381 | blitRegion.dstSubresource.layerCount = 1; |
| 12382 | blitRegion.dstSubresource.mipLevel = 0; |
| 12383 | |
| 12384 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 12385 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 12386 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 12387 | m_errorMonitor->VerifyFound(); |
| 12388 | |
| 12389 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12390 | "called with 0 in ppMemoryBarriers"); |
| 12391 | VkImageMemoryBarrier img_barrier; |
| 12392 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 12393 | img_barrier.pNext = NULL; |
| 12394 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 12395 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 12396 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12397 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12398 | img_barrier.image = image.handle(); |
| 12399 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 12400 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 12401 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12402 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 12403 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 12404 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 12405 | img_barrier.subresourceRange.layerCount = 0; |
| 12406 | img_barrier.subresourceRange.levelCount = 1; |
| 12407 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 12408 | VK_PIPELINE_STAGE_HOST_BIT, |
| 12409 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 12410 | nullptr, 1, &img_barrier); |
| 12411 | m_errorMonitor->VerifyFound(); |
| 12412 | img_barrier.subresourceRange.layerCount = 1; |
| 12413 | } |
| 12414 | |
| 12415 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 12416 | |
| 12417 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 12418 | |
| 12419 | m_errorMonitor->SetDesiredFailureMsg( |
| 12420 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12421 | "CreateImage extents exceed allowable limits for format"); |
| 12422 | VkImageCreateInfo image_create_info = {}; |
| 12423 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12424 | image_create_info.pNext = NULL; |
| 12425 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12426 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12427 | image_create_info.extent.width = 32; |
| 12428 | image_create_info.extent.height = 32; |
| 12429 | image_create_info.extent.depth = 1; |
| 12430 | image_create_info.mipLevels = 1; |
| 12431 | image_create_info.arrayLayers = 1; |
| 12432 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12433 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12434 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12435 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 12436 | image_create_info.flags = 0; |
| 12437 | |
| 12438 | VkImage nullImg; |
| 12439 | VkImageFormatProperties imgFmtProps; |
| 12440 | vkGetPhysicalDeviceImageFormatProperties( |
| 12441 | gpu(), image_create_info.format, image_create_info.imageType, |
| 12442 | image_create_info.tiling, image_create_info.usage, |
| 12443 | image_create_info.flags, &imgFmtProps); |
| 12444 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 12445 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12446 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12447 | m_errorMonitor->VerifyFound(); |
| 12448 | image_create_info.extent.depth = 1; |
| 12449 | |
| 12450 | m_errorMonitor->SetDesiredFailureMsg( |
| 12451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12452 | "exceeds allowable maximum supported by format of"); |
| 12453 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 12454 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12455 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12456 | m_errorMonitor->VerifyFound(); |
| 12457 | image_create_info.mipLevels = 1; |
| 12458 | |
| 12459 | m_errorMonitor->SetDesiredFailureMsg( |
| 12460 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12461 | "exceeds allowable maximum supported by format of"); |
| 12462 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 12463 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12464 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12465 | m_errorMonitor->VerifyFound(); |
| 12466 | image_create_info.arrayLayers = 1; |
| 12467 | |
| 12468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12469 | "is not supported by format"); |
| 12470 | int samples = imgFmtProps.sampleCounts >> 1; |
| 12471 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 12472 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12473 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12474 | m_errorMonitor->VerifyFound(); |
| 12475 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12476 | |
| 12477 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12478 | "pCreateInfo->initialLayout, must be " |
| 12479 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 12480 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 12481 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12482 | // Expect INVALID_LAYOUT |
| 12483 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12484 | m_errorMonitor->VerifyFound(); |
| 12485 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 12486 | } |
| 12487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12488 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 12489 | VkResult err; |
| 12490 | bool pass; |
| 12491 | |
| 12492 | // Create color images with different format sizes and try to copy between them |
| 12493 | m_errorMonitor->SetDesiredFailureMsg( |
| 12494 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12495 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 12496 | |
| 12497 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12498 | |
| 12499 | // Create two images of different types and try to copy between them |
| 12500 | VkImage srcImage; |
| 12501 | VkImage dstImage; |
| 12502 | VkDeviceMemory srcMem; |
| 12503 | VkDeviceMemory destMem; |
| 12504 | VkMemoryRequirements memReqs; |
| 12505 | |
| 12506 | VkImageCreateInfo image_create_info = {}; |
| 12507 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12508 | image_create_info.pNext = NULL; |
| 12509 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12510 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12511 | image_create_info.extent.width = 32; |
| 12512 | image_create_info.extent.height = 32; |
| 12513 | image_create_info.extent.depth = 1; |
| 12514 | image_create_info.mipLevels = 1; |
| 12515 | image_create_info.arrayLayers = 1; |
| 12516 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12517 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12518 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12519 | image_create_info.flags = 0; |
| 12520 | |
| 12521 | err = |
| 12522 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 12523 | ASSERT_VK_SUCCESS(err); |
| 12524 | |
| 12525 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 12526 | // Introduce failure by creating second image with a different-sized format. |
| 12527 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 12528 | |
| 12529 | err = |
| 12530 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 12531 | ASSERT_VK_SUCCESS(err); |
| 12532 | |
| 12533 | // Allocate memory |
| 12534 | VkMemoryAllocateInfo memAlloc = {}; |
| 12535 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12536 | memAlloc.pNext = NULL; |
| 12537 | memAlloc.allocationSize = 0; |
| 12538 | memAlloc.memoryTypeIndex = 0; |
| 12539 | |
| 12540 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 12541 | memAlloc.allocationSize = memReqs.size; |
| 12542 | pass = |
| 12543 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 12544 | ASSERT_TRUE(pass); |
| 12545 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 12546 | ASSERT_VK_SUCCESS(err); |
| 12547 | |
| 12548 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 12549 | memAlloc.allocationSize = memReqs.size; |
| 12550 | pass = |
| 12551 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 12552 | ASSERT_TRUE(pass); |
| 12553 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 12554 | ASSERT_VK_SUCCESS(err); |
| 12555 | |
| 12556 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12557 | ASSERT_VK_SUCCESS(err); |
| 12558 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 12559 | ASSERT_VK_SUCCESS(err); |
| 12560 | |
| 12561 | BeginCommandBuffer(); |
| 12562 | VkImageCopy copyRegion; |
| 12563 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12564 | copyRegion.srcSubresource.mipLevel = 0; |
| 12565 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 12566 | copyRegion.srcSubresource.layerCount = 0; |
| 12567 | copyRegion.srcOffset.x = 0; |
| 12568 | copyRegion.srcOffset.y = 0; |
| 12569 | copyRegion.srcOffset.z = 0; |
| 12570 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12571 | copyRegion.dstSubresource.mipLevel = 0; |
| 12572 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 12573 | copyRegion.dstSubresource.layerCount = 0; |
| 12574 | copyRegion.dstOffset.x = 0; |
| 12575 | copyRegion.dstOffset.y = 0; |
| 12576 | copyRegion.dstOffset.z = 0; |
| 12577 | copyRegion.extent.width = 1; |
| 12578 | copyRegion.extent.height = 1; |
| 12579 | copyRegion.extent.depth = 1; |
| 12580 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12581 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 12582 | EndCommandBuffer(); |
| 12583 | |
| 12584 | m_errorMonitor->VerifyFound(); |
| 12585 | |
| 12586 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 12587 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 12588 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12589 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12590 | } |
| 12591 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12592 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 12593 | VkResult err; |
| 12594 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12595 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12596 | // 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] | 12597 | m_errorMonitor->SetDesiredFailureMsg( |
| 12598 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12599 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12600 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12601 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12602 | |
| 12603 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12604 | VkImage srcImage; |
| 12605 | VkImage dstImage; |
| 12606 | VkDeviceMemory srcMem; |
| 12607 | VkDeviceMemory destMem; |
| 12608 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12609 | |
| 12610 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12611 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12612 | image_create_info.pNext = NULL; |
| 12613 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12614 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12615 | image_create_info.extent.width = 32; |
| 12616 | image_create_info.extent.height = 32; |
| 12617 | image_create_info.extent.depth = 1; |
| 12618 | image_create_info.mipLevels = 1; |
| 12619 | image_create_info.arrayLayers = 1; |
| 12620 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12621 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12622 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12623 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12625 | err = |
| 12626 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12627 | ASSERT_VK_SUCCESS(err); |
| 12628 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 12629 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 12630 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12631 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12632 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12633 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12634 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12635 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12636 | err = |
| 12637 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12638 | ASSERT_VK_SUCCESS(err); |
| 12639 | |
| 12640 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12641 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12642 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12643 | memAlloc.pNext = NULL; |
| 12644 | memAlloc.allocationSize = 0; |
| 12645 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12646 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12647 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12648 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12649 | pass = |
| 12650 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12651 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12652 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12653 | ASSERT_VK_SUCCESS(err); |
| 12654 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12655 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12656 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12657 | pass = |
| 12658 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12659 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12660 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12661 | ASSERT_VK_SUCCESS(err); |
| 12662 | |
| 12663 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12664 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12665 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12666 | ASSERT_VK_SUCCESS(err); |
| 12667 | |
| 12668 | BeginCommandBuffer(); |
| 12669 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12670 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12671 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12672 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12673 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12674 | copyRegion.srcOffset.x = 0; |
| 12675 | copyRegion.srcOffset.y = 0; |
| 12676 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12677 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12678 | copyRegion.dstSubresource.mipLevel = 0; |
| 12679 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 12680 | copyRegion.dstSubresource.layerCount = 0; |
| 12681 | copyRegion.dstOffset.x = 0; |
| 12682 | copyRegion.dstOffset.y = 0; |
| 12683 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12684 | copyRegion.extent.width = 1; |
| 12685 | copyRegion.extent.height = 1; |
| 12686 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12687 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12688 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12689 | EndCommandBuffer(); |
| 12690 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12691 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12692 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12693 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12694 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12695 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12696 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12697 | } |
| 12698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12699 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 12700 | VkResult err; |
| 12701 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12703 | m_errorMonitor->SetDesiredFailureMsg( |
| 12704 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12705 | "vkCmdResolveImage called with source sample count less than 2."); |
| 12706 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12708 | |
| 12709 | // 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] | 12710 | VkImage srcImage; |
| 12711 | VkImage dstImage; |
| 12712 | VkDeviceMemory srcMem; |
| 12713 | VkDeviceMemory destMem; |
| 12714 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12715 | |
| 12716 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12717 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12718 | image_create_info.pNext = NULL; |
| 12719 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12720 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12721 | image_create_info.extent.width = 32; |
| 12722 | image_create_info.extent.height = 1; |
| 12723 | image_create_info.extent.depth = 1; |
| 12724 | image_create_info.mipLevels = 1; |
| 12725 | image_create_info.arrayLayers = 1; |
| 12726 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12727 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12728 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12729 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12731 | err = |
| 12732 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12733 | ASSERT_VK_SUCCESS(err); |
| 12734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12735 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12736 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12737 | err = |
| 12738 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12739 | ASSERT_VK_SUCCESS(err); |
| 12740 | |
| 12741 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12742 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12743 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12744 | memAlloc.pNext = NULL; |
| 12745 | memAlloc.allocationSize = 0; |
| 12746 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12747 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12748 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12749 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12750 | pass = |
| 12751 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12752 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12753 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12754 | ASSERT_VK_SUCCESS(err); |
| 12755 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12756 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12757 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12758 | pass = |
| 12759 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12760 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12761 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12762 | ASSERT_VK_SUCCESS(err); |
| 12763 | |
| 12764 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12765 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12766 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12767 | ASSERT_VK_SUCCESS(err); |
| 12768 | |
| 12769 | BeginCommandBuffer(); |
| 12770 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12771 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12772 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12773 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12774 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12775 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12776 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12777 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12778 | resolveRegion.srcOffset.x = 0; |
| 12779 | resolveRegion.srcOffset.y = 0; |
| 12780 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12781 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12782 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12783 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12784 | resolveRegion.dstSubresource.layerCount = 0; |
| 12785 | resolveRegion.dstOffset.x = 0; |
| 12786 | resolveRegion.dstOffset.y = 0; |
| 12787 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12788 | resolveRegion.extent.width = 1; |
| 12789 | resolveRegion.extent.height = 1; |
| 12790 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12791 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12792 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12793 | EndCommandBuffer(); |
| 12794 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12795 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12796 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12797 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12798 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12799 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12800 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12801 | } |
| 12802 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12803 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 12804 | VkResult err; |
| 12805 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12806 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12807 | m_errorMonitor->SetDesiredFailureMsg( |
| 12808 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12809 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 12810 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12811 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12812 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12813 | // Create two images of sample count 4 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12814 | VkImage srcImage; |
| 12815 | VkImage dstImage; |
| 12816 | VkDeviceMemory srcMem; |
| 12817 | VkDeviceMemory destMem; |
| 12818 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12819 | |
| 12820 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12821 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12822 | image_create_info.pNext = NULL; |
| 12823 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12824 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12825 | image_create_info.extent.width = 32; |
| 12826 | image_create_info.extent.height = 1; |
| 12827 | image_create_info.extent.depth = 1; |
| 12828 | image_create_info.mipLevels = 1; |
| 12829 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12830 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12831 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12832 | // Note: Some implementations expect color attachment usage for any |
| 12833 | // multisample surface |
| 12834 | image_create_info.usage = |
| 12835 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12836 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12838 | err = |
| 12839 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12840 | ASSERT_VK_SUCCESS(err); |
| 12841 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12842 | // Note: Some implementations expect color attachment usage for any |
| 12843 | // multisample surface |
| 12844 | image_create_info.usage = |
| 12845 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12846 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12847 | err = |
| 12848 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12849 | ASSERT_VK_SUCCESS(err); |
| 12850 | |
| 12851 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12852 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12853 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12854 | memAlloc.pNext = NULL; |
| 12855 | memAlloc.allocationSize = 0; |
| 12856 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12857 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12858 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12859 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12860 | pass = |
| 12861 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12862 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12863 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12864 | ASSERT_VK_SUCCESS(err); |
| 12865 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12866 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12867 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12868 | pass = |
| 12869 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12870 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12871 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12872 | ASSERT_VK_SUCCESS(err); |
| 12873 | |
| 12874 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12875 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12876 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12877 | ASSERT_VK_SUCCESS(err); |
| 12878 | |
| 12879 | BeginCommandBuffer(); |
| 12880 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12881 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12882 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12883 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12884 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12885 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12886 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12887 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12888 | resolveRegion.srcOffset.x = 0; |
| 12889 | resolveRegion.srcOffset.y = 0; |
| 12890 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12891 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12892 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12893 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12894 | resolveRegion.dstSubresource.layerCount = 0; |
| 12895 | resolveRegion.dstOffset.x = 0; |
| 12896 | resolveRegion.dstOffset.y = 0; |
| 12897 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12898 | resolveRegion.extent.width = 1; |
| 12899 | resolveRegion.extent.height = 1; |
| 12900 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12901 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12902 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12903 | EndCommandBuffer(); |
| 12904 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12905 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12906 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12907 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12908 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12909 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12910 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12911 | } |
| 12912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12913 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 12914 | VkResult err; |
| 12915 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12916 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12917 | m_errorMonitor->SetDesiredFailureMsg( |
| 12918 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12919 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 12920 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12922 | |
| 12923 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12924 | VkImage srcImage; |
| 12925 | VkImage dstImage; |
| 12926 | VkDeviceMemory srcMem; |
| 12927 | VkDeviceMemory destMem; |
| 12928 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12929 | |
| 12930 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12931 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12932 | image_create_info.pNext = NULL; |
| 12933 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12934 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12935 | image_create_info.extent.width = 32; |
| 12936 | image_create_info.extent.height = 1; |
| 12937 | image_create_info.extent.depth = 1; |
| 12938 | image_create_info.mipLevels = 1; |
| 12939 | image_create_info.arrayLayers = 1; |
| 12940 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 12941 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12942 | // Note: Some implementations expect color attachment usage for any |
| 12943 | // multisample surface |
| 12944 | image_create_info.usage = |
| 12945 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12946 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12948 | err = |
| 12949 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12950 | ASSERT_VK_SUCCESS(err); |
| 12951 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12952 | // Set format to something other than source image |
| 12953 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 12954 | // Note: Some implementations expect color attachment usage for any |
| 12955 | // multisample surface |
| 12956 | image_create_info.usage = |
| 12957 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12958 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12959 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12960 | err = |
| 12961 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12962 | ASSERT_VK_SUCCESS(err); |
| 12963 | |
| 12964 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12965 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12966 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12967 | memAlloc.pNext = NULL; |
| 12968 | memAlloc.allocationSize = 0; |
| 12969 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12970 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12971 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12972 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12973 | pass = |
| 12974 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12975 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12976 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12977 | ASSERT_VK_SUCCESS(err); |
| 12978 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12979 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12980 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12981 | pass = |
| 12982 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12983 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12984 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12985 | ASSERT_VK_SUCCESS(err); |
| 12986 | |
| 12987 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12988 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12989 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12990 | ASSERT_VK_SUCCESS(err); |
| 12991 | |
| 12992 | BeginCommandBuffer(); |
| 12993 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12994 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12995 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12996 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12997 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12998 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12999 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13000 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13001 | resolveRegion.srcOffset.x = 0; |
| 13002 | resolveRegion.srcOffset.y = 0; |
| 13003 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13004 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13005 | resolveRegion.dstSubresource.mipLevel = 0; |
| 13006 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 13007 | resolveRegion.dstSubresource.layerCount = 0; |
| 13008 | resolveRegion.dstOffset.x = 0; |
| 13009 | resolveRegion.dstOffset.y = 0; |
| 13010 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13011 | resolveRegion.extent.width = 1; |
| 13012 | resolveRegion.extent.height = 1; |
| 13013 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13014 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 13015 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13016 | EndCommandBuffer(); |
| 13017 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13018 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13019 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13020 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13021 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13022 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 13023 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13024 | } |
| 13025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13026 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 13027 | VkResult err; |
| 13028 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13029 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13030 | m_errorMonitor->SetDesiredFailureMsg( |
| 13031 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13032 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 13033 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13034 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13035 | |
| 13036 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13037 | VkImage srcImage; |
| 13038 | VkImage dstImage; |
| 13039 | VkDeviceMemory srcMem; |
| 13040 | VkDeviceMemory destMem; |
| 13041 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13042 | |
| 13043 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13044 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13045 | image_create_info.pNext = NULL; |
| 13046 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13047 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 13048 | image_create_info.extent.width = 32; |
| 13049 | image_create_info.extent.height = 1; |
| 13050 | image_create_info.extent.depth = 1; |
| 13051 | image_create_info.mipLevels = 1; |
| 13052 | image_create_info.arrayLayers = 1; |
| 13053 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 13054 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13055 | // Note: Some implementations expect color attachment usage for any |
| 13056 | // multisample surface |
| 13057 | image_create_info.usage = |
| 13058 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13059 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13060 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13061 | err = |
| 13062 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13063 | ASSERT_VK_SUCCESS(err); |
| 13064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13065 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 13066 | // Note: Some implementations expect color attachment usage for any |
| 13067 | // multisample surface |
| 13068 | image_create_info.usage = |
| 13069 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13070 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13071 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13072 | err = |
| 13073 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13074 | ASSERT_VK_SUCCESS(err); |
| 13075 | |
| 13076 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13077 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13078 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 13079 | memAlloc.pNext = NULL; |
| 13080 | memAlloc.allocationSize = 0; |
| 13081 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13082 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 13083 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13084 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13085 | pass = |
| 13086 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13087 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13088 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13089 | ASSERT_VK_SUCCESS(err); |
| 13090 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13091 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13092 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13093 | pass = |
| 13094 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13095 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13096 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13097 | ASSERT_VK_SUCCESS(err); |
| 13098 | |
| 13099 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 13100 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13101 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13102 | ASSERT_VK_SUCCESS(err); |
| 13103 | |
| 13104 | BeginCommandBuffer(); |
| 13105 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13106 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 13107 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13108 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13109 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13110 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 13111 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13112 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13113 | resolveRegion.srcOffset.x = 0; |
| 13114 | resolveRegion.srcOffset.y = 0; |
| 13115 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13116 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13117 | resolveRegion.dstSubresource.mipLevel = 0; |
| 13118 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 13119 | resolveRegion.dstSubresource.layerCount = 0; |
| 13120 | resolveRegion.dstOffset.x = 0; |
| 13121 | resolveRegion.dstOffset.y = 0; |
| 13122 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13123 | resolveRegion.extent.width = 1; |
| 13124 | resolveRegion.extent.height = 1; |
| 13125 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13126 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 13127 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13128 | EndCommandBuffer(); |
| 13129 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13130 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13131 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13132 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13133 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13134 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 13135 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13136 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13137 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13138 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13139 | // 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] | 13140 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 13141 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13142 | // The image format check comes 2nd in validation so we trigger it first, |
| 13143 | // 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] | 13144 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13146 | m_errorMonitor->SetDesiredFailureMsg( |
| 13147 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13148 | "Combination depth/stencil image formats can have only the "); |
| 13149 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13150 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13151 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 13152 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13153 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 13154 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13155 | |
| 13156 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13157 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 13158 | ds_pool_ci.pNext = NULL; |
| 13159 | ds_pool_ci.maxSets = 1; |
| 13160 | ds_pool_ci.poolSizeCount = 1; |
| 13161 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13162 | |
| 13163 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13164 | err = |
| 13165 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13166 | ASSERT_VK_SUCCESS(err); |
| 13167 | |
| 13168 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13169 | dsl_binding.binding = 0; |
| 13170 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 13171 | dsl_binding.descriptorCount = 1; |
| 13172 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 13173 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13174 | |
| 13175 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13176 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 13177 | ds_layout_ci.pNext = NULL; |
| 13178 | ds_layout_ci.bindingCount = 1; |
| 13179 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13180 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13181 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 13182 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13183 | ASSERT_VK_SUCCESS(err); |
| 13184 | |
| 13185 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13186 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 13187 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 13188 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13189 | alloc_info.descriptorPool = ds_pool; |
| 13190 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13191 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 13192 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13193 | ASSERT_VK_SUCCESS(err); |
| 13194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13195 | VkImage image_bad; |
| 13196 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13197 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 13198 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13199 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13200 | const int32_t tex_width = 32; |
| 13201 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13202 | |
| 13203 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13204 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13205 | image_create_info.pNext = NULL; |
| 13206 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13207 | image_create_info.format = tex_format_bad; |
| 13208 | image_create_info.extent.width = tex_width; |
| 13209 | image_create_info.extent.height = tex_height; |
| 13210 | image_create_info.extent.depth = 1; |
| 13211 | image_create_info.mipLevels = 1; |
| 13212 | image_create_info.arrayLayers = 1; |
| 13213 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 13214 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13215 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 13216 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 13217 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13219 | err = |
| 13220 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13221 | ASSERT_VK_SUCCESS(err); |
| 13222 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13223 | image_create_info.usage = |
| 13224 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13225 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 13226 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13227 | ASSERT_VK_SUCCESS(err); |
| 13228 | |
| 13229 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13230 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13231 | image_view_create_info.image = image_bad; |
| 13232 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 13233 | image_view_create_info.format = tex_format_bad; |
| 13234 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 13235 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 13236 | image_view_create_info.subresourceRange.layerCount = 1; |
| 13237 | image_view_create_info.subresourceRange.levelCount = 1; |
| 13238 | image_view_create_info.subresourceRange.aspectMask = |
| 13239 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13240 | |
| 13241 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13242 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 13243 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13244 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13245 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13246 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13247 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 13248 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13249 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 13250 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13251 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 13252 | |
| 13253 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 13254 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 13255 | "ClearDepthStencilImage with a color image."); |
| 13256 | |
| 13257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 13258 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 13259 | |
| 13260 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 13261 | BeginCommandBuffer(); |
| 13262 | m_commandBuffer->EndRenderPass(); |
| 13263 | |
| 13264 | // Color image |
| 13265 | VkClearColorValue clear_color; |
| 13266 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 13267 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 13268 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 13269 | const int32_t img_width = 32; |
| 13270 | const int32_t img_height = 32; |
| 13271 | VkImageCreateInfo image_create_info = {}; |
| 13272 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13273 | image_create_info.pNext = NULL; |
| 13274 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13275 | image_create_info.format = color_format; |
| 13276 | image_create_info.extent.width = img_width; |
| 13277 | image_create_info.extent.height = img_height; |
| 13278 | image_create_info.extent.depth = 1; |
| 13279 | image_create_info.mipLevels = 1; |
| 13280 | image_create_info.arrayLayers = 1; |
| 13281 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 13282 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 13283 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 13284 | |
| 13285 | vk_testing::Image color_image; |
| 13286 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 13287 | reqs); |
| 13288 | |
| 13289 | const VkImageSubresourceRange color_range = |
| 13290 | vk_testing::Image::subresource_range(image_create_info, |
| 13291 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 13292 | |
| 13293 | // Depth/Stencil image |
| 13294 | VkClearDepthStencilValue clear_value = {0}; |
| 13295 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 13296 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 13297 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13298 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 13299 | ds_image_create_info.extent.width = 64; |
| 13300 | ds_image_create_info.extent.height = 64; |
| 13301 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13302 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 13303 | |
| 13304 | vk_testing::Image ds_image; |
| 13305 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 13306 | reqs); |
| 13307 | |
| 13308 | const VkImageSubresourceRange ds_range = |
| 13309 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 13310 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 13311 | |
| 13312 | m_errorMonitor->SetDesiredFailureMsg( |
| 13313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13314 | "vkCmdClearColorImage called with depth/stencil image."); |
| 13315 | |
| 13316 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 13317 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 13318 | &color_range); |
| 13319 | |
| 13320 | m_errorMonitor->VerifyFound(); |
| 13321 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 13322 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13323 | "vkCmdClearColorImage called with " |
| 13324 | "image created without " |
| 13325 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 13326 | |
| 13327 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 13328 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 13329 | &color_range); |
| 13330 | |
| 13331 | m_errorMonitor->VerifyFound(); |
| 13332 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 13333 | // Call CmdClearDepthStencilImage with color image |
| 13334 | m_errorMonitor->SetDesiredFailureMsg( |
| 13335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13336 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 13337 | |
| 13338 | vkCmdClearDepthStencilImage( |
| 13339 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 13340 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 13341 | &ds_range); |
| 13342 | |
| 13343 | m_errorMonitor->VerifyFound(); |
| 13344 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13345 | #endif // IMAGE_TESTS |
| 13346 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13347 | int main(int argc, char **argv) { |
| 13348 | int result; |
| 13349 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 13350 | #ifdef ANDROID |
| 13351 | int vulkanSupport = InitVulkan(); |
| 13352 | if (vulkanSupport == 0) |
| 13353 | return 1; |
| 13354 | #endif |
| 13355 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13356 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 13357 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13358 | |
| 13359 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 13360 | |
| 13361 | result = RUN_ALL_TESTS(); |
| 13362 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 13363 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13364 | return result; |
| 13365 | } |