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, |
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3088 | rp, fb, { { 0, 0 } , { 32, 32 } }, |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 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, |
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3191 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 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, |
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3265 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 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) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 3500 | TEST_DESCRIPTION("Ensure that CreateRenderPass produces a validation error " |
| 3501 | "when the source of a subpass multisample resolve " |
| 3502 | "does not have multiple samples."); |
| 3503 | |
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 3504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3505 | |
| 3506 | m_errorMonitor->SetDesiredFailureMsg( |
| 3507 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 3508 | "Subpass 0 requests multisample resolve from attachment 0 which has " |
| 3509 | "VK_SAMPLE_COUNT_1_BIT"); |
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 3510 | |
| 3511 | VkAttachmentDescription attachments[] = { |
| 3512 | { |
| 3513 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3514 | VK_SAMPLE_COUNT_1_BIT, |
| 3515 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3516 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3517 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3518 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3519 | }, |
| 3520 | { |
| 3521 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3522 | VK_SAMPLE_COUNT_1_BIT, |
| 3523 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3524 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3525 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3526 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3527 | }, |
| 3528 | }; |
| 3529 | |
| 3530 | VkAttachmentReference color = { |
| 3531 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3532 | }; |
| 3533 | |
| 3534 | VkAttachmentReference resolve = { |
| 3535 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3536 | }; |
| 3537 | |
| 3538 | VkSubpassDescription subpass = { |
| 3539 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3540 | 0, nullptr, |
| 3541 | 1, &color, |
| 3542 | &resolve, |
| 3543 | nullptr, |
| 3544 | 0, nullptr |
| 3545 | }; |
| 3546 | |
| 3547 | VkRenderPassCreateInfo rpci = { |
| 3548 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3549 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3550 | }; |
| 3551 | |
| 3552 | VkRenderPass rp; |
| 3553 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3554 | |
| 3555 | m_errorMonitor->VerifyFound(); |
| 3556 | |
| 3557 | if (err == VK_SUCCESS) |
| 3558 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3559 | } |
| 3560 | |
| 3561 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresSingleSampleDest) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 3562 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
| 3563 | "when a subpass multisample resolve operation is " |
| 3564 | "requested, and the destination of that resolve has " |
| 3565 | "multiple samples."); |
| 3566 | |
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 3567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3568 | |
| 3569 | m_errorMonitor->SetDesiredFailureMsg( |
| 3570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3571 | "Subpass 0 requests multisample resolve into attachment 1, which " |
| 3572 | "must have VK_SAMPLE_COUNT_1_BIT but has VK_SAMPLE_COUNT_4_BIT"); |
| 3573 | |
| 3574 | VkAttachmentDescription attachments[] = { |
| 3575 | { |
| 3576 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3577 | VK_SAMPLE_COUNT_4_BIT, |
| 3578 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3579 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3580 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3581 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3582 | }, |
| 3583 | { |
| 3584 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3585 | VK_SAMPLE_COUNT_4_BIT, |
| 3586 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3587 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3588 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3589 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3590 | }, |
| 3591 | }; |
| 3592 | |
| 3593 | VkAttachmentReference color = { |
| 3594 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3595 | }; |
| 3596 | |
| 3597 | VkAttachmentReference resolve = { |
| 3598 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3599 | }; |
| 3600 | |
| 3601 | VkSubpassDescription subpass = { |
| 3602 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3603 | 0, nullptr, |
| 3604 | 1, &color, |
| 3605 | &resolve, |
| 3606 | nullptr, |
| 3607 | 0, nullptr |
| 3608 | }; |
| 3609 | |
| 3610 | VkRenderPassCreateInfo rpci = { |
| 3611 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3612 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3613 | }; |
| 3614 | |
| 3615 | VkRenderPass rp; |
| 3616 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3617 | |
| 3618 | m_errorMonitor->VerifyFound(); |
| 3619 | |
| 3620 | if (err == VK_SUCCESS) |
| 3621 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3622 | } |
| 3623 | |
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 3624 | TEST_F(VkLayerTest, CreateRenderPassSubpassSampleCountConsistency) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 3625 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
| 3626 | "when the color and depth attachments used by a subpass " |
| 3627 | "have inconsistent sample counts"); |
| 3628 | |
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 3629 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3630 | |
| 3631 | m_errorMonitor->SetDesiredFailureMsg( |
| 3632 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3633 | "Subpass 0 attempts to render to attachments with inconsistent sample counts"); |
| 3634 | |
| 3635 | VkAttachmentDescription attachments[] = { |
| 3636 | { |
| 3637 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3638 | VK_SAMPLE_COUNT_1_BIT, |
| 3639 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3640 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3641 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3642 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3643 | }, |
| 3644 | { |
| 3645 | 0, VK_FORMAT_R8G8B8A8_UNORM, |
| 3646 | VK_SAMPLE_COUNT_4_BIT, |
| 3647 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3648 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 3649 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3650 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 3651 | }, |
| 3652 | }; |
| 3653 | |
| 3654 | VkAttachmentReference color[] = { |
| 3655 | { |
| 3656 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3657 | }, |
| 3658 | { |
| 3659 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, |
| 3660 | }, |
| 3661 | }; |
| 3662 | |
| 3663 | VkSubpassDescription subpass = { |
| 3664 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3665 | 0, nullptr, |
| 3666 | 2, color, |
| 3667 | nullptr, |
| 3668 | nullptr, |
| 3669 | 0, nullptr |
| 3670 | }; |
| 3671 | |
| 3672 | VkRenderPassCreateInfo rpci = { |
| 3673 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, |
| 3674 | 0, 2, attachments, 1, &subpass, 0, nullptr |
| 3675 | }; |
| 3676 | |
| 3677 | VkRenderPass rp; |
| 3678 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
| 3679 | |
| 3680 | m_errorMonitor->VerifyFound(); |
| 3681 | |
| 3682 | if (err == VK_SUCCESS) |
| 3683 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3684 | } |
| 3685 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3686 | TEST_F(VkLayerTest, FramebufferCreateErrors) { |
| 3687 | TEST_DESCRIPTION("Hit errors when attempting to create a framebuffer :\n" |
| 3688 | " 1. Mismatch between fb & renderPass attachmentCount\n" |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3689 | " 2. Use a color image as depthStencil attachment\n" |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3690 | " 3. Mismatch fb & renderPass attachment formats\n" |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3691 | " 4. Mismatch fb & renderPass attachment #samples\n" |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3692 | " 5. FB attachment w/ non-1 mip-levels\n" |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 3693 | " 6. FB attachment where dimensions don't match\n" |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 3694 | " 7. FB attachment w/o identity swizzle\n" |
| 3695 | " 8. FB dimensions exceed physical device limits\n"); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3696 | |
| 3697 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3698 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3699 | |
| 3700 | m_errorMonitor->SetDesiredFailureMsg( |
| 3701 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3702 | "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of 2 " |
| 3703 | "does not match attachmentCount of 1 of "); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3704 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3705 | // Create a renderPass with a single color attachment |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3706 | VkAttachmentReference attach = {}; |
| 3707 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 3708 | VkSubpassDescription subpass = {}; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3709 | subpass.pColorAttachments = &attach; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3710 | VkRenderPassCreateInfo rpci = {}; |
| 3711 | rpci.subpassCount = 1; |
| 3712 | rpci.pSubpasses = &subpass; |
| 3713 | rpci.attachmentCount = 1; |
| 3714 | VkAttachmentDescription attach_desc = {}; |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3715 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3716 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3717 | rpci.pAttachments = &attach_desc; |
| 3718 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3719 | VkRenderPass rp; |
| 3720 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3721 | ASSERT_VK_SUCCESS(err); |
| 3722 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3723 | VkImageView ivs[2]; |
| 3724 | ivs[0] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
| 3725 | ivs[1] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3726 | VkFramebufferCreateInfo fb_info = {}; |
| 3727 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 3728 | fb_info.pNext = NULL; |
| 3729 | fb_info.renderPass = rp; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3730 | // Set mis-matching attachmentCount |
| 3731 | fb_info.attachmentCount = 2; |
| 3732 | fb_info.pAttachments = ivs; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3733 | fb_info.width = 100; |
| 3734 | fb_info.height = 100; |
| 3735 | fb_info.layers = 1; |
| 3736 | |
| 3737 | VkFramebuffer fb; |
| 3738 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3739 | |
| 3740 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3741 | if (err == VK_SUCCESS) { |
| 3742 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3743 | } |
| 3744 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3745 | |
| 3746 | // Create a renderPass with a depth-stencil attachment created with |
| 3747 | // IMAGE_USAGE_COLOR_ATTACHMENT |
| 3748 | // Add our color attachment to pDepthStencilAttachment |
| 3749 | subpass.pDepthStencilAttachment = &attach; |
| 3750 | subpass.pColorAttachments = NULL; |
| 3751 | VkRenderPass rp_ds; |
| 3752 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp_ds); |
| 3753 | ASSERT_VK_SUCCESS(err); |
| 3754 | // Set correct attachment count, but attachment has COLOR usage bit set |
| 3755 | fb_info.attachmentCount = 1; |
| 3756 | fb_info.renderPass = rp_ds; |
| 3757 | |
| 3758 | m_errorMonitor->SetDesiredFailureMsg( |
| 3759 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3760 | " conflicts with the image's IMAGE_USAGE flags "); |
| 3761 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3762 | |
| 3763 | m_errorMonitor->VerifyFound(); |
| 3764 | if (err == VK_SUCCESS) { |
| 3765 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3766 | } |
| 3767 | vkDestroyRenderPass(m_device->device(), rp_ds, NULL); |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3768 | |
| 3769 | // Create new renderpass with alternate attachment format from fb |
| 3770 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3771 | subpass.pDepthStencilAttachment = NULL; |
| 3772 | subpass.pColorAttachments = &attach; |
| 3773 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3774 | ASSERT_VK_SUCCESS(err); |
| 3775 | |
| 3776 | // Cause error due to mis-matched formats between rp & fb |
| 3777 | // rp attachment 0 now has RGBA8 but corresponding fb attach is BGRA8 |
| 3778 | fb_info.renderPass = rp; |
| 3779 | m_errorMonitor->SetDesiredFailureMsg( |
| 3780 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3781 | " has format of VK_FORMAT_B8G8R8A8_UNORM that does not match "); |
| 3782 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3783 | |
| 3784 | m_errorMonitor->VerifyFound(); |
| 3785 | if (err == VK_SUCCESS) { |
| 3786 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3787 | } |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3788 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3789 | |
| 3790 | // Create new renderpass with alternate sample count from fb |
| 3791 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3792 | attach_desc.samples = VK_SAMPLE_COUNT_4_BIT; |
| 3793 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3794 | ASSERT_VK_SUCCESS(err); |
| 3795 | |
| 3796 | // Cause error due to mis-matched sample count between rp & fb |
| 3797 | fb_info.renderPass = rp; |
| 3798 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3799 | " has VK_SAMPLE_COUNT_1_BIT samples " |
| 3800 | "that do not match the " |
| 3801 | "VK_SAMPLE_COUNT_4_BIT "); |
| 3802 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3803 | |
| 3804 | m_errorMonitor->VerifyFound(); |
| 3805 | if (err == VK_SUCCESS) { |
| 3806 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3807 | } |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3808 | |
| 3809 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3810 | |
| 3811 | // Create a custom imageView with non-1 mip levels |
| 3812 | VkImageObj image(m_device); |
| 3813 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 3814 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 3815 | ASSERT_TRUE(image.initialized()); |
| 3816 | |
| 3817 | VkImageView view; |
| 3818 | VkImageViewCreateInfo ivci = {}; |
| 3819 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3820 | ivci.image = image.handle(); |
| 3821 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3822 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3823 | ivci.subresourceRange.layerCount = 1; |
| 3824 | ivci.subresourceRange.baseMipLevel = 0; |
| 3825 | // Set level count 2 (only 1 is allowed for FB attachment) |
| 3826 | ivci.subresourceRange.levelCount = 2; |
| 3827 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3828 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); |
| 3829 | ASSERT_VK_SUCCESS(err); |
| 3830 | // Re-create renderpass to have matching sample count |
| 3831 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3832 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3833 | ASSERT_VK_SUCCESS(err); |
| 3834 | |
| 3835 | fb_info.renderPass = rp; |
| 3836 | fb_info.pAttachments = &view; |
| 3837 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3838 | " has mip levelCount of 2 but only "); |
| 3839 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3840 | |
| 3841 | m_errorMonitor->VerifyFound(); |
| 3842 | if (err == VK_SUCCESS) { |
| 3843 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3844 | } |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3845 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3846 | // Update view to original color buffer and grow FB dimensions too big |
| 3847 | fb_info.pAttachments = ivs; |
| 3848 | fb_info.height = 1024; |
| 3849 | fb_info.width = 1024; |
| 3850 | fb_info.layers = 2; |
| 3851 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3852 | " Attachment dimensions must be at " |
| 3853 | "least as large. "); |
| 3854 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3855 | |
| 3856 | m_errorMonitor->VerifyFound(); |
| 3857 | if (err == VK_SUCCESS) { |
| 3858 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3859 | } |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 3860 | // Create view attachment with non-identity swizzle |
| 3861 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3862 | ivci.image = image.handle(); |
| 3863 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3864 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3865 | ivci.subresourceRange.layerCount = 1; |
| 3866 | ivci.subresourceRange.baseMipLevel = 0; |
| 3867 | ivci.subresourceRange.levelCount = 1; |
| 3868 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3869 | ivci.components.r = VK_COMPONENT_SWIZZLE_G; |
| 3870 | ivci.components.g = VK_COMPONENT_SWIZZLE_R; |
| 3871 | ivci.components.b = VK_COMPONENT_SWIZZLE_A; |
| 3872 | ivci.components.a = VK_COMPONENT_SWIZZLE_B; |
| 3873 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); |
| 3874 | ASSERT_VK_SUCCESS(err); |
| 3875 | |
| 3876 | fb_info.pAttachments = &view; |
| 3877 | fb_info.height = 100; |
| 3878 | fb_info.width = 100; |
| 3879 | fb_info.layers = 1; |
| 3880 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3881 | " has non-identy swizzle. All " |
| 3882 | "framebuffer attachments must have " |
| 3883 | "been created with the identity " |
| 3884 | "swizzle. "); |
| 3885 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3886 | |
| 3887 | m_errorMonitor->VerifyFound(); |
| 3888 | if (err == VK_SUCCESS) { |
| 3889 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3890 | } |
| 3891 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 3892 | // Request fb that exceeds max dimensions |
| 3893 | // reset attachment to color attachment |
| 3894 | fb_info.pAttachments = ivs; |
| 3895 | fb_info.width = m_device->props.limits.maxFramebufferWidth + 1; |
| 3896 | fb_info.height = m_device->props.limits.maxFramebufferHeight + 1; |
| 3897 | fb_info.layers = m_device->props.limits.maxFramebufferLayers + 1; |
| 3898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3899 | " Requested VkFramebufferCreateInfo " |
| 3900 | "dimensions exceed physical device " |
| 3901 | "limits. "); |
| 3902 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3903 | |
| 3904 | m_errorMonitor->VerifyFound(); |
| 3905 | if (err == VK_SUCCESS) { |
| 3906 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3907 | } |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 3908 | |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3909 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3910 | } |
| 3911 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3912 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3913 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 3914 | TEST_DESCRIPTION( |
| 3915 | "Wait on a event then set it after the wait has been submitted."); |
| 3916 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3917 | m_errorMonitor->ExpectSuccess(); |
| 3918 | |
| 3919 | VkEvent event; |
| 3920 | VkEventCreateInfo event_create_info{}; |
| 3921 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3922 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3923 | |
| 3924 | VkCommandPool command_pool; |
| 3925 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3926 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3927 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3928 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3929 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3930 | &command_pool); |
| 3931 | |
| 3932 | VkCommandBuffer command_buffer; |
| 3933 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3934 | command_buffer_allocate_info.sType = |
| 3935 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3936 | command_buffer_allocate_info.commandPool = command_pool; |
| 3937 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3938 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3939 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3940 | &command_buffer); |
| 3941 | |
| 3942 | VkQueue queue = VK_NULL_HANDLE; |
| 3943 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3944 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3945 | |
| 3946 | { |
| 3947 | VkCommandBufferBeginInfo begin_info{}; |
| 3948 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3949 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3950 | |
| 3951 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 3952 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3953 | nullptr, 0, nullptr); |
| 3954 | vkCmdResetEvent(command_buffer, event, |
| 3955 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3956 | vkEndCommandBuffer(command_buffer); |
| 3957 | } |
| 3958 | { |
| 3959 | VkSubmitInfo submit_info{}; |
| 3960 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3961 | submit_info.commandBufferCount = 1; |
| 3962 | submit_info.pCommandBuffers = &command_buffer; |
| 3963 | submit_info.signalSemaphoreCount = 0; |
| 3964 | submit_info.pSignalSemaphores = nullptr; |
| 3965 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3966 | } |
| 3967 | { vkSetEvent(m_device->device(), event); } |
| 3968 | |
| 3969 | vkQueueWaitIdle(queue); |
| 3970 | |
| 3971 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3972 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3973 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3974 | |
| 3975 | m_errorMonitor->VerifyNotFound(); |
| 3976 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3977 | // This is a positive test. No errors should be generated. |
| 3978 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 3979 | TEST_DESCRIPTION( |
| 3980 | "Issue a query and copy from it on a second command buffer."); |
| 3981 | |
| 3982 | if ((m_device->queue_props.empty()) || |
| 3983 | (m_device->queue_props[0].queueCount < 2)) |
| 3984 | return; |
| 3985 | |
| 3986 | m_errorMonitor->ExpectSuccess(); |
| 3987 | |
| 3988 | VkQueryPool query_pool; |
| 3989 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 3990 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 3991 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 3992 | query_pool_create_info.queryCount = 1; |
| 3993 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 3994 | &query_pool); |
| 3995 | |
| 3996 | VkCommandPool command_pool; |
| 3997 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3998 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3999 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4000 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4001 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4002 | &command_pool); |
| 4003 | |
| 4004 | VkCommandBuffer command_buffer[2]; |
| 4005 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4006 | command_buffer_allocate_info.sType = |
| 4007 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4008 | command_buffer_allocate_info.commandPool = command_pool; |
| 4009 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4010 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4011 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4012 | command_buffer); |
| 4013 | |
| 4014 | VkQueue queue = VK_NULL_HANDLE; |
| 4015 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4016 | 1, &queue); |
| 4017 | |
| 4018 | uint32_t qfi = 0; |
| 4019 | VkBufferCreateInfo buff_create_info = {}; |
| 4020 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4021 | buff_create_info.size = 1024; |
| 4022 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 4023 | buff_create_info.queueFamilyIndexCount = 1; |
| 4024 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 4025 | |
| 4026 | VkResult err; |
| 4027 | VkBuffer buffer; |
| 4028 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 4029 | ASSERT_VK_SUCCESS(err); |
| 4030 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4031 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4032 | mem_alloc.pNext = NULL; |
| 4033 | mem_alloc.allocationSize = 1024; |
| 4034 | mem_alloc.memoryTypeIndex = 0; |
| 4035 | |
| 4036 | VkMemoryRequirements memReqs; |
| 4037 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 4038 | bool pass = |
| 4039 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 4040 | if (!pass) { |
| 4041 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 4042 | return; |
| 4043 | } |
| 4044 | |
| 4045 | VkDeviceMemory mem; |
| 4046 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4047 | ASSERT_VK_SUCCESS(err); |
| 4048 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 4049 | ASSERT_VK_SUCCESS(err); |
| 4050 | |
| 4051 | { |
| 4052 | VkCommandBufferBeginInfo begin_info{}; |
| 4053 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4054 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4055 | |
| 4056 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 4057 | vkCmdWriteTimestamp(command_buffer[0], |
| 4058 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 4059 | |
| 4060 | vkEndCommandBuffer(command_buffer[0]); |
| 4061 | |
| 4062 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4063 | |
| 4064 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 4065 | 0, 0, 0); |
| 4066 | |
| 4067 | vkEndCommandBuffer(command_buffer[1]); |
| 4068 | } |
| 4069 | { |
| 4070 | VkSubmitInfo submit_info{}; |
| 4071 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4072 | submit_info.commandBufferCount = 2; |
| 4073 | submit_info.pCommandBuffers = command_buffer; |
| 4074 | submit_info.signalSemaphoreCount = 0; |
| 4075 | submit_info.pSignalSemaphores = nullptr; |
| 4076 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4077 | } |
| 4078 | |
| 4079 | vkQueueWaitIdle(queue); |
| 4080 | |
| 4081 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 4082 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 4083 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4084 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 4085 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 4086 | |
| 4087 | m_errorMonitor->VerifyNotFound(); |
| 4088 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4089 | |
| 4090 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 4091 | TEST_DESCRIPTION( |
| 4092 | "Reset an event then set it after the reset has been submitted."); |
| 4093 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4094 | m_errorMonitor->ExpectSuccess(); |
| 4095 | |
| 4096 | VkEvent event; |
| 4097 | VkEventCreateInfo event_create_info{}; |
| 4098 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4099 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 4100 | |
| 4101 | VkCommandPool command_pool; |
| 4102 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4103 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4104 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4105 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4106 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4107 | &command_pool); |
| 4108 | |
| 4109 | VkCommandBuffer command_buffer; |
| 4110 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4111 | command_buffer_allocate_info.sType = |
| 4112 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4113 | command_buffer_allocate_info.commandPool = command_pool; |
| 4114 | command_buffer_allocate_info.commandBufferCount = 1; |
| 4115 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4116 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4117 | &command_buffer); |
| 4118 | |
| 4119 | VkQueue queue = VK_NULL_HANDLE; |
| 4120 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 4121 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4122 | |
| 4123 | { |
| 4124 | VkCommandBufferBeginInfo begin_info{}; |
| 4125 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4126 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 4127 | |
| 4128 | vkCmdResetEvent(command_buffer, event, |
| 4129 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 4130 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 4131 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4132 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 4133 | nullptr, 0, nullptr); |
| 4134 | vkEndCommandBuffer(command_buffer); |
| 4135 | } |
| 4136 | { |
| 4137 | VkSubmitInfo submit_info{}; |
| 4138 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4139 | submit_info.commandBufferCount = 1; |
| 4140 | submit_info.pCommandBuffers = &command_buffer; |
| 4141 | submit_info.signalSemaphoreCount = 0; |
| 4142 | submit_info.pSignalSemaphores = nullptr; |
| 4143 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4144 | } |
| 4145 | { |
| 4146 | m_errorMonitor->SetDesiredFailureMsg( |
| 4147 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 4148 | "0x1 that is already in use by a " |
| 4149 | "command buffer."); |
| 4150 | vkSetEvent(m_device->device(), event); |
| 4151 | m_errorMonitor->VerifyFound(); |
| 4152 | } |
| 4153 | |
| 4154 | vkQueueWaitIdle(queue); |
| 4155 | |
| 4156 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 4157 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 4158 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4159 | } |
| 4160 | |
| 4161 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4162 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 4163 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 4164 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 4165 | "previously revealed a bug so running this positive test " |
| 4166 | "to prevent a regression."); |
| 4167 | m_errorMonitor->ExpectSuccess(); |
| 4168 | |
| 4169 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4170 | VkQueue queue = VK_NULL_HANDLE; |
| 4171 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4172 | 0, &queue); |
| 4173 | |
| 4174 | static const uint32_t NUM_OBJECTS = 2; |
| 4175 | static const uint32_t NUM_FRAMES = 3; |
| 4176 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 4177 | VkFence fences[NUM_OBJECTS] = {}; |
| 4178 | |
| 4179 | VkCommandPool cmd_pool; |
| 4180 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 4181 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4182 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4183 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4184 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 4185 | nullptr, &cmd_pool); |
| 4186 | ASSERT_VK_SUCCESS(err); |
| 4187 | |
| 4188 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 4189 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4190 | cmd_buf_info.commandPool = cmd_pool; |
| 4191 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4192 | cmd_buf_info.commandBufferCount = 1; |
| 4193 | |
| 4194 | VkFenceCreateInfo fence_ci = {}; |
| 4195 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4196 | fence_ci.pNext = nullptr; |
| 4197 | fence_ci.flags = 0; |
| 4198 | |
| 4199 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 4200 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 4201 | &cmd_buffers[i]); |
| 4202 | ASSERT_VK_SUCCESS(err); |
| 4203 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 4204 | ASSERT_VK_SUCCESS(err); |
| 4205 | } |
| 4206 | |
| 4207 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4208 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 4209 | // Create empty cmd buffer |
| 4210 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 4211 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4212 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4213 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 4214 | ASSERT_VK_SUCCESS(err); |
| 4215 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 4216 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4217 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4218 | VkSubmitInfo submit_info = {}; |
| 4219 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4220 | submit_info.commandBufferCount = 1; |
| 4221 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 4222 | // Submit cmd buffer and wait for fence |
| 4223 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 4224 | ASSERT_VK_SUCCESS(err); |
| 4225 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 4226 | UINT64_MAX); |
| 4227 | ASSERT_VK_SUCCESS(err); |
| 4228 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 4229 | ASSERT_VK_SUCCESS(err); |
| 4230 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4231 | } |
| 4232 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4233 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 4234 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 4235 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 4236 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4237 | } |
| 4238 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4239 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 4240 | |
| 4241 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4242 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 4243 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4244 | if ((m_device->queue_props.empty()) || |
| 4245 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4246 | return; |
| 4247 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4248 | m_errorMonitor->ExpectSuccess(); |
| 4249 | |
| 4250 | VkSemaphore semaphore; |
| 4251 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4252 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4253 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4254 | &semaphore); |
| 4255 | |
| 4256 | VkCommandPool command_pool; |
| 4257 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4258 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4259 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4260 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4261 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4262 | &command_pool); |
| 4263 | |
| 4264 | VkCommandBuffer command_buffer[2]; |
| 4265 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4266 | command_buffer_allocate_info.sType = |
| 4267 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4268 | command_buffer_allocate_info.commandPool = command_pool; |
| 4269 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4270 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4271 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4272 | command_buffer); |
| 4273 | |
| 4274 | VkQueue queue = VK_NULL_HANDLE; |
| 4275 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4276 | 1, &queue); |
| 4277 | |
| 4278 | { |
| 4279 | VkCommandBufferBeginInfo begin_info{}; |
| 4280 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4281 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4282 | |
| 4283 | vkCmdPipelineBarrier(command_buffer[0], |
| 4284 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4285 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4286 | 0, nullptr, 0, nullptr); |
| 4287 | |
| 4288 | VkViewport viewport{}; |
| 4289 | viewport.maxDepth = 1.0f; |
| 4290 | viewport.minDepth = 0.0f; |
| 4291 | viewport.width = 512; |
| 4292 | viewport.height = 512; |
| 4293 | viewport.x = 0; |
| 4294 | viewport.y = 0; |
| 4295 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4296 | vkEndCommandBuffer(command_buffer[0]); |
| 4297 | } |
| 4298 | { |
| 4299 | VkCommandBufferBeginInfo begin_info{}; |
| 4300 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4301 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4302 | |
| 4303 | VkViewport viewport{}; |
| 4304 | viewport.maxDepth = 1.0f; |
| 4305 | viewport.minDepth = 0.0f; |
| 4306 | viewport.width = 512; |
| 4307 | viewport.height = 512; |
| 4308 | viewport.x = 0; |
| 4309 | viewport.y = 0; |
| 4310 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4311 | vkEndCommandBuffer(command_buffer[1]); |
| 4312 | } |
| 4313 | { |
| 4314 | VkSubmitInfo submit_info{}; |
| 4315 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4316 | submit_info.commandBufferCount = 1; |
| 4317 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4318 | submit_info.signalSemaphoreCount = 1; |
| 4319 | submit_info.pSignalSemaphores = &semaphore; |
| 4320 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4321 | } |
| 4322 | { |
| 4323 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4324 | VkSubmitInfo submit_info{}; |
| 4325 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4326 | submit_info.commandBufferCount = 1; |
| 4327 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4328 | submit_info.waitSemaphoreCount = 1; |
| 4329 | submit_info.pWaitSemaphores = &semaphore; |
| 4330 | submit_info.pWaitDstStageMask = flags; |
| 4331 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4332 | } |
| 4333 | |
| 4334 | vkQueueWaitIdle(m_device->m_queue); |
| 4335 | |
| 4336 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4337 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4338 | &command_buffer[0]); |
| 4339 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4340 | |
| 4341 | m_errorMonitor->VerifyNotFound(); |
| 4342 | } |
| 4343 | |
| 4344 | // This is a positive test. No errors should be generated. |
| 4345 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 4346 | |
| 4347 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4348 | "submitted on separate queues, the second having a fence" |
| 4349 | "followed by a QueueWaitIdle."); |
| 4350 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4351 | if ((m_device->queue_props.empty()) || |
| 4352 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4353 | return; |
| 4354 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4355 | m_errorMonitor->ExpectSuccess(); |
| 4356 | |
| 4357 | VkFence fence; |
| 4358 | VkFenceCreateInfo fence_create_info{}; |
| 4359 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4360 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4361 | |
| 4362 | VkSemaphore semaphore; |
| 4363 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4364 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4365 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4366 | &semaphore); |
| 4367 | |
| 4368 | VkCommandPool command_pool; |
| 4369 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4370 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4371 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4372 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4373 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4374 | &command_pool); |
| 4375 | |
| 4376 | VkCommandBuffer command_buffer[2]; |
| 4377 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4378 | command_buffer_allocate_info.sType = |
| 4379 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4380 | command_buffer_allocate_info.commandPool = command_pool; |
| 4381 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4382 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4383 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4384 | command_buffer); |
| 4385 | |
| 4386 | VkQueue queue = VK_NULL_HANDLE; |
| 4387 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4388 | 1, &queue); |
| 4389 | |
| 4390 | { |
| 4391 | VkCommandBufferBeginInfo begin_info{}; |
| 4392 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4393 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4394 | |
| 4395 | vkCmdPipelineBarrier(command_buffer[0], |
| 4396 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4397 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4398 | 0, nullptr, 0, nullptr); |
| 4399 | |
| 4400 | VkViewport viewport{}; |
| 4401 | viewport.maxDepth = 1.0f; |
| 4402 | viewport.minDepth = 0.0f; |
| 4403 | viewport.width = 512; |
| 4404 | viewport.height = 512; |
| 4405 | viewport.x = 0; |
| 4406 | viewport.y = 0; |
| 4407 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4408 | vkEndCommandBuffer(command_buffer[0]); |
| 4409 | } |
| 4410 | { |
| 4411 | VkCommandBufferBeginInfo begin_info{}; |
| 4412 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4413 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4414 | |
| 4415 | VkViewport viewport{}; |
| 4416 | viewport.maxDepth = 1.0f; |
| 4417 | viewport.minDepth = 0.0f; |
| 4418 | viewport.width = 512; |
| 4419 | viewport.height = 512; |
| 4420 | viewport.x = 0; |
| 4421 | viewport.y = 0; |
| 4422 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4423 | vkEndCommandBuffer(command_buffer[1]); |
| 4424 | } |
| 4425 | { |
| 4426 | VkSubmitInfo submit_info{}; |
| 4427 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4428 | submit_info.commandBufferCount = 1; |
| 4429 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4430 | submit_info.signalSemaphoreCount = 1; |
| 4431 | submit_info.pSignalSemaphores = &semaphore; |
| 4432 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4433 | } |
| 4434 | { |
| 4435 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4436 | VkSubmitInfo submit_info{}; |
| 4437 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4438 | submit_info.commandBufferCount = 1; |
| 4439 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4440 | submit_info.waitSemaphoreCount = 1; |
| 4441 | submit_info.pWaitSemaphores = &semaphore; |
| 4442 | submit_info.pWaitDstStageMask = flags; |
| 4443 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4444 | } |
| 4445 | |
| 4446 | vkQueueWaitIdle(m_device->m_queue); |
| 4447 | |
| 4448 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4449 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4450 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4451 | &command_buffer[0]); |
| 4452 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4453 | |
| 4454 | m_errorMonitor->VerifyNotFound(); |
| 4455 | } |
| 4456 | |
| 4457 | // This is a positive test. No errors should be generated. |
| 4458 | TEST_F(VkLayerTest, |
| 4459 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 4460 | |
| 4461 | TEST_DESCRIPTION( |
| 4462 | "Two command buffers, each in a separate QueueSubmit call " |
| 4463 | "submitted on separate queues, the second having a fence" |
| 4464 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 4465 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4466 | if ((m_device->queue_props.empty()) || |
| 4467 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4468 | return; |
| 4469 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4470 | m_errorMonitor->ExpectSuccess(); |
| 4471 | |
| 4472 | VkFence fence; |
| 4473 | VkFenceCreateInfo fence_create_info{}; |
| 4474 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4475 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4476 | |
| 4477 | VkSemaphore semaphore; |
| 4478 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4479 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4480 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4481 | &semaphore); |
| 4482 | |
| 4483 | VkCommandPool command_pool; |
| 4484 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4485 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4486 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4487 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4488 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4489 | &command_pool); |
| 4490 | |
| 4491 | VkCommandBuffer command_buffer[2]; |
| 4492 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4493 | command_buffer_allocate_info.sType = |
| 4494 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4495 | command_buffer_allocate_info.commandPool = command_pool; |
| 4496 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4497 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4498 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4499 | command_buffer); |
| 4500 | |
| 4501 | VkQueue queue = VK_NULL_HANDLE; |
| 4502 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4503 | 1, &queue); |
| 4504 | |
| 4505 | { |
| 4506 | VkCommandBufferBeginInfo begin_info{}; |
| 4507 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4508 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4509 | |
| 4510 | vkCmdPipelineBarrier(command_buffer[0], |
| 4511 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4512 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4513 | 0, nullptr, 0, nullptr); |
| 4514 | |
| 4515 | VkViewport viewport{}; |
| 4516 | viewport.maxDepth = 1.0f; |
| 4517 | viewport.minDepth = 0.0f; |
| 4518 | viewport.width = 512; |
| 4519 | viewport.height = 512; |
| 4520 | viewport.x = 0; |
| 4521 | viewport.y = 0; |
| 4522 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4523 | vkEndCommandBuffer(command_buffer[0]); |
| 4524 | } |
| 4525 | { |
| 4526 | VkCommandBufferBeginInfo begin_info{}; |
| 4527 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4528 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4529 | |
| 4530 | VkViewport viewport{}; |
| 4531 | viewport.maxDepth = 1.0f; |
| 4532 | viewport.minDepth = 0.0f; |
| 4533 | viewport.width = 512; |
| 4534 | viewport.height = 512; |
| 4535 | viewport.x = 0; |
| 4536 | viewport.y = 0; |
| 4537 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4538 | vkEndCommandBuffer(command_buffer[1]); |
| 4539 | } |
| 4540 | { |
| 4541 | VkSubmitInfo submit_info{}; |
| 4542 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4543 | submit_info.commandBufferCount = 1; |
| 4544 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4545 | submit_info.signalSemaphoreCount = 1; |
| 4546 | submit_info.pSignalSemaphores = &semaphore; |
| 4547 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4548 | } |
| 4549 | { |
| 4550 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4551 | VkSubmitInfo submit_info{}; |
| 4552 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4553 | submit_info.commandBufferCount = 1; |
| 4554 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4555 | submit_info.waitSemaphoreCount = 1; |
| 4556 | submit_info.pWaitSemaphores = &semaphore; |
| 4557 | submit_info.pWaitDstStageMask = flags; |
| 4558 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4559 | } |
| 4560 | |
| 4561 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4562 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4563 | |
| 4564 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4565 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4566 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4567 | &command_buffer[0]); |
| 4568 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4569 | |
| 4570 | m_errorMonitor->VerifyNotFound(); |
| 4571 | } |
| 4572 | |
Chris Forbes | 0f8126b | 2016-06-20 17:48:22 +1200 | [diff] [blame] | 4573 | #if 0 |
| 4574 | TEST_F(VkLayerTest, TwoQueuesEnsureCorrectRetirementWithWorkStolen) { |
| 4575 | if ((m_device->queue_props.empty()) || |
| 4576 | (m_device->queue_props[0].queueCount < 2)) { |
| 4577 | printf("Test requires two queues, skipping\n"); |
| 4578 | return; |
| 4579 | } |
| 4580 | |
| 4581 | VkResult err; |
| 4582 | |
| 4583 | m_errorMonitor->ExpectSuccess(); |
| 4584 | |
| 4585 | VkQueue q0 = m_device->m_queue; |
| 4586 | VkQueue q1 = nullptr; |
| 4587 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, 1, &q1); |
| 4588 | ASSERT_NE(q1, nullptr); |
| 4589 | |
| 4590 | // An (empty) command buffer. We must have work in the first submission -- |
| 4591 | // the layer treats unfenced work differently from fenced work. |
| 4592 | VkCommandPoolCreateInfo cpci = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, nullptr, 0, 0 }; |
| 4593 | VkCommandPool pool; |
| 4594 | err = vkCreateCommandPool(m_device->device(), &cpci, nullptr, &pool); |
| 4595 | ASSERT_VK_SUCCESS(err); |
| 4596 | VkCommandBufferAllocateInfo cbai = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr, |
| 4597 | pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1 |
| 4598 | }; |
| 4599 | VkCommandBuffer cb; |
| 4600 | err = vkAllocateCommandBuffers(m_device->device(), &cbai, &cb); |
| 4601 | ASSERT_VK_SUCCESS(err); |
| 4602 | VkCommandBufferBeginInfo cbbi = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 4603 | 0, nullptr |
| 4604 | }; |
| 4605 | err = vkBeginCommandBuffer(cb, &cbbi); |
| 4606 | ASSERT_VK_SUCCESS(err); |
| 4607 | err = vkEndCommandBuffer(cb); |
| 4608 | ASSERT_VK_SUCCESS(err); |
| 4609 | |
| 4610 | // A semaphore |
| 4611 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; |
| 4612 | VkSemaphore s; |
| 4613 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s); |
| 4614 | ASSERT_VK_SUCCESS(err); |
| 4615 | |
| 4616 | // First submission, to q0 |
| 4617 | VkSubmitInfo s0 = { |
| 4618 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, |
| 4619 | 0, nullptr, nullptr, |
| 4620 | 1, &cb, |
| 4621 | 1, &s |
| 4622 | }; |
| 4623 | |
| 4624 | err = vkQueueSubmit(q0, 1, &s0, VK_NULL_HANDLE); |
| 4625 | ASSERT_VK_SUCCESS(err); |
| 4626 | |
| 4627 | // Second submission, to q1, waiting on s |
| 4628 | VkFlags waitmask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; // doesn't really matter what this value is. |
| 4629 | VkSubmitInfo s1 = { |
| 4630 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, |
| 4631 | 1, &s, &waitmask, |
| 4632 | 0, nullptr, |
| 4633 | 0, nullptr |
| 4634 | }; |
| 4635 | |
| 4636 | err = vkQueueSubmit(q1, 1, &s1, VK_NULL_HANDLE); |
| 4637 | ASSERT_VK_SUCCESS(err); |
| 4638 | |
| 4639 | // Wait for q0 idle |
| 4640 | err = vkQueueWaitIdle(q0); |
| 4641 | ASSERT_VK_SUCCESS(err); |
| 4642 | |
| 4643 | // Command buffer should have been completed (it was on q0); reset the pool. |
| 4644 | vkFreeCommandBuffers(m_device->device(), pool, 1, &cb); |
| 4645 | |
| 4646 | m_errorMonitor->VerifyNotFound(); |
| 4647 | |
| 4648 | // Force device completely idle and clean up resources |
| 4649 | vkDeviceWaitIdle(m_device->device()); |
| 4650 | vkDestroyCommandPool(m_device->device(), pool, nullptr); |
| 4651 | vkDestroySemaphore(m_device->device(), s, nullptr); |
| 4652 | } |
| 4653 | #endif |
| 4654 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4655 | // This is a positive test. No errors should be generated. |
| 4656 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 4657 | |
| 4658 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4659 | "submitted on separate queues, the second having a fence, " |
| 4660 | "followed by a WaitForFences call."); |
| 4661 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4662 | if ((m_device->queue_props.empty()) || |
| 4663 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4664 | return; |
| 4665 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4666 | m_errorMonitor->ExpectSuccess(); |
| 4667 | |
| 4668 | VkFence fence; |
| 4669 | VkFenceCreateInfo fence_create_info{}; |
| 4670 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4671 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4672 | |
| 4673 | VkSemaphore semaphore; |
| 4674 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4675 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4676 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4677 | &semaphore); |
| 4678 | |
| 4679 | VkCommandPool command_pool; |
| 4680 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4681 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4682 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4683 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4684 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4685 | &command_pool); |
| 4686 | |
| 4687 | VkCommandBuffer command_buffer[2]; |
| 4688 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4689 | command_buffer_allocate_info.sType = |
| 4690 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4691 | command_buffer_allocate_info.commandPool = command_pool; |
| 4692 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4693 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4694 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4695 | command_buffer); |
| 4696 | |
| 4697 | VkQueue queue = VK_NULL_HANDLE; |
| 4698 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4699 | 1, &queue); |
| 4700 | |
| 4701 | |
| 4702 | { |
| 4703 | VkCommandBufferBeginInfo begin_info{}; |
| 4704 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4705 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4706 | |
| 4707 | vkCmdPipelineBarrier(command_buffer[0], |
| 4708 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4709 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4710 | 0, nullptr, 0, nullptr); |
| 4711 | |
| 4712 | VkViewport viewport{}; |
| 4713 | viewport.maxDepth = 1.0f; |
| 4714 | viewport.minDepth = 0.0f; |
| 4715 | viewport.width = 512; |
| 4716 | viewport.height = 512; |
| 4717 | viewport.x = 0; |
| 4718 | viewport.y = 0; |
| 4719 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4720 | vkEndCommandBuffer(command_buffer[0]); |
| 4721 | } |
| 4722 | { |
| 4723 | VkCommandBufferBeginInfo begin_info{}; |
| 4724 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4725 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4726 | |
| 4727 | VkViewport viewport{}; |
| 4728 | viewport.maxDepth = 1.0f; |
| 4729 | viewport.minDepth = 0.0f; |
| 4730 | viewport.width = 512; |
| 4731 | viewport.height = 512; |
| 4732 | viewport.x = 0; |
| 4733 | viewport.y = 0; |
| 4734 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4735 | vkEndCommandBuffer(command_buffer[1]); |
| 4736 | } |
| 4737 | { |
| 4738 | VkSubmitInfo submit_info{}; |
| 4739 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4740 | submit_info.commandBufferCount = 1; |
| 4741 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4742 | submit_info.signalSemaphoreCount = 1; |
| 4743 | submit_info.pSignalSemaphores = &semaphore; |
| 4744 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4745 | } |
| 4746 | { |
| 4747 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4748 | VkSubmitInfo submit_info{}; |
| 4749 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4750 | submit_info.commandBufferCount = 1; |
| 4751 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4752 | submit_info.waitSemaphoreCount = 1; |
| 4753 | submit_info.pWaitSemaphores = &semaphore; |
| 4754 | submit_info.pWaitDstStageMask = flags; |
| 4755 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4756 | } |
| 4757 | |
| 4758 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4759 | |
| 4760 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4761 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4762 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4763 | &command_buffer[0]); |
| 4764 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4765 | |
| 4766 | m_errorMonitor->VerifyNotFound(); |
| 4767 | } |
| 4768 | |
| 4769 | // This is a positive test. No errors should be generated. |
| 4770 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 4771 | |
| 4772 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4773 | "on the same queue, sharing a signal/wait semaphore, the " |
| 4774 | "second having a fence, " |
| 4775 | "followed by a WaitForFences call."); |
| 4776 | |
| 4777 | m_errorMonitor->ExpectSuccess(); |
| 4778 | |
| 4779 | VkFence fence; |
| 4780 | VkFenceCreateInfo fence_create_info{}; |
| 4781 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4782 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4783 | |
| 4784 | VkSemaphore semaphore; |
| 4785 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4786 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4787 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4788 | &semaphore); |
| 4789 | |
| 4790 | VkCommandPool command_pool; |
| 4791 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4792 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4793 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4794 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4795 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4796 | &command_pool); |
| 4797 | |
| 4798 | VkCommandBuffer command_buffer[2]; |
| 4799 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4800 | command_buffer_allocate_info.sType = |
| 4801 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4802 | command_buffer_allocate_info.commandPool = command_pool; |
| 4803 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4804 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4805 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4806 | command_buffer); |
| 4807 | |
| 4808 | { |
| 4809 | VkCommandBufferBeginInfo begin_info{}; |
| 4810 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4811 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4812 | |
| 4813 | vkCmdPipelineBarrier(command_buffer[0], |
| 4814 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4815 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4816 | 0, nullptr, 0, nullptr); |
| 4817 | |
| 4818 | VkViewport viewport{}; |
| 4819 | viewport.maxDepth = 1.0f; |
| 4820 | viewport.minDepth = 0.0f; |
| 4821 | viewport.width = 512; |
| 4822 | viewport.height = 512; |
| 4823 | viewport.x = 0; |
| 4824 | viewport.y = 0; |
| 4825 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4826 | vkEndCommandBuffer(command_buffer[0]); |
| 4827 | } |
| 4828 | { |
| 4829 | VkCommandBufferBeginInfo begin_info{}; |
| 4830 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4831 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4832 | |
| 4833 | VkViewport viewport{}; |
| 4834 | viewport.maxDepth = 1.0f; |
| 4835 | viewport.minDepth = 0.0f; |
| 4836 | viewport.width = 512; |
| 4837 | viewport.height = 512; |
| 4838 | viewport.x = 0; |
| 4839 | viewport.y = 0; |
| 4840 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4841 | vkEndCommandBuffer(command_buffer[1]); |
| 4842 | } |
| 4843 | { |
| 4844 | VkSubmitInfo submit_info{}; |
| 4845 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4846 | submit_info.commandBufferCount = 1; |
| 4847 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4848 | submit_info.signalSemaphoreCount = 1; |
| 4849 | submit_info.pSignalSemaphores = &semaphore; |
| 4850 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4851 | } |
| 4852 | { |
| 4853 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4854 | VkSubmitInfo submit_info{}; |
| 4855 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4856 | submit_info.commandBufferCount = 1; |
| 4857 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4858 | submit_info.waitSemaphoreCount = 1; |
| 4859 | submit_info.pWaitSemaphores = &semaphore; |
| 4860 | submit_info.pWaitDstStageMask = flags; |
| 4861 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4862 | } |
| 4863 | |
| 4864 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4865 | |
| 4866 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4867 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4868 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4869 | &command_buffer[0]); |
| 4870 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4871 | |
| 4872 | m_errorMonitor->VerifyNotFound(); |
| 4873 | } |
| 4874 | |
| 4875 | // This is a positive test. No errors should be generated. |
| 4876 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 4877 | |
| 4878 | TEST_DESCRIPTION( |
| 4879 | "Two command buffers, each in a separate QueueSubmit call " |
| 4880 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 4881 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 4882 | |
| 4883 | m_errorMonitor->ExpectSuccess(); |
| 4884 | |
| 4885 | VkFence fence; |
| 4886 | VkFenceCreateInfo fence_create_info{}; |
| 4887 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4888 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4889 | |
| 4890 | VkCommandPool command_pool; |
| 4891 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4892 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4893 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4894 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4895 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4896 | &command_pool); |
| 4897 | |
| 4898 | VkCommandBuffer command_buffer[2]; |
| 4899 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4900 | command_buffer_allocate_info.sType = |
| 4901 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4902 | command_buffer_allocate_info.commandPool = command_pool; |
| 4903 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4904 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4905 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4906 | command_buffer); |
| 4907 | |
| 4908 | { |
| 4909 | VkCommandBufferBeginInfo begin_info{}; |
| 4910 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4911 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4912 | |
| 4913 | vkCmdPipelineBarrier(command_buffer[0], |
| 4914 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4915 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4916 | 0, nullptr, 0, nullptr); |
| 4917 | |
| 4918 | VkViewport viewport{}; |
| 4919 | viewport.maxDepth = 1.0f; |
| 4920 | viewport.minDepth = 0.0f; |
| 4921 | viewport.width = 512; |
| 4922 | viewport.height = 512; |
| 4923 | viewport.x = 0; |
| 4924 | viewport.y = 0; |
| 4925 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4926 | vkEndCommandBuffer(command_buffer[0]); |
| 4927 | } |
| 4928 | { |
| 4929 | VkCommandBufferBeginInfo begin_info{}; |
| 4930 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4931 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4932 | |
| 4933 | VkViewport viewport{}; |
| 4934 | viewport.maxDepth = 1.0f; |
| 4935 | viewport.minDepth = 0.0f; |
| 4936 | viewport.width = 512; |
| 4937 | viewport.height = 512; |
| 4938 | viewport.x = 0; |
| 4939 | viewport.y = 0; |
| 4940 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4941 | vkEndCommandBuffer(command_buffer[1]); |
| 4942 | } |
| 4943 | { |
| 4944 | VkSubmitInfo submit_info{}; |
| 4945 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4946 | submit_info.commandBufferCount = 1; |
| 4947 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4948 | submit_info.signalSemaphoreCount = 0; |
| 4949 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4950 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4951 | } |
| 4952 | { |
| 4953 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4954 | VkSubmitInfo submit_info{}; |
| 4955 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4956 | submit_info.commandBufferCount = 1; |
| 4957 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4958 | submit_info.waitSemaphoreCount = 0; |
| 4959 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4960 | submit_info.pWaitDstStageMask = flags; |
| 4961 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4962 | } |
| 4963 | |
| 4964 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 4965 | |
Mike Stroyan | cd1c3e5 | 2016-06-21 09:20:01 -0600 | [diff] [blame] | 4966 | VkResult err = |
| 4967 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4968 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4969 | |
| 4970 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4971 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4972 | &command_buffer[0]); |
| 4973 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4974 | |
| 4975 | m_errorMonitor->VerifyNotFound(); |
| 4976 | } |
| 4977 | |
| 4978 | // This is a positive test. No errors should be generated. |
| 4979 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 4980 | |
| 4981 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4982 | "on the same queue, the second having a fence, followed " |
| 4983 | "by a WaitForFences call."); |
| 4984 | |
| 4985 | m_errorMonitor->ExpectSuccess(); |
| 4986 | |
| 4987 | VkFence fence; |
| 4988 | VkFenceCreateInfo fence_create_info{}; |
| 4989 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4990 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4991 | |
| 4992 | VkCommandPool command_pool; |
| 4993 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4994 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4995 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4996 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4997 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4998 | &command_pool); |
| 4999 | |
| 5000 | VkCommandBuffer command_buffer[2]; |
| 5001 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 5002 | command_buffer_allocate_info.sType = |
| 5003 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 5004 | command_buffer_allocate_info.commandPool = command_pool; |
| 5005 | command_buffer_allocate_info.commandBufferCount = 2; |
| 5006 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 5007 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 5008 | command_buffer); |
| 5009 | |
| 5010 | { |
| 5011 | VkCommandBufferBeginInfo begin_info{}; |
| 5012 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5013 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 5014 | |
| 5015 | vkCmdPipelineBarrier(command_buffer[0], |
| 5016 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 5017 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 5018 | 0, nullptr, 0, nullptr); |
| 5019 | |
| 5020 | VkViewport viewport{}; |
| 5021 | viewport.maxDepth = 1.0f; |
| 5022 | viewport.minDepth = 0.0f; |
| 5023 | viewport.width = 512; |
| 5024 | viewport.height = 512; |
| 5025 | viewport.x = 0; |
| 5026 | viewport.y = 0; |
| 5027 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 5028 | vkEndCommandBuffer(command_buffer[0]); |
| 5029 | } |
| 5030 | { |
| 5031 | VkCommandBufferBeginInfo begin_info{}; |
| 5032 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5033 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 5034 | |
| 5035 | VkViewport viewport{}; |
| 5036 | viewport.maxDepth = 1.0f; |
| 5037 | viewport.minDepth = 0.0f; |
| 5038 | viewport.width = 512; |
| 5039 | viewport.height = 512; |
| 5040 | viewport.x = 0; |
| 5041 | viewport.y = 0; |
| 5042 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 5043 | vkEndCommandBuffer(command_buffer[1]); |
| 5044 | } |
| 5045 | { |
| 5046 | VkSubmitInfo submit_info{}; |
| 5047 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5048 | submit_info.commandBufferCount = 1; |
| 5049 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 5050 | submit_info.signalSemaphoreCount = 0; |
| 5051 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 5052 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 5053 | } |
| 5054 | { |
| 5055 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 5056 | VkSubmitInfo submit_info{}; |
| 5057 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5058 | submit_info.commandBufferCount = 1; |
| 5059 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 5060 | submit_info.waitSemaphoreCount = 0; |
| 5061 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 5062 | submit_info.pWaitDstStageMask = flags; |
| 5063 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 5064 | } |
| 5065 | |
| 5066 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 5067 | |
| 5068 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 5069 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 5070 | &command_buffer[0]); |
| 5071 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 5072 | |
| 5073 | m_errorMonitor->VerifyNotFound(); |
| 5074 | } |
| 5075 | |
| 5076 | // This is a positive test. No errors should be generated. |
| 5077 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 5078 | |
| 5079 | TEST_DESCRIPTION( |
| 5080 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 5081 | "QueueSubmit call followed by a WaitForFences call."); |
| 5082 | |
| 5083 | m_errorMonitor->ExpectSuccess(); |
| 5084 | |
| 5085 | VkFence fence; |
| 5086 | VkFenceCreateInfo fence_create_info{}; |
| 5087 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 5088 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 5089 | |
| 5090 | VkSemaphore semaphore; |
| 5091 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 5092 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 5093 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 5094 | &semaphore); |
| 5095 | |
| 5096 | VkCommandPool command_pool; |
| 5097 | VkCommandPoolCreateInfo pool_create_info{}; |
| 5098 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 5099 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 5100 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 5101 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 5102 | &command_pool); |
| 5103 | |
| 5104 | VkCommandBuffer command_buffer[2]; |
| 5105 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 5106 | command_buffer_allocate_info.sType = |
| 5107 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 5108 | command_buffer_allocate_info.commandPool = command_pool; |
| 5109 | command_buffer_allocate_info.commandBufferCount = 2; |
| 5110 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 5111 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 5112 | command_buffer); |
| 5113 | |
| 5114 | { |
| 5115 | VkCommandBufferBeginInfo begin_info{}; |
| 5116 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5117 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 5118 | |
| 5119 | vkCmdPipelineBarrier(command_buffer[0], |
| 5120 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 5121 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 5122 | 0, nullptr, 0, nullptr); |
| 5123 | |
| 5124 | VkViewport viewport{}; |
| 5125 | viewport.maxDepth = 1.0f; |
| 5126 | viewport.minDepth = 0.0f; |
| 5127 | viewport.width = 512; |
| 5128 | viewport.height = 512; |
| 5129 | viewport.x = 0; |
| 5130 | viewport.y = 0; |
| 5131 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 5132 | vkEndCommandBuffer(command_buffer[0]); |
| 5133 | } |
| 5134 | { |
| 5135 | VkCommandBufferBeginInfo begin_info{}; |
| 5136 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5137 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 5138 | |
| 5139 | VkViewport viewport{}; |
| 5140 | viewport.maxDepth = 1.0f; |
| 5141 | viewport.minDepth = 0.0f; |
| 5142 | viewport.width = 512; |
| 5143 | viewport.height = 512; |
| 5144 | viewport.x = 0; |
| 5145 | viewport.y = 0; |
| 5146 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 5147 | vkEndCommandBuffer(command_buffer[1]); |
| 5148 | } |
| 5149 | { |
| 5150 | VkSubmitInfo submit_info[2]; |
| 5151 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 5152 | |
| 5153 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5154 | submit_info[0].pNext = NULL; |
| 5155 | submit_info[0].commandBufferCount = 1; |
| 5156 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 5157 | submit_info[0].signalSemaphoreCount = 1; |
| 5158 | submit_info[0].pSignalSemaphores = &semaphore; |
| 5159 | submit_info[0].waitSemaphoreCount = 0; |
| 5160 | submit_info[0].pWaitSemaphores = NULL; |
| 5161 | submit_info[0].pWaitDstStageMask = 0; |
| 5162 | |
| 5163 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5164 | submit_info[1].pNext = NULL; |
| 5165 | submit_info[1].commandBufferCount = 1; |
| 5166 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 5167 | submit_info[1].waitSemaphoreCount = 1; |
| 5168 | submit_info[1].pWaitSemaphores = &semaphore; |
| 5169 | submit_info[1].pWaitDstStageMask = flags; |
| 5170 | submit_info[1].signalSemaphoreCount = 0; |
| 5171 | submit_info[1].pSignalSemaphores = NULL; |
| 5172 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 5173 | } |
| 5174 | |
| 5175 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 5176 | |
| 5177 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 5178 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 5179 | &command_buffer[0]); |
| 5180 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5181 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5182 | |
| 5183 | m_errorMonitor->VerifyNotFound(); |
| 5184 | } |
| 5185 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5186 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5187 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5188 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 5189 | "state is required but not correctly bound."); |
| 5190 | |
| 5191 | // Dynamic depth bias |
| 5192 | m_errorMonitor->SetDesiredFailureMsg( |
| 5193 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5194 | "Dynamic depth bias state not set for this command buffer"); |
| 5195 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5196 | BsoFailDepthBias); |
| 5197 | m_errorMonitor->VerifyFound(); |
| 5198 | } |
| 5199 | |
| 5200 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 5201 | TEST_DESCRIPTION( |
| 5202 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 5203 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5204 | |
| 5205 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5206 | m_errorMonitor->SetDesiredFailureMsg( |
| 5207 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5208 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5209 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5210 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5211 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5212 | } |
| 5213 | |
| 5214 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 5215 | TEST_DESCRIPTION( |
| 5216 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 5217 | "state is required but not correctly bound."); |
| 5218 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5219 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5220 | m_errorMonitor->SetDesiredFailureMsg( |
| 5221 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5222 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5223 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5224 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5225 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5226 | } |
| 5227 | |
| 5228 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 5229 | TEST_DESCRIPTION( |
| 5230 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 5231 | "state is required but not correctly bound."); |
| 5232 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5233 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5234 | m_errorMonitor->SetDesiredFailureMsg( |
| 5235 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5236 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5238 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5239 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5240 | } |
| 5241 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5242 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5243 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5244 | "Run a simple draw calls to validate failure when Blend Constants " |
| 5245 | "dynamic state is required but not correctly bound."); |
| 5246 | // Dynamic blend constant state |
| 5247 | m_errorMonitor->SetDesiredFailureMsg( |
| 5248 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5249 | "Dynamic blend constants state not set for this command buffer"); |
| 5250 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5251 | BsoFailBlend); |
| 5252 | m_errorMonitor->VerifyFound(); |
| 5253 | } |
| 5254 | |
| 5255 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 5256 | TEST_DESCRIPTION( |
| 5257 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5258 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5259 | if (!m_device->phy().features().depthBounds) { |
| 5260 | printf("Device does not support depthBounds test; skipped.\n"); |
| 5261 | return; |
| 5262 | } |
| 5263 | // Dynamic depth bounds |
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 depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5267 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5268 | BsoFailDepthBounds); |
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, DynamicStencilReadNotBound) { |
| 5273 | TEST_DESCRIPTION( |
| 5274 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 5275 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5276 | // Dynamic stencil read 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 read 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 | BsoFailStencilReadMask); |
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, DynamicStencilWriteNotBound) { |
| 5286 | TEST_DESCRIPTION( |
| 5287 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 5288 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5289 | // Dynamic stencil write mask |
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 write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5294 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5295 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5296 | } |
| 5297 | |
| 5298 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 5299 | TEST_DESCRIPTION( |
| 5300 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 5301 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5302 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5303 | m_errorMonitor->SetDesiredFailureMsg( |
| 5304 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5305 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5306 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 5307 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5308 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 5309 | } |
| 5310 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5311 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5312 | m_errorMonitor->SetDesiredFailureMsg( |
| 5313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5314 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 5315 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5316 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5317 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5318 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5319 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5321 | // We luck out b/c by default the framework creates CB w/ the |
| 5322 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5323 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5324 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 5325 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5326 | EndCommandBuffer(); |
| 5327 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5328 | // Bypass framework since it does the waits automatically |
| 5329 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5330 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 5331 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 5332 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5333 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5334 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 5335 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5336 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5337 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5338 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 5339 | submit_info.pSignalSemaphores = NULL; |
| 5340 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 5341 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5342 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5344 | // Cause validation error by re-submitting cmd buffer that should only be |
| 5345 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 5346 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5347 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5348 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5349 | } |
| 5350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5351 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5352 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5353 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5354 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5355 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5356 | "Unable to allocate 1 descriptors of " |
| 5357 | "type " |
| 5358 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5359 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5360 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5361 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5362 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5363 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 5364 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5365 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5366 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5367 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5368 | |
| 5369 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5371 | ds_pool_ci.pNext = NULL; |
| 5372 | ds_pool_ci.flags = 0; |
| 5373 | ds_pool_ci.maxSets = 1; |
| 5374 | ds_pool_ci.poolSizeCount = 1; |
| 5375 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5376 | |
| 5377 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5378 | err = |
| 5379 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5380 | ASSERT_VK_SUCCESS(err); |
| 5381 | |
| 5382 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5383 | dsl_binding.binding = 0; |
| 5384 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5385 | dsl_binding.descriptorCount = 1; |
| 5386 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5387 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5388 | |
| 5389 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5390 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5391 | ds_layout_ci.pNext = NULL; |
| 5392 | ds_layout_ci.bindingCount = 1; |
| 5393 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5394 | |
| 5395 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5396 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5397 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5398 | ASSERT_VK_SUCCESS(err); |
| 5399 | |
| 5400 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5401 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5402 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5403 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5404 | alloc_info.descriptorPool = ds_pool; |
| 5405 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5406 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5407 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5408 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5409 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5410 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5411 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5412 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 5413 | } |
| 5414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5415 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 5416 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5418 | m_errorMonitor->SetDesiredFailureMsg( |
| 5419 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5420 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 5421 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5422 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5424 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5425 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5426 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5427 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5428 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5429 | |
| 5430 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5431 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5432 | ds_pool_ci.pNext = NULL; |
| 5433 | ds_pool_ci.maxSets = 1; |
| 5434 | ds_pool_ci.poolSizeCount = 1; |
| 5435 | ds_pool_ci.flags = 0; |
| 5436 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 5437 | // app can only call vkResetDescriptorPool on this pool.; |
| 5438 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5439 | |
| 5440 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5441 | err = |
| 5442 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5443 | ASSERT_VK_SUCCESS(err); |
| 5444 | |
| 5445 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | dsl_binding.binding = 0; |
| 5447 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5448 | dsl_binding.descriptorCount = 1; |
| 5449 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5450 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5451 | |
| 5452 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5453 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5454 | ds_layout_ci.pNext = NULL; |
| 5455 | ds_layout_ci.bindingCount = 1; |
| 5456 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5457 | |
| 5458 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5460 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5461 | ASSERT_VK_SUCCESS(err); |
| 5462 | |
| 5463 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5464 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5465 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5466 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5467 | alloc_info.descriptorPool = ds_pool; |
| 5468 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5469 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5470 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5471 | ASSERT_VK_SUCCESS(err); |
| 5472 | |
| 5473 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5474 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5475 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5476 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5477 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 5478 | } |
| 5479 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5480 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5481 | // Attempt to clear Descriptor Pool with bad object. |
| 5482 | // ObjectTracker should catch this. |
| 5483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5484 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5485 | uint64_t fake_pool_handle = 0xbaad6001; |
| 5486 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 5487 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5488 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5489 | } |
| 5490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5492 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 5493 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5494 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5495 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5496 | |
| 5497 | uint64_t fake_set_handle = 0xbaad6001; |
| 5498 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5499 | VkResult err; |
| 5500 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5501 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 5502 | |
| 5503 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5504 | |
| 5505 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 5506 | layout_bindings[0].binding = 0; |
| 5507 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5508 | layout_bindings[0].descriptorCount = 1; |
| 5509 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 5510 | layout_bindings[0].pImmutableSamplers = NULL; |
| 5511 | |
| 5512 | VkDescriptorSetLayout descriptor_set_layout; |
| 5513 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 5514 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5515 | dslci.pNext = NULL; |
| 5516 | dslci.bindingCount = 1; |
| 5517 | dslci.pBindings = layout_bindings; |
| 5518 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 5519 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5520 | |
| 5521 | VkPipelineLayout pipeline_layout; |
| 5522 | VkPipelineLayoutCreateInfo plci = {}; |
| 5523 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5524 | plci.pNext = NULL; |
| 5525 | plci.setLayoutCount = 1; |
| 5526 | plci.pSetLayouts = &descriptor_set_layout; |
| 5527 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 5528 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5529 | |
| 5530 | BeginCommandBuffer(); |
| 5531 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5532 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5533 | m_errorMonitor->VerifyFound(); |
| 5534 | EndCommandBuffer(); |
| 5535 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 5536 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5537 | } |
| 5538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5540 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 5541 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5542 | uint64_t fake_layout_handle = 0xbaad6001; |
| 5543 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5544 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5545 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 5546 | |
| 5547 | VkPipelineLayout pipeline_layout; |
| 5548 | VkPipelineLayoutCreateInfo plci = {}; |
| 5549 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5550 | plci.pNext = NULL; |
| 5551 | plci.setLayoutCount = 1; |
| 5552 | plci.pSetLayouts = &bad_layout; |
| 5553 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 5554 | |
| 5555 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5556 | } |
| 5557 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5558 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
| 5559 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " |
| 5560 | "1) A uniform buffer update must have a valid buffer index." |
| 5561 | "2) When using an array of descriptors in a single WriteDescriptor," |
| 5562 | " the descriptor types and stageflags must all be the same." |
| 5563 | "3) Immutable Sampler state must match across descriptors"); |
| 5564 | |
| 5565 | const char *invalid_BufferInfo_ErrorMessage = |
| 5566 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " |
| 5567 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " |
| 5568 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; |
| 5569 | const char *stateFlag_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5570 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5571 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5572 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5573 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5574 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
| 5575 | |
| 5576 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5577 | VkDescriptorPoolSize ds_type_count[4] = {}; |
| 5578 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5579 | ds_type_count[0].descriptorCount = 1; |
| 5580 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5581 | ds_type_count[1].descriptorCount = 1; |
| 5582 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5583 | ds_type_count[2].descriptorCount = 1; |
| 5584 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5585 | ds_type_count[3].descriptorCount = 1; |
| 5586 | |
| 5587 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5588 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5589 | ds_pool_ci.maxSets = 1; |
| 5590 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); |
| 5591 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 5592 | |
| 5593 | VkDescriptorPool ds_pool; |
| 5594 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5595 | ASSERT_VK_SUCCESS(err); |
| 5596 | |
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5597 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5598 | layout_binding[0].binding = 0; |
| 5599 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5600 | layout_binding[0].descriptorCount = 1; |
| 5601 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5602 | layout_binding[0].pImmutableSamplers = NULL; |
| 5603 | |
| 5604 | layout_binding[1].binding = 1; |
| 5605 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5606 | layout_binding[1].descriptorCount = 1; |
| 5607 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 5608 | layout_binding[1].pImmutableSamplers = NULL; |
| 5609 | |
| 5610 | VkSamplerCreateInfo sampler_ci = {}; |
| 5611 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5612 | sampler_ci.pNext = NULL; |
| 5613 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5614 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5615 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5616 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5617 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5618 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5619 | sampler_ci.mipLodBias = 1.0; |
| 5620 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5621 | sampler_ci.maxAnisotropy = 1; |
| 5622 | sampler_ci.compareEnable = VK_FALSE; |
| 5623 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5624 | sampler_ci.minLod = 1.0; |
| 5625 | sampler_ci.maxLod = 1.0; |
| 5626 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5627 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5628 | VkSampler sampler; |
| 5629 | |
| 5630 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5631 | ASSERT_VK_SUCCESS(err); |
| 5632 | |
| 5633 | layout_binding[2].binding = 2; |
| 5634 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5635 | layout_binding[2].descriptorCount = 1; |
| 5636 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 5637 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); |
| 5638 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5639 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5640 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5641 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); |
| 5642 | ds_layout_ci.pBindings = layout_binding; |
| 5643 | VkDescriptorSetLayout ds_layout; |
| 5644 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 5645 | ASSERT_VK_SUCCESS(err); |
| 5646 | |
| 5647 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5648 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5649 | alloc_info.descriptorSetCount = 1; |
| 5650 | alloc_info.descriptorPool = ds_pool; |
| 5651 | alloc_info.pSetLayouts = &ds_layout; |
| 5652 | VkDescriptorSet descriptorSet; |
| 5653 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 5654 | ASSERT_VK_SUCCESS(err); |
| 5655 | |
| 5656 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5657 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5658 | pipeline_layout_ci.pNext = NULL; |
| 5659 | pipeline_layout_ci.setLayoutCount = 1; |
| 5660 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5661 | |
| 5662 | VkPipelineLayout pipeline_layout; |
| 5663 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 5664 | ASSERT_VK_SUCCESS(err); |
| 5665 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5666 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5667 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5668 | descriptor_write.dstSet = descriptorSet; |
| 5669 | descriptor_write.dstBinding = 0; |
| 5670 | descriptor_write.descriptorCount = 1; |
| 5671 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5672 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5673 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5674 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5675 | m_errorMonitor->VerifyFound(); |
| 5676 | |
| 5677 | // Create a buffer to update the descriptor with |
| 5678 | uint32_t qfi = 0; |
| 5679 | VkBufferCreateInfo buffCI = {}; |
| 5680 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5681 | buffCI.size = 1024; |
| 5682 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5683 | buffCI.queueFamilyIndexCount = 1; |
| 5684 | buffCI.pQueueFamilyIndices = &qfi; |
| 5685 | |
| 5686 | VkBuffer dyub; |
| 5687 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5688 | ASSERT_VK_SUCCESS(err); |
| 5689 | VkDescriptorBufferInfo buffInfo = {}; |
| 5690 | buffInfo.buffer = dyub; |
| 5691 | buffInfo.offset = 0; |
| 5692 | buffInfo.range = 1024; |
| 5693 | |
| 5694 | descriptor_write.pBufferInfo = &buffInfo; |
| 5695 | descriptor_write.descriptorCount = 2; |
| 5696 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5697 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5698 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
| 5699 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5700 | m_errorMonitor->VerifyFound(); |
| 5701 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5702 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
| 5703 | // the third descriptor contains an immutable sampler |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5704 | descriptor_write.dstBinding = 1; |
| 5705 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5706 | |
| 5707 | |
| 5708 | // Make pImageInfo index non-null to avoid complaints of it missing |
| 5709 | VkDescriptorImageInfo imageInfo = {}; |
| 5710 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5711 | descriptor_write.pImageInfo = &imageInfo; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5712 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
| 5713 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5714 | m_errorMonitor->VerifyFound(); |
| 5715 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5716 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5717 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5718 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5719 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5720 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5721 | } |
| 5722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5723 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5724 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 5725 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5726 | // Create a valid cmd buffer |
| 5727 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5728 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 5729 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5730 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5731 | "Invalid VkPipeline Object 0xbaad6001"); |
| 5732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5733 | BeginCommandBuffer(); |
| 5734 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5735 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 5736 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5737 | // Now issue a draw call with no pipeline bound |
| 5738 | m_errorMonitor->SetDesiredFailureMsg( |
| 5739 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5740 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5741 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5742 | BeginCommandBuffer(); |
| 5743 | Draw(1, 0, 0, 0); |
| 5744 | m_errorMonitor->VerifyFound(); |
| 5745 | // Finally same check once more but with Dispatch/Compute |
| 5746 | m_errorMonitor->SetDesiredFailureMsg( |
| 5747 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5748 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5749 | BeginCommandBuffer(); |
| 5750 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 5751 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5752 | } |
| 5753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5754 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 5755 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 5756 | // CommandBuffer |
| 5757 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5758 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5760 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5761 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5763 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5764 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5765 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5766 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5767 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5768 | |
| 5769 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5770 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5771 | ds_pool_ci.pNext = NULL; |
| 5772 | ds_pool_ci.maxSets = 1; |
| 5773 | ds_pool_ci.poolSizeCount = 1; |
| 5774 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5775 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5776 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5777 | err = |
| 5778 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5779 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5780 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5781 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5782 | dsl_binding.binding = 0; |
| 5783 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5784 | dsl_binding.descriptorCount = 1; |
| 5785 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5786 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5787 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5788 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5789 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5790 | ds_layout_ci.pNext = NULL; |
| 5791 | ds_layout_ci.bindingCount = 1; |
| 5792 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5793 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5794 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5795 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5796 | ASSERT_VK_SUCCESS(err); |
| 5797 | |
| 5798 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5799 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5800 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5801 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5802 | alloc_info.descriptorPool = ds_pool; |
| 5803 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5804 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5805 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5806 | ASSERT_VK_SUCCESS(err); |
| 5807 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5808 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5809 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5810 | pipeline_layout_ci.pNext = NULL; |
| 5811 | pipeline_layout_ci.setLayoutCount = 1; |
| 5812 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5813 | |
| 5814 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5815 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5816 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5817 | ASSERT_VK_SUCCESS(err); |
| 5818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5819 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5820 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5821 | // 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] | 5822 | // on more devices |
| 5823 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5824 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5825 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5826 | VkPipelineObj pipe(m_device); |
| 5827 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5828 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5829 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5830 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5831 | |
| 5832 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5833 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5834 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5835 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5836 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5837 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5838 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5839 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5840 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5841 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5842 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5843 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5844 | } |
| 5845 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5846 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5847 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5848 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5849 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5850 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5851 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 5852 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5853 | |
| 5854 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5855 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5856 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5857 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5858 | |
| 5859 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5860 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5861 | ds_pool_ci.pNext = NULL; |
| 5862 | ds_pool_ci.maxSets = 1; |
| 5863 | ds_pool_ci.poolSizeCount = 1; |
| 5864 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5865 | |
| 5866 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5867 | err = |
| 5868 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5869 | ASSERT_VK_SUCCESS(err); |
| 5870 | |
| 5871 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5872 | dsl_binding.binding = 0; |
| 5873 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5874 | dsl_binding.descriptorCount = 1; |
| 5875 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5876 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5877 | |
| 5878 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5879 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5880 | ds_layout_ci.pNext = NULL; |
| 5881 | ds_layout_ci.bindingCount = 1; |
| 5882 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5883 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5884 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5885 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5886 | ASSERT_VK_SUCCESS(err); |
| 5887 | |
| 5888 | VkDescriptorSet descriptorSet; |
| 5889 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5890 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5891 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5892 | alloc_info.descriptorPool = ds_pool; |
| 5893 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5894 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5895 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5896 | ASSERT_VK_SUCCESS(err); |
| 5897 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5898 | VkBufferView view = |
| 5899 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5900 | VkWriteDescriptorSet descriptor_write; |
| 5901 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5902 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5903 | descriptor_write.dstSet = descriptorSet; |
| 5904 | descriptor_write.dstBinding = 0; |
| 5905 | descriptor_write.descriptorCount = 1; |
| 5906 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5907 | descriptor_write.pTexelBufferView = &view; |
| 5908 | |
| 5909 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5910 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5911 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5912 | |
| 5913 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5914 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5915 | } |
| 5916 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5917 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 5918 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 5919 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5920 | // 1. No dynamicOffset supplied |
| 5921 | // 2. Too many dynamicOffsets supplied |
| 5922 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5923 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5924 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5925 | " requires 1 dynamicOffsets, but only " |
| 5926 | "0 dynamicOffsets are left in " |
| 5927 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5928 | |
| 5929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5930 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5931 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5932 | |
| 5933 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5934 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5935 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5936 | |
| 5937 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5939 | ds_pool_ci.pNext = NULL; |
| 5940 | ds_pool_ci.maxSets = 1; |
| 5941 | ds_pool_ci.poolSizeCount = 1; |
| 5942 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5943 | |
| 5944 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5945 | err = |
| 5946 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5947 | ASSERT_VK_SUCCESS(err); |
| 5948 | |
| 5949 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5950 | dsl_binding.binding = 0; |
| 5951 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5952 | dsl_binding.descriptorCount = 1; |
| 5953 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5954 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5955 | |
| 5956 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5958 | ds_layout_ci.pNext = NULL; |
| 5959 | ds_layout_ci.bindingCount = 1; |
| 5960 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5961 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5962 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5963 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5964 | ASSERT_VK_SUCCESS(err); |
| 5965 | |
| 5966 | VkDescriptorSet descriptorSet; |
| 5967 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5968 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5969 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5970 | alloc_info.descriptorPool = ds_pool; |
| 5971 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5972 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5973 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5974 | ASSERT_VK_SUCCESS(err); |
| 5975 | |
| 5976 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5978 | pipeline_layout_ci.pNext = NULL; |
| 5979 | pipeline_layout_ci.setLayoutCount = 1; |
| 5980 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5981 | |
| 5982 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5983 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5984 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5985 | ASSERT_VK_SUCCESS(err); |
| 5986 | |
| 5987 | // Create a buffer to update the descriptor with |
| 5988 | uint32_t qfi = 0; |
| 5989 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5990 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5991 | buffCI.size = 1024; |
| 5992 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5993 | buffCI.queueFamilyIndexCount = 1; |
| 5994 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5995 | |
| 5996 | VkBuffer dyub; |
| 5997 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5998 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5999 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 6000 | // error |
| 6001 | VkMemoryAllocateInfo mem_alloc = {}; |
| 6002 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6003 | mem_alloc.pNext = NULL; |
| 6004 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 6005 | mem_alloc.memoryTypeIndex = 0; |
| 6006 | |
| 6007 | VkMemoryRequirements memReqs; |
| 6008 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 6009 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 6010 | 0); |
| 6011 | if (!pass) { |
| 6012 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 6013 | return; |
| 6014 | } |
| 6015 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6016 | VkDeviceMemory mem; |
| 6017 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 6018 | ASSERT_VK_SUCCESS(err); |
| 6019 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 6020 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6021 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6022 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6023 | buffInfo.buffer = dyub; |
| 6024 | buffInfo.offset = 0; |
| 6025 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6026 | |
| 6027 | VkWriteDescriptorSet descriptor_write; |
| 6028 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6029 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6030 | descriptor_write.dstSet = descriptorSet; |
| 6031 | descriptor_write.dstBinding = 0; |
| 6032 | descriptor_write.descriptorCount = 1; |
| 6033 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 6034 | descriptor_write.pBufferInfo = &buffInfo; |
| 6035 | |
| 6036 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6037 | |
| 6038 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6040 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6041 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6042 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6043 | uint32_t pDynOff[2] = {512, 756}; |
| 6044 | // 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] | 6045 | m_errorMonitor->SetDesiredFailureMsg( |
| 6046 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6047 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6048 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6049 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6050 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6051 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6052 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6053 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6054 | " dynamic offset 512 combined with " |
| 6055 | "offset 0 and range 1024 that " |
| 6056 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6057 | // Create PSO to be used for draw-time errors below |
| 6058 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6059 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6060 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6061 | "out gl_PerVertex { \n" |
| 6062 | " vec4 gl_Position;\n" |
| 6063 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6064 | "void main(){\n" |
| 6065 | " gl_Position = vec4(1);\n" |
| 6066 | "}\n"; |
| 6067 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6068 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6069 | "\n" |
| 6070 | "layout(location=0) out vec4 x;\n" |
| 6071 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6072 | "void main(){\n" |
| 6073 | " x = vec4(bar.y);\n" |
| 6074 | "}\n"; |
| 6075 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6076 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6077 | VkPipelineObj pipe(m_device); |
| 6078 | pipe.AddShader(&vs); |
| 6079 | pipe.AddShader(&fs); |
| 6080 | pipe.AddColorAttachment(); |
| 6081 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6082 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6083 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6084 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6085 | // This update should succeed, but offset size of 512 will overstep buffer |
| 6086 | // /w range 1024 & size 1024 |
| 6087 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6088 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6089 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6090 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6091 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6092 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6093 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 6094 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6095 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6096 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6097 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6098 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6099 | } |
| 6100 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6101 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6102 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6103 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6104 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6106 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6107 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6108 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6109 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6110 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6111 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 6112 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 6113 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6114 | // |
| 6115 | // Check for invalid push constant ranges in pipeline layouts. |
| 6116 | // |
| 6117 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6118 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6119 | char const *msg; |
| 6120 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6121 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6122 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 6123 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 6124 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 6125 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6126 | "size 0."}, |
| 6127 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 6128 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6129 | "size 1."}, |
| 6130 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 6131 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6132 | "size 1."}, |
| 6133 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 6134 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6135 | "size 0."}, |
| 6136 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 6137 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 6138 | "offset 1. Offset must"}, |
| 6139 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 6140 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 6141 | "with offset "}, |
| 6142 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 6143 | "vkCreatePipelineLayout() call has push constants " |
| 6144 | "index 0 with offset "}, |
| 6145 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 6146 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 6147 | "with offset "}, |
| 6148 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 6149 | "vkCreatePipelineLayout() call has push " |
| 6150 | "constants index 0 with offset "}, |
| 6151 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 6152 | "vkCreatePipelineLayout() call has push " |
| 6153 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6154 | }}; |
| 6155 | |
| 6156 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6157 | for (const auto &iter : range_tests) { |
| 6158 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6159 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6160 | iter.msg); |
| 6161 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6162 | NULL, &pipeline_layout); |
| 6163 | m_errorMonitor->VerifyFound(); |
| 6164 | if (VK_SUCCESS == err) { |
| 6165 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6166 | } |
| 6167 | } |
| 6168 | |
| 6169 | // Check for invalid stage flag |
| 6170 | pc_range.offset = 0; |
| 6171 | pc_range.size = 16; |
| 6172 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6173 | m_errorMonitor->SetDesiredFailureMsg( |
| 6174 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6175 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6176 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6177 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6178 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6179 | if (VK_SUCCESS == err) { |
| 6180 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6181 | } |
| 6182 | |
| 6183 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6184 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6185 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6186 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6187 | char const *msg; |
| 6188 | }; |
| 6189 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6190 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6191 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6192 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6193 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6194 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6195 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6196 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 6197 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 6198 | { |
| 6199 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6200 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6201 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6202 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6203 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 6204 | "vkCreatePipelineLayout() call has push constants with " |
| 6205 | "overlapping " |
| 6206 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 6207 | }, |
| 6208 | { |
| 6209 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6210 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6211 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6212 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6213 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6214 | "vkCreatePipelineLayout() call has push constants with " |
| 6215 | "overlapping " |
| 6216 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 6217 | }, |
| 6218 | { |
| 6219 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6220 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6221 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6222 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 6223 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6224 | "vkCreatePipelineLayout() call has push constants with " |
| 6225 | "overlapping " |
| 6226 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 6227 | }, |
| 6228 | { |
| 6229 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6230 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 6231 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 6232 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 6233 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 6234 | "vkCreatePipelineLayout() call has push constants with " |
| 6235 | "overlapping " |
| 6236 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 6237 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6238 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6239 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6240 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6241 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 6242 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6243 | iter.msg); |
| 6244 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6245 | NULL, &pipeline_layout); |
| 6246 | m_errorMonitor->VerifyFound(); |
| 6247 | if (VK_SUCCESS == err) { |
| 6248 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6249 | } |
| 6250 | } |
| 6251 | |
| 6252 | // 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] | 6253 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 6254 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6255 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 6256 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 6257 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 6258 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 6259 | ""}, |
| 6260 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 6261 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 6262 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 6263 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 6264 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 6265 | ""}}}; |
| 6266 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6267 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 6268 | m_errorMonitor->ExpectSuccess(); |
| 6269 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 6270 | NULL, &pipeline_layout); |
| 6271 | m_errorMonitor->VerifyNotFound(); |
| 6272 | if (VK_SUCCESS == err) { |
| 6273 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6274 | } |
| 6275 | } |
| 6276 | |
| 6277 | // |
| 6278 | // CmdPushConstants tests |
| 6279 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6280 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6281 | |
| 6282 | // 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] | 6283 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 6284 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 6285 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 6286 | "must be greater than zero and a multiple of 4."}, |
| 6287 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 6288 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 6289 | "must be greater than zero and a multiple of 4."}, |
| 6290 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 6291 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 6292 | "must be greater than zero and a multiple of 4."}, |
| 6293 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 6294 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 6295 | "Offset must be a multiple of 4."}, |
| 6296 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 6297 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 6298 | "Offset must be a multiple of 4."}, |
| 6299 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 6300 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 6301 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6302 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 6303 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 6304 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6305 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 6306 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 6307 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6308 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 6309 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 6310 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6311 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 6312 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 6313 | "any of the ranges in pipeline layout"}, |
| 6314 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 6315 | 0, 16}, |
| 6316 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 6317 | "any of the ranges in pipeline layout"}, |
| 6318 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6319 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6320 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6321 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6322 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6323 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6324 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6325 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6326 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6327 | "vkCmdPushConstants() call has push constants with offset "}, |
| 6328 | }}; |
| 6329 | |
| 6330 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6331 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6332 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6333 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6334 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6335 | pipeline_layout_ci.pushConstantRangeCount = |
| 6336 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6337 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6338 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6339 | &pipeline_layout); |
| 6340 | ASSERT_VK_SUCCESS(err); |
| 6341 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6342 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6343 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6344 | iter.msg); |
| 6345 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6346 | iter.range.stageFlags, iter.range.offset, |
| 6347 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6348 | m_errorMonitor->VerifyFound(); |
| 6349 | } |
| 6350 | |
| 6351 | // Check for invalid stage flag |
| 6352 | m_errorMonitor->SetDesiredFailureMsg( |
| 6353 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6354 | "vkCmdPushConstants() call has no stageFlags set."); |
| 6355 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6356 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6357 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6358 | EndCommandBuffer(); |
| 6359 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 6360 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6361 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 6362 | // overlapping range tests with cmd |
| 6363 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 6364 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 6365 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 6366 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6367 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 6368 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 6369 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6370 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 6371 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 6372 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 6373 | }}; |
| 6374 | const VkPushConstantRange pc_range3[] = { |
| 6375 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 6376 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 6377 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6378 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 6379 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 6380 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 6381 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 6382 | }; |
| 6383 | pipeline_layout_ci.pushConstantRangeCount = |
| 6384 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 6385 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 6386 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6387 | &pipeline_layout); |
| 6388 | ASSERT_VK_SUCCESS(err); |
| 6389 | BeginCommandBuffer(); |
| 6390 | for (const auto &iter : cmd_overlap_tests) { |
| 6391 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6392 | iter.msg); |
| 6393 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 6394 | iter.range.stageFlags, iter.range.offset, |
| 6395 | iter.range.size, dummy_values); |
| 6396 | m_errorMonitor->VerifyFound(); |
| 6397 | } |
| 6398 | EndCommandBuffer(); |
| 6399 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 6400 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6401 | |
| 6402 | // positive overlapping range tests with cmd |
| 6403 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 6404 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 6405 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 6406 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 6407 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 6408 | }}; |
| 6409 | const VkPushConstantRange pc_range4[] = { |
| 6410 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 6411 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 6412 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 6413 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 6414 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 6415 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 6416 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 6417 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 6418 | }; |
| 6419 | pipeline_layout_ci.pushConstantRangeCount = |
| 6420 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 6421 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 6422 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6423 | &pipeline_layout); |
| 6424 | ASSERT_VK_SUCCESS(err); |
| 6425 | BeginCommandBuffer(); |
| 6426 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 6427 | m_errorMonitor->ExpectSuccess(); |
| 6428 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 6429 | iter.range.stageFlags, iter.range.offset, |
| 6430 | iter.range.size, dummy_values); |
| 6431 | m_errorMonitor->VerifyNotFound(); |
| 6432 | } |
| 6433 | EndCommandBuffer(); |
| 6434 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6435 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6436 | } |
| 6437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6438 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6439 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6440 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6441 | |
| 6442 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6443 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6444 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6445 | |
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 6446 | const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 6447 | VkImageTiling tiling; |
| 6448 | VkFormatProperties format_properties; |
| 6449 | vkGetPhysicalDeviceFormatProperties(gpu(), tex_format, &format_properties); |
| 6450 | if (format_properties.linearTilingFeatures & |
| 6451 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { |
| 6452 | tiling = VK_IMAGE_TILING_LINEAR; |
| 6453 | } else if (format_properties.optimalTilingFeatures & |
| 6454 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { |
| 6455 | tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6456 | } else { |
| 6457 | printf("Device does not support VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; " |
| 6458 | "skipped.\n"); |
| 6459 | return; |
| 6460 | } |
| 6461 | |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6462 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 6463 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6464 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6465 | ds_type_count[0].descriptorCount = 10; |
| 6466 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6467 | ds_type_count[1].descriptorCount = 2; |
| 6468 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 6469 | ds_type_count[2].descriptorCount = 2; |
| 6470 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6471 | ds_type_count[3].descriptorCount = 5; |
| 6472 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 6473 | // type |
| 6474 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 6475 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 6476 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6477 | |
| 6478 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6479 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6480 | ds_pool_ci.pNext = NULL; |
| 6481 | ds_pool_ci.maxSets = 5; |
| 6482 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 6483 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6484 | |
| 6485 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6486 | err = |
| 6487 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6488 | ASSERT_VK_SUCCESS(err); |
| 6489 | |
| 6490 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 6491 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6492 | dsl_binding[0].binding = 0; |
| 6493 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6494 | dsl_binding[0].descriptorCount = 5; |
| 6495 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6496 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6497 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6498 | // Create layout identical to set0 layout but w/ different stageFlags |
| 6499 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6500 | dsl_fs_stage_only.binding = 0; |
| 6501 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6502 | dsl_fs_stage_only.descriptorCount = 5; |
| 6503 | dsl_fs_stage_only.stageFlags = |
| 6504 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 6505 | // bind time |
| 6506 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6507 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6509 | ds_layout_ci.pNext = NULL; |
| 6510 | ds_layout_ci.bindingCount = 1; |
| 6511 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6512 | static const uint32_t NUM_LAYOUTS = 4; |
| 6513 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6514 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6515 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 6516 | // layout for error case |
| 6517 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6518 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6519 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6520 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
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_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6523 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6524 | dsl_binding[0].binding = 0; |
| 6525 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6526 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6527 | dsl_binding[1].binding = 1; |
| 6528 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 6529 | dsl_binding[1].descriptorCount = 2; |
| 6530 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6531 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6532 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6533 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6534 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6535 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6536 | ASSERT_VK_SUCCESS(err); |
| 6537 | dsl_binding[0].binding = 0; |
| 6538 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6539 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6540 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6541 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6542 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6543 | ASSERT_VK_SUCCESS(err); |
| 6544 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6545 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6546 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6547 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6548 | ASSERT_VK_SUCCESS(err); |
| 6549 | |
| 6550 | static const uint32_t NUM_SETS = 4; |
| 6551 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 6552 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6553 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6554 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6555 | alloc_info.descriptorPool = ds_pool; |
| 6556 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6557 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6558 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6559 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6560 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6561 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6562 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6563 | err = |
| 6564 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6565 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6566 | |
| 6567 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6568 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6569 | pipeline_layout_ci.pNext = NULL; |
| 6570 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 6571 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6572 | |
| 6573 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6574 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6575 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6576 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6577 | // Create pipelineLayout with only one setLayout |
| 6578 | pipeline_layout_ci.setLayoutCount = 1; |
| 6579 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6580 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6581 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6582 | ASSERT_VK_SUCCESS(err); |
| 6583 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 6584 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 6585 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6586 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6587 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6588 | ASSERT_VK_SUCCESS(err); |
| 6589 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 6590 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 6591 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6592 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6593 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6594 | ASSERT_VK_SUCCESS(err); |
| 6595 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 6596 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 6597 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6598 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6599 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6600 | ASSERT_VK_SUCCESS(err); |
| 6601 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 6602 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 6603 | pl_bad_s0[0] = ds_layout_fs_only; |
| 6604 | pl_bad_s0[1] = ds_layout[1]; |
| 6605 | pipeline_layout_ci.setLayoutCount = 2; |
| 6606 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 6607 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6608 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6609 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6610 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6611 | |
| 6612 | // Create a buffer to update the descriptor with |
| 6613 | uint32_t qfi = 0; |
| 6614 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6615 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6616 | buffCI.size = 1024; |
| 6617 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 6618 | buffCI.queueFamilyIndexCount = 1; |
| 6619 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6620 | |
| 6621 | VkBuffer dyub; |
| 6622 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 6623 | ASSERT_VK_SUCCESS(err); |
| 6624 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6625 | static const uint32_t NUM_BUFFS = 5; |
| 6626 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6627 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6628 | buffInfo[i].buffer = dyub; |
| 6629 | buffInfo[i].offset = 0; |
| 6630 | buffInfo[i].range = 1024; |
| 6631 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6632 | VkImage image; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6633 | const int32_t tex_width = 32; |
| 6634 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6635 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6636 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6637 | image_create_info.pNext = NULL; |
| 6638 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6639 | image_create_info.format = tex_format; |
| 6640 | image_create_info.extent.width = tex_width; |
| 6641 | image_create_info.extent.height = tex_height; |
| 6642 | image_create_info.extent.depth = 1; |
| 6643 | image_create_info.mipLevels = 1; |
| 6644 | image_create_info.arrayLayers = 1; |
| 6645 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 6646 | image_create_info.tiling = tiling; |
| 6647 | image_create_info.usage = |
| 6648 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6649 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6650 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 6651 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6653 | VkMemoryRequirements memReqs; |
| 6654 | VkDeviceMemory imageMem; |
| 6655 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6656 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6657 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6658 | memAlloc.pNext = NULL; |
| 6659 | memAlloc.allocationSize = 0; |
| 6660 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6661 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 6662 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6663 | pass = |
| 6664 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6665 | ASSERT_TRUE(pass); |
| 6666 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 6667 | ASSERT_VK_SUCCESS(err); |
| 6668 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 6669 | ASSERT_VK_SUCCESS(err); |
| 6670 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6671 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6672 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 6673 | image_view_create_info.image = image; |
| 6674 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6675 | image_view_create_info.format = tex_format; |
| 6676 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6677 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6678 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6679 | image_view_create_info.subresourceRange.aspectMask = |
| 6680 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6681 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6682 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6683 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6684 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6685 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6686 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6687 | imageInfo[0].imageView = view; |
| 6688 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6689 | imageInfo[1].imageView = view; |
| 6690 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6691 | imageInfo[2].imageView = view; |
| 6692 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6693 | imageInfo[3].imageView = view; |
| 6694 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6695 | |
| 6696 | static const uint32_t NUM_SET_UPDATES = 3; |
| 6697 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 6698 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6699 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 6700 | descriptor_write[0].dstBinding = 0; |
| 6701 | descriptor_write[0].descriptorCount = 5; |
| 6702 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6703 | descriptor_write[0].pBufferInfo = buffInfo; |
| 6704 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6705 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 6706 | descriptor_write[1].dstBinding = 0; |
| 6707 | descriptor_write[1].descriptorCount = 2; |
| 6708 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6709 | descriptor_write[1].pImageInfo = imageInfo; |
| 6710 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6711 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 6712 | descriptor_write[2].dstBinding = 1; |
| 6713 | descriptor_write[2].descriptorCount = 2; |
| 6714 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6715 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6716 | |
| 6717 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6718 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6719 | // Create PSO to be used for draw-time errors below |
| 6720 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6721 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6722 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6723 | "out gl_PerVertex {\n" |
| 6724 | " vec4 gl_Position;\n" |
| 6725 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6726 | "void main(){\n" |
| 6727 | " gl_Position = vec4(1);\n" |
| 6728 | "}\n"; |
| 6729 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6730 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6731 | "\n" |
| 6732 | "layout(location=0) out vec4 x;\n" |
| 6733 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6734 | "void main(){\n" |
| 6735 | " x = vec4(bar.y);\n" |
| 6736 | "}\n"; |
| 6737 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6738 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6739 | VkPipelineObj pipe(m_device); |
| 6740 | pipe.AddShader(&vs); |
| 6741 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6742 | pipe.AddColorAttachment(); |
| 6743 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6744 | |
| 6745 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6747 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6748 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6749 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 6750 | // of PSO |
| 6751 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 6752 | // cmd_pipeline.c |
| 6753 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 6754 | // cmd_bind_graphics_pipeline() |
| 6755 | // TODO : Want to cause various binding incompatibility issues here to test |
| 6756 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6757 | // First cause various verify_layout_compatibility() fails |
| 6758 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6759 | // verify_set_layout_compatibility fail cases: |
| 6760 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6761 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6762 | " due to: invalid VkPipelineLayout "); |
| 6763 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6764 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6765 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 6766 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6767 | m_errorMonitor->VerifyFound(); |
| 6768 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6769 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6770 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6771 | " attempting to bind set to index 1"); |
| 6772 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6773 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 6774 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6775 | m_errorMonitor->VerifyFound(); |
| 6776 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6777 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6778 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 6779 | // descriptors |
| 6780 | m_errorMonitor->SetDesiredFailureMsg( |
| 6781 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6782 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6783 | vkCmdBindDescriptorSets( |
| 6784 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6785 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6786 | m_errorMonitor->VerifyFound(); |
| 6787 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6788 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 6789 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6790 | m_errorMonitor->SetDesiredFailureMsg( |
| 6791 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6792 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6793 | vkCmdBindDescriptorSets( |
| 6794 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6795 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6796 | m_errorMonitor->VerifyFound(); |
| 6797 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6798 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 6799 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6800 | m_errorMonitor->SetDesiredFailureMsg( |
| 6801 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6802 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6803 | vkCmdBindDescriptorSets( |
| 6804 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6805 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6806 | m_errorMonitor->VerifyFound(); |
| 6807 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6808 | // Cause INFO messages due to disturbing previously bound Sets |
| 6809 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6810 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6811 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6812 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6813 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6814 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6815 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6816 | " previously bound as set #0 was disturbed "); |
| 6817 | vkCmdBindDescriptorSets( |
| 6818 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6819 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6820 | m_errorMonitor->VerifyFound(); |
| 6821 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6822 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6823 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6824 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6825 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6826 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6827 | " newly bound as set #0 so set #1 and " |
| 6828 | "any subsequent sets were disturbed "); |
| 6829 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6830 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6831 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6832 | m_errorMonitor->VerifyFound(); |
| 6833 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6834 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6835 | // 1. Error due to not binding required set (we actually use same code as |
| 6836 | // above to disturb set0) |
| 6837 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6838 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6839 | 2, &descriptorSet[0], 0, NULL); |
| 6840 | vkCmdBindDescriptorSets( |
| 6841 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6842 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 6843 | m_errorMonitor->SetDesiredFailureMsg( |
| 6844 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6845 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6846 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6847 | m_errorMonitor->VerifyFound(); |
| 6848 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6849 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6850 | // 2. Error due to bound set not being compatible with PSO's |
| 6851 | // VkPipelineLayout (diff stageFlags in this case) |
| 6852 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6853 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6854 | 2, &descriptorSet[0], 0, NULL); |
| 6855 | m_errorMonitor->SetDesiredFailureMsg( |
| 6856 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6857 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6858 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6859 | m_errorMonitor->VerifyFound(); |
| 6860 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6861 | // Remaining clean-up |
| 6862 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6863 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6864 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 6865 | } |
| 6866 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 6867 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 6868 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6869 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6870 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6871 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6872 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 6873 | vkDestroyImage(m_device->device(), image, NULL); |
| 6874 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6875 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6877 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6878 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6879 | m_errorMonitor->SetDesiredFailureMsg( |
| 6880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6881 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6882 | |
| 6883 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6884 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6885 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6886 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6887 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6888 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6889 | } |
| 6890 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6891 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 6892 | VkResult err; |
| 6893 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6895 | m_errorMonitor->SetDesiredFailureMsg( |
| 6896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 6897 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6898 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6900 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6901 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6902 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6903 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6904 | cmd.commandPool = m_commandPool; |
| 6905 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6906 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6907 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6908 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6909 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6910 | |
| 6911 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6912 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6913 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6914 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6915 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6916 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 6917 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6918 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6919 | |
| 6920 | // The error should be caught by validation of the BeginCommandBuffer call |
| 6921 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 6922 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6923 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6924 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6925 | } |
| 6926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6927 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6928 | // Cause error due to Begin while recording CB |
| 6929 | // Then cause 2 errors for attempting to reset CB w/o having |
| 6930 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 6931 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6932 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6933 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6934 | |
| 6935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6936 | |
| 6937 | // Calls AllocateCommandBuffers |
| 6938 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 6939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6940 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 6941 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6942 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6943 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6944 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6945 | cmd_buf_info.pNext = NULL; |
| 6946 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6947 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6948 | |
| 6949 | // Begin CB to transition to recording state |
| 6950 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 6951 | // Can't re-begin. This should trigger error |
| 6952 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6953 | m_errorMonitor->VerifyFound(); |
| 6954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6955 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6956 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6957 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 6958 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 6959 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6960 | m_errorMonitor->VerifyFound(); |
| 6961 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6962 | m_errorMonitor->SetDesiredFailureMsg( |
| 6963 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6964 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6965 | // Transition CB to RECORDED state |
| 6966 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 6967 | // Now attempting to Begin will implicitly reset, which triggers error |
| 6968 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6969 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6970 | } |
| 6971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6972 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6973 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6974 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6976 | m_errorMonitor->SetDesiredFailureMsg( |
| 6977 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6978 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 6979 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6980 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6981 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6982 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6983 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6984 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6985 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6986 | |
| 6987 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6988 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6989 | ds_pool_ci.pNext = NULL; |
| 6990 | ds_pool_ci.maxSets = 1; |
| 6991 | ds_pool_ci.poolSizeCount = 1; |
| 6992 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6993 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6994 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6995 | err = |
| 6996 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6997 | ASSERT_VK_SUCCESS(err); |
| 6998 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6999 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7000 | dsl_binding.binding = 0; |
| 7001 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7002 | dsl_binding.descriptorCount = 1; |
| 7003 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7004 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7005 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7006 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7007 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7008 | ds_layout_ci.pNext = NULL; |
| 7009 | ds_layout_ci.bindingCount = 1; |
| 7010 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7011 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7012 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7013 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7014 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7015 | ASSERT_VK_SUCCESS(err); |
| 7016 | |
| 7017 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7018 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7019 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7020 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7021 | alloc_info.descriptorPool = ds_pool; |
| 7022 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7023 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7024 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7025 | ASSERT_VK_SUCCESS(err); |
| 7026 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7027 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7028 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7029 | pipeline_layout_ci.setLayoutCount = 1; |
| 7030 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7031 | |
| 7032 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7033 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7034 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7035 | ASSERT_VK_SUCCESS(err); |
| 7036 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7037 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7038 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7039 | |
| 7040 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7041 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7042 | vp_state_ci.scissorCount = 1; |
| 7043 | vp_state_ci.pScissors = ≻ |
| 7044 | vp_state_ci.viewportCount = 1; |
| 7045 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7046 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7047 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7048 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7049 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7050 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7051 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7052 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7053 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7054 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7055 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7056 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7058 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7059 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7060 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7061 | gp_ci.layout = pipeline_layout; |
| 7062 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7063 | |
| 7064 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7065 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7066 | pc_ci.initialDataSize = 0; |
| 7067 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7068 | |
| 7069 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7070 | VkPipelineCache pipelineCache; |
| 7071 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7072 | err = |
| 7073 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7074 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7075 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7076 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7077 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7078 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7079 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7080 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7081 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7082 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7083 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7084 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7085 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 7086 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 7087 | { |
| 7088 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7089 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7090 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7091 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7092 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 7093 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7094 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7095 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7096 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7097 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7098 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7099 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7100 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7101 | |
| 7102 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7103 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7104 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7105 | ds_pool_ci.poolSizeCount = 1; |
| 7106 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7107 | |
| 7108 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7109 | err = vkCreateDescriptorPool(m_device->device(), |
| 7110 | 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] | 7111 | ASSERT_VK_SUCCESS(err); |
| 7112 | |
| 7113 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7114 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7115 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7116 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7117 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7118 | dsl_binding.pImmutableSamplers = NULL; |
| 7119 | |
| 7120 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7121 | ds_layout_ci.sType = |
| 7122 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7123 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7124 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7125 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7126 | |
| 7127 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7128 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7129 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7130 | ASSERT_VK_SUCCESS(err); |
| 7131 | |
| 7132 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7133 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 7134 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7135 | ASSERT_VK_SUCCESS(err); |
| 7136 | |
| 7137 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7138 | pipeline_layout_ci.sType = |
| 7139 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7140 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7141 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7142 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7143 | |
| 7144 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7145 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7146 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7147 | ASSERT_VK_SUCCESS(err); |
| 7148 | |
| 7149 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 7150 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7152 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 7153 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7154 | // 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] | 7155 | VkShaderObj |
| 7156 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 7157 | this); |
| 7158 | VkShaderObj |
| 7159 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 7160 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7162 | shaderStages[0].sType = |
| 7163 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7164 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7165 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7166 | shaderStages[1].sType = |
| 7167 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7168 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7169 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7170 | shaderStages[2].sType = |
| 7171 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7172 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7173 | shaderStages[2].shader = te.handle(); |
| 7174 | |
| 7175 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7176 | iaCI.sType = |
| 7177 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7178 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7179 | |
| 7180 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 7181 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 7182 | tsCI.patchControlPoints = 0; // This will cause an error |
| 7183 | |
| 7184 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7185 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7186 | gp_ci.pNext = NULL; |
| 7187 | gp_ci.stageCount = 3; |
| 7188 | gp_ci.pStages = shaderStages; |
| 7189 | gp_ci.pVertexInputState = NULL; |
| 7190 | gp_ci.pInputAssemblyState = &iaCI; |
| 7191 | gp_ci.pTessellationState = &tsCI; |
| 7192 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7193 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7194 | gp_ci.pMultisampleState = NULL; |
| 7195 | gp_ci.pDepthStencilState = NULL; |
| 7196 | gp_ci.pColorBlendState = NULL; |
| 7197 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7198 | gp_ci.layout = pipeline_layout; |
| 7199 | gp_ci.renderPass = renderPass(); |
| 7200 | |
| 7201 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7202 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7203 | pc_ci.pNext = NULL; |
| 7204 | pc_ci.initialSize = 0; |
| 7205 | pc_ci.initialData = 0; |
| 7206 | pc_ci.maxSize = 0; |
| 7207 | |
| 7208 | VkPipeline pipeline; |
| 7209 | VkPipelineCache pipelineCache; |
| 7210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7211 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 7212 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7213 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7214 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7215 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7216 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7217 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7218 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7219 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7220 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7221 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7222 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7223 | } |
| 7224 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7225 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7226 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7227 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7229 | m_errorMonitor->SetDesiredFailureMsg( |
| 7230 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7231 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 7232 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7235 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7236 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7237 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7238 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7239 | |
| 7240 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7241 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7242 | ds_pool_ci.maxSets = 1; |
| 7243 | ds_pool_ci.poolSizeCount = 1; |
| 7244 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7245 | |
| 7246 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7247 | err = |
| 7248 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7249 | ASSERT_VK_SUCCESS(err); |
| 7250 | |
| 7251 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7252 | dsl_binding.binding = 0; |
| 7253 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7254 | dsl_binding.descriptorCount = 1; |
| 7255 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7256 | |
| 7257 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7258 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7259 | ds_layout_ci.bindingCount = 1; |
| 7260 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7261 | |
| 7262 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7263 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7264 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7265 | ASSERT_VK_SUCCESS(err); |
| 7266 | |
| 7267 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7268 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7269 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7270 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7271 | alloc_info.descriptorPool = ds_pool; |
| 7272 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7273 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7274 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7275 | ASSERT_VK_SUCCESS(err); |
| 7276 | |
| 7277 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7278 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7279 | pipeline_layout_ci.setLayoutCount = 1; |
| 7280 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7281 | |
| 7282 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7283 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7284 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7285 | ASSERT_VK_SUCCESS(err); |
| 7286 | |
| 7287 | VkViewport vp = {}; // Just need dummy vp to point to |
| 7288 | |
| 7289 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7290 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7291 | vp_state_ci.scissorCount = 0; |
| 7292 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 7293 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7294 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7295 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7296 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7297 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7298 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7299 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7300 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7301 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7302 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7303 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7304 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7305 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7306 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7307 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7308 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7309 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7310 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7311 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7312 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7313 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7314 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7315 | |
| 7316 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7317 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7318 | gp_ci.stageCount = 2; |
| 7319 | gp_ci.pStages = shaderStages; |
| 7320 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7321 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7322 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7323 | gp_ci.layout = pipeline_layout; |
| 7324 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7325 | |
| 7326 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7327 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7328 | |
| 7329 | VkPipeline pipeline; |
| 7330 | VkPipelineCache pipelineCache; |
| 7331 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7332 | err = |
| 7333 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7334 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7335 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7336 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7338 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7339 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7340 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7341 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7342 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7343 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7344 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7345 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 7346 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7347 | // 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] | 7348 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7349 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7350 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7352 | m_errorMonitor->SetDesiredFailureMsg( |
| 7353 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7354 | "Gfx Pipeline pViewportState is null. Even if "); |
| 7355 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7356 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7357 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7358 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7359 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7360 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7361 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7362 | |
| 7363 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7364 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7365 | ds_pool_ci.maxSets = 1; |
| 7366 | ds_pool_ci.poolSizeCount = 1; |
| 7367 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7368 | |
| 7369 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7370 | err = |
| 7371 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7372 | ASSERT_VK_SUCCESS(err); |
| 7373 | |
| 7374 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7375 | dsl_binding.binding = 0; |
| 7376 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7377 | dsl_binding.descriptorCount = 1; |
| 7378 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7379 | |
| 7380 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7381 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7382 | ds_layout_ci.bindingCount = 1; |
| 7383 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7384 | |
| 7385 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7386 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7387 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7388 | ASSERT_VK_SUCCESS(err); |
| 7389 | |
| 7390 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7391 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7392 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7393 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7394 | alloc_info.descriptorPool = ds_pool; |
| 7395 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7396 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7397 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7398 | ASSERT_VK_SUCCESS(err); |
| 7399 | |
| 7400 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7401 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7402 | pipeline_layout_ci.setLayoutCount = 1; |
| 7403 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7404 | |
| 7405 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7406 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7407 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7408 | ASSERT_VK_SUCCESS(err); |
| 7409 | |
| 7410 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 7411 | // Set scissor as dynamic to avoid second error |
| 7412 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7413 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7414 | dyn_state_ci.dynamicStateCount = 1; |
| 7415 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7416 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7417 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7418 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7419 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7420 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7421 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7422 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7423 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7424 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7425 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7426 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7427 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7428 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7429 | |
| 7430 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 7431 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7432 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 7433 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 7434 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 7435 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 7436 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 7437 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 7438 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7439 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7440 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7441 | gp_ci.stageCount = 2; |
| 7442 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7443 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7444 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 7445 | // should cause validation error |
| 7446 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7447 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7448 | gp_ci.layout = pipeline_layout; |
| 7449 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7450 | |
| 7451 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7452 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7453 | |
| 7454 | VkPipeline pipeline; |
| 7455 | VkPipelineCache pipelineCache; |
| 7456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7457 | err = |
| 7458 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7459 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7460 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7461 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7463 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7464 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7465 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7466 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7467 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7468 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7469 | } |
| 7470 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7471 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 7472 | // count |
| 7473 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 7474 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7476 | m_errorMonitor->SetDesiredFailureMsg( |
| 7477 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7478 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 7479 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7482 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7483 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7485 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7486 | |
| 7487 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7488 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7489 | ds_pool_ci.maxSets = 1; |
| 7490 | ds_pool_ci.poolSizeCount = 1; |
| 7491 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7492 | |
| 7493 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7494 | err = |
| 7495 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7496 | ASSERT_VK_SUCCESS(err); |
| 7497 | |
| 7498 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7499 | dsl_binding.binding = 0; |
| 7500 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7501 | dsl_binding.descriptorCount = 1; |
| 7502 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7503 | |
| 7504 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7505 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7506 | ds_layout_ci.bindingCount = 1; |
| 7507 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7508 | |
| 7509 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7510 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7511 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7512 | ASSERT_VK_SUCCESS(err); |
| 7513 | |
| 7514 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7515 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7516 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7517 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7518 | alloc_info.descriptorPool = ds_pool; |
| 7519 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7520 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7521 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7522 | ASSERT_VK_SUCCESS(err); |
| 7523 | |
| 7524 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7525 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7526 | pipeline_layout_ci.setLayoutCount = 1; |
| 7527 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7528 | |
| 7529 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7530 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7531 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7532 | ASSERT_VK_SUCCESS(err); |
| 7533 | |
| 7534 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7535 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7536 | vp_state_ci.viewportCount = 1; |
| 7537 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 7538 | vp_state_ci.scissorCount = 1; |
| 7539 | vp_state_ci.pScissors = |
| 7540 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7541 | |
| 7542 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 7543 | // Set scissor as dynamic to avoid that error |
| 7544 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7545 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7546 | dyn_state_ci.dynamicStateCount = 1; |
| 7547 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7548 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 7549 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7550 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7552 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7553 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7554 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7555 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7556 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7557 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7558 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7559 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7560 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7561 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7562 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7563 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7564 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7565 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7566 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7567 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7568 | |
| 7569 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7570 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7571 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7572 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7573 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7574 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7575 | rs_ci.pNext = nullptr; |
| 7576 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7577 | VkPipelineColorBlendAttachmentState att = {}; |
| 7578 | att.blendEnable = VK_FALSE; |
| 7579 | att.colorWriteMask = 0xf; |
| 7580 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7581 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7582 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7583 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7584 | cb_ci.attachmentCount = 1; |
| 7585 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 7586 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7587 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7588 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7589 | gp_ci.stageCount = 2; |
| 7590 | gp_ci.pStages = shaderStages; |
| 7591 | gp_ci.pVertexInputState = &vi_ci; |
| 7592 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7593 | gp_ci.pViewportState = &vp_state_ci; |
| 7594 | gp_ci.pRasterizationState = &rs_ci; |
| 7595 | gp_ci.pColorBlendState = &cb_ci; |
| 7596 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7597 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7598 | gp_ci.layout = pipeline_layout; |
| 7599 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7600 | |
| 7601 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7602 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7603 | |
| 7604 | VkPipeline pipeline; |
| 7605 | VkPipelineCache pipelineCache; |
| 7606 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7607 | err = |
| 7608 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7609 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7610 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7611 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7612 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7613 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7614 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7615 | // 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] | 7616 | // First need to successfully create the PSO from above by setting |
| 7617 | // pViewports |
| 7618 | m_errorMonitor->SetDesiredFailureMsg( |
| 7619 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7620 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 7621 | "scissorCount is 1. These counts must match."); |
| 7622 | |
| 7623 | VkViewport vp = {}; // Just need dummy vp to point to |
| 7624 | vp_state_ci.pViewports = &vp; |
| 7625 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7626 | &gp_ci, NULL, &pipeline); |
| 7627 | ASSERT_VK_SUCCESS(err); |
| 7628 | BeginCommandBuffer(); |
| 7629 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7630 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7631 | VkRect2D scissors[2] = {}; // don't care about data |
| 7632 | // Count of 2 doesn't match PSO count of 1 |
| 7633 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 7634 | Draw(1, 0, 0, 0); |
| 7635 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7636 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7637 | |
| 7638 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7639 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7640 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7641 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7642 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7643 | } |
| 7644 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 7645 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 7646 | // viewportCount |
| 7647 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 7648 | VkResult err; |
| 7649 | |
| 7650 | m_errorMonitor->SetDesiredFailureMsg( |
| 7651 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7652 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 7653 | |
| 7654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7655 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7656 | |
| 7657 | VkDescriptorPoolSize ds_type_count = {}; |
| 7658 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7659 | ds_type_count.descriptorCount = 1; |
| 7660 | |
| 7661 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7662 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7663 | ds_pool_ci.maxSets = 1; |
| 7664 | ds_pool_ci.poolSizeCount = 1; |
| 7665 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7666 | |
| 7667 | VkDescriptorPool ds_pool; |
| 7668 | err = |
| 7669 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7670 | ASSERT_VK_SUCCESS(err); |
| 7671 | |
| 7672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7673 | dsl_binding.binding = 0; |
| 7674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7675 | dsl_binding.descriptorCount = 1; |
| 7676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7677 | |
| 7678 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7679 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7680 | ds_layout_ci.bindingCount = 1; |
| 7681 | ds_layout_ci.pBindings = &dsl_binding; |
| 7682 | |
| 7683 | VkDescriptorSetLayout ds_layout; |
| 7684 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7685 | &ds_layout); |
| 7686 | ASSERT_VK_SUCCESS(err); |
| 7687 | |
| 7688 | VkDescriptorSet descriptorSet; |
| 7689 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7690 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7691 | alloc_info.descriptorSetCount = 1; |
| 7692 | alloc_info.descriptorPool = ds_pool; |
| 7693 | alloc_info.pSetLayouts = &ds_layout; |
| 7694 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7695 | &descriptorSet); |
| 7696 | ASSERT_VK_SUCCESS(err); |
| 7697 | |
| 7698 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7699 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7700 | pipeline_layout_ci.setLayoutCount = 1; |
| 7701 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7702 | |
| 7703 | VkPipelineLayout pipeline_layout; |
| 7704 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7705 | &pipeline_layout); |
| 7706 | ASSERT_VK_SUCCESS(err); |
| 7707 | |
| 7708 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7709 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7710 | vp_state_ci.scissorCount = 1; |
| 7711 | vp_state_ci.pScissors = |
| 7712 | NULL; // Null scissor w/ count of 1 should cause error |
| 7713 | vp_state_ci.viewportCount = 1; |
| 7714 | vp_state_ci.pViewports = |
| 7715 | NULL; // vp is dynamic (below) so this won't cause error |
| 7716 | |
| 7717 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 7718 | // Set scissor as dynamic to avoid that error |
| 7719 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7720 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7721 | dyn_state_ci.dynamicStateCount = 1; |
| 7722 | dyn_state_ci.pDynamicStates = &vp_state; |
| 7723 | |
| 7724 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7725 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7726 | |
| 7727 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7728 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7729 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7730 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7731 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7732 | // but add it to be able to run on more devices |
| 7733 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7734 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7735 | |
| 7736 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7737 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7738 | vi_ci.pNext = nullptr; |
| 7739 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7740 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7741 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7742 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7743 | |
| 7744 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7745 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7746 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7747 | |
| 7748 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7749 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7750 | rs_ci.pNext = nullptr; |
| 7751 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7752 | VkPipelineColorBlendAttachmentState att = {}; |
| 7753 | att.blendEnable = VK_FALSE; |
| 7754 | att.colorWriteMask = 0xf; |
| 7755 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7756 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7757 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7758 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7759 | cb_ci.attachmentCount = 1; |
| 7760 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7761 | |
| 7762 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7763 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7764 | gp_ci.stageCount = 2; |
| 7765 | gp_ci.pStages = shaderStages; |
| 7766 | gp_ci.pVertexInputState = &vi_ci; |
| 7767 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7768 | gp_ci.pViewportState = &vp_state_ci; |
| 7769 | gp_ci.pRasterizationState = &rs_ci; |
| 7770 | gp_ci.pColorBlendState = &cb_ci; |
| 7771 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7772 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7773 | gp_ci.layout = pipeline_layout; |
| 7774 | gp_ci.renderPass = renderPass(); |
| 7775 | |
| 7776 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7777 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7778 | |
| 7779 | VkPipeline pipeline; |
| 7780 | VkPipelineCache pipelineCache; |
| 7781 | |
| 7782 | err = |
| 7783 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7784 | ASSERT_VK_SUCCESS(err); |
| 7785 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7786 | &gp_ci, NULL, &pipeline); |
| 7787 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7788 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7789 | |
| 7790 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 7791 | // First need to successfully create the PSO from above by setting |
| 7792 | // pViewports |
| 7793 | m_errorMonitor->SetDesiredFailureMsg( |
| 7794 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7795 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 7796 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7797 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7798 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 7799 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7800 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7801 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7802 | ASSERT_VK_SUCCESS(err); |
| 7803 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7804 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7805 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7806 | VkViewport viewports[2] = {}; // don't care about data |
| 7807 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 7808 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7809 | Draw(1, 0, 0, 0); |
| 7810 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7811 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7812 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7813 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7814 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7815 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7816 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7817 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7818 | } |
| 7819 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7820 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 7821 | VkResult err; |
| 7822 | |
| 7823 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7824 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7825 | |
| 7826 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7827 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7828 | |
| 7829 | VkDescriptorPoolSize ds_type_count = {}; |
| 7830 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7831 | ds_type_count.descriptorCount = 1; |
| 7832 | |
| 7833 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7834 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7835 | ds_pool_ci.maxSets = 1; |
| 7836 | ds_pool_ci.poolSizeCount = 1; |
| 7837 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7838 | |
| 7839 | VkDescriptorPool ds_pool; |
| 7840 | err = |
| 7841 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7842 | ASSERT_VK_SUCCESS(err); |
| 7843 | |
| 7844 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7845 | dsl_binding.binding = 0; |
| 7846 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7847 | dsl_binding.descriptorCount = 1; |
| 7848 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7849 | |
| 7850 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7851 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7852 | ds_layout_ci.bindingCount = 1; |
| 7853 | ds_layout_ci.pBindings = &dsl_binding; |
| 7854 | |
| 7855 | VkDescriptorSetLayout ds_layout; |
| 7856 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7857 | &ds_layout); |
| 7858 | ASSERT_VK_SUCCESS(err); |
| 7859 | |
| 7860 | VkDescriptorSet descriptorSet; |
| 7861 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7862 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7863 | alloc_info.descriptorSetCount = 1; |
| 7864 | alloc_info.descriptorPool = ds_pool; |
| 7865 | alloc_info.pSetLayouts = &ds_layout; |
| 7866 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7867 | &descriptorSet); |
| 7868 | ASSERT_VK_SUCCESS(err); |
| 7869 | |
| 7870 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7871 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7872 | pipeline_layout_ci.setLayoutCount = 1; |
| 7873 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7874 | |
| 7875 | VkPipelineLayout pipeline_layout; |
| 7876 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7877 | &pipeline_layout); |
| 7878 | ASSERT_VK_SUCCESS(err); |
| 7879 | |
| 7880 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7881 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7882 | vp_state_ci.scissorCount = 1; |
| 7883 | vp_state_ci.pScissors = NULL; |
| 7884 | vp_state_ci.viewportCount = 1; |
| 7885 | vp_state_ci.pViewports = NULL; |
| 7886 | |
| 7887 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 7888 | VK_DYNAMIC_STATE_SCISSOR, |
| 7889 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 7890 | // Set scissor as dynamic to avoid that error |
| 7891 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7892 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7893 | dyn_state_ci.dynamicStateCount = 2; |
| 7894 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 7895 | |
| 7896 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7897 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7898 | |
| 7899 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7900 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7901 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7902 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 7903 | this); // TODO - We shouldn't need a fragment shader |
| 7904 | // but add it to be able to run on more devices |
| 7905 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7906 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7907 | |
| 7908 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7909 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7910 | vi_ci.pNext = nullptr; |
| 7911 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7912 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7913 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7914 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7915 | |
| 7916 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7917 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7918 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7919 | |
| 7920 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7921 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7922 | rs_ci.pNext = nullptr; |
| 7923 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7924 | // Check too low (line width of -1.0f). |
| 7925 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7926 | |
| 7927 | VkPipelineColorBlendAttachmentState att = {}; |
| 7928 | att.blendEnable = VK_FALSE; |
| 7929 | att.colorWriteMask = 0xf; |
| 7930 | |
| 7931 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7932 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7933 | cb_ci.pNext = nullptr; |
| 7934 | cb_ci.attachmentCount = 1; |
| 7935 | cb_ci.pAttachments = &att; |
| 7936 | |
| 7937 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7938 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7939 | gp_ci.stageCount = 2; |
| 7940 | gp_ci.pStages = shaderStages; |
| 7941 | gp_ci.pVertexInputState = &vi_ci; |
| 7942 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7943 | gp_ci.pViewportState = &vp_state_ci; |
| 7944 | gp_ci.pRasterizationState = &rs_ci; |
| 7945 | gp_ci.pColorBlendState = &cb_ci; |
| 7946 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7947 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7948 | gp_ci.layout = pipeline_layout; |
| 7949 | gp_ci.renderPass = renderPass(); |
| 7950 | |
| 7951 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7952 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7953 | |
| 7954 | VkPipeline pipeline; |
| 7955 | VkPipelineCache pipelineCache; |
| 7956 | |
| 7957 | err = |
| 7958 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7959 | ASSERT_VK_SUCCESS(err); |
| 7960 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7961 | &gp_ci, NULL, &pipeline); |
| 7962 | |
| 7963 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7964 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7965 | |
| 7966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7967 | "Attempt to set lineWidth to 65536"); |
| 7968 | |
| 7969 | // Check too high (line width of 65536.0f). |
| 7970 | rs_ci.lineWidth = 65536.0f; |
| 7971 | |
| 7972 | err = |
| 7973 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7974 | ASSERT_VK_SUCCESS(err); |
| 7975 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7976 | &gp_ci, NULL, &pipeline); |
| 7977 | |
| 7978 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7979 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7980 | |
| 7981 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7982 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7983 | |
| 7984 | dyn_state_ci.dynamicStateCount = 3; |
| 7985 | |
| 7986 | rs_ci.lineWidth = 1.0f; |
| 7987 | |
| 7988 | err = |
| 7989 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7990 | ASSERT_VK_SUCCESS(err); |
| 7991 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7992 | &gp_ci, NULL, &pipeline); |
| 7993 | BeginCommandBuffer(); |
| 7994 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7995 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7996 | |
| 7997 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7998 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7999 | m_errorMonitor->VerifyFound(); |
| 8000 | |
| 8001 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8002 | "Attempt to set lineWidth to 65536"); |
| 8003 | |
| 8004 | // Check too high with dynamic setting. |
| 8005 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 8006 | m_errorMonitor->VerifyFound(); |
| 8007 | EndCommandBuffer(); |
| 8008 | |
| 8009 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 8010 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8011 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8012 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8013 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8014 | } |
| 8015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8016 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8017 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8018 | m_errorMonitor->SetDesiredFailureMsg( |
| 8019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8020 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8021 | |
| 8022 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8023 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8024 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8025 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8026 | // Don't care about RenderPass handle b/c error should be flagged before |
| 8027 | // that |
| 8028 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 8029 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8030 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8031 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8032 | } |
| 8033 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8034 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8035 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8036 | m_errorMonitor->SetDesiredFailureMsg( |
| 8037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8038 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8039 | |
| 8040 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8041 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8042 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8043 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8044 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 8045 | // proper error |
Chris Forbes | 38ae7c4 | 2016-06-21 20:51:44 +1200 | [diff] [blame] | 8046 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8047 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8048 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8049 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8050 | } |
| 8051 | |
Chris Forbes | 2eeabe3 | 2016-06-21 20:52:34 +1200 | [diff] [blame] | 8052 | TEST_F(VkLayerTest, RenderPassSecondaryCommandBuffersMultipleTimes) { |
| 8053 | m_errorMonitor->ExpectSuccess(); |
| 8054 | |
| 8055 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8056 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8057 | |
| 8058 | BeginCommandBuffer(); // framework implicitly begins the renderpass. |
| 8059 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); // end implicit. |
| 8060 | |
| 8061 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 8062 | VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 8063 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8064 | m_errorMonitor->VerifyNotFound(); |
| 8065 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 8066 | VK_SUBPASS_CONTENTS_INLINE); |
| 8067 | m_errorMonitor->VerifyNotFound(); |
| 8068 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8069 | m_errorMonitor->VerifyNotFound(); |
| 8070 | |
| 8071 | m_commandBuffer->EndCommandBuffer(); |
| 8072 | m_errorMonitor->VerifyNotFound(); |
| 8073 | } |
| 8074 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 8075 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 8076 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 8077 | "the number of renderPass attachments that use loadOp" |
| 8078 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 8079 | |
| 8080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8082 | |
| 8083 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 8084 | VkAttachmentReference attach = {}; |
| 8085 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8086 | VkSubpassDescription subpass = {}; |
| 8087 | subpass.inputAttachmentCount = 1; |
| 8088 | subpass.pInputAttachments = &attach; |
| 8089 | VkRenderPassCreateInfo rpci = {}; |
| 8090 | rpci.subpassCount = 1; |
| 8091 | rpci.pSubpasses = &subpass; |
| 8092 | rpci.attachmentCount = 1; |
| 8093 | VkAttachmentDescription attach_desc = {}; |
| 8094 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8095 | // Set loadOp to CLEAR |
| 8096 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8097 | rpci.pAttachments = &attach_desc; |
| 8098 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8099 | VkRenderPass rp; |
| 8100 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8101 | |
| 8102 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 8103 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 8104 | hinfo.renderPass = VK_NULL_HANDLE; |
| 8105 | hinfo.subpass = 0; |
| 8106 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 8107 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 8108 | hinfo.queryFlags = 0; |
| 8109 | hinfo.pipelineStatistics = 0; |
| 8110 | VkCommandBufferBeginInfo info = {}; |
| 8111 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 8112 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 8113 | info.pInheritanceInfo = &hinfo; |
| 8114 | |
| 8115 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 8116 | VkRenderPassBeginInfo rp_begin = {}; |
| 8117 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 8118 | rp_begin.pNext = NULL; |
| 8119 | rp_begin.renderPass = renderPass(); |
| 8120 | rp_begin.framebuffer = framebuffer(); |
| 8121 | rp_begin.clearValueCount = 0; // Should be 1 |
| 8122 | |
| 8123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8124 | " has a clearValueCount of 0 but the " |
| 8125 | "actual number of attachments in " |
| 8126 | "renderPass "); |
| 8127 | |
| 8128 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 8129 | VK_SUBPASS_CONTENTS_INLINE); |
| 8130 | |
| 8131 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 8132 | |
| 8133 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 8134 | } |
| 8135 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 8136 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 8137 | |
| 8138 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 8139 | |
| 8140 | m_errorMonitor->SetDesiredFailureMsg( |
| 8141 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8142 | "It is invalid to issue this call inside an active render pass"); |
| 8143 | |
| 8144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8145 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8146 | |
| 8147 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 8148 | BeginCommandBuffer(); |
| 8149 | |
| 8150 | // Call directly into vkEndCommandBuffer instead of the |
| 8151 | // the framework's EndCommandBuffer, which inserts a |
| 8152 | // vkEndRenderPass |
| 8153 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 8154 | |
| 8155 | m_errorMonitor->VerifyFound(); |
| 8156 | |
| 8157 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 8158 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 8159 | } |
| 8160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8161 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8162 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8163 | m_errorMonitor->SetDesiredFailureMsg( |
| 8164 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8165 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8166 | |
| 8167 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8168 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8169 | |
| 8170 | // Renderpass is started here |
| 8171 | BeginCommandBuffer(); |
| 8172 | |
| 8173 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8174 | vk_testing::Buffer dstBuffer; |
| 8175 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8176 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8177 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8178 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8179 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8180 | } |
| 8181 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8182 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8183 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8184 | m_errorMonitor->SetDesiredFailureMsg( |
| 8185 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8186 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8187 | |
| 8188 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8189 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8190 | |
| 8191 | // Renderpass is started here |
| 8192 | BeginCommandBuffer(); |
| 8193 | |
| 8194 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8195 | vk_testing::Buffer dstBuffer; |
| 8196 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8198 | VkDeviceSize dstOffset = 0; |
| 8199 | VkDeviceSize dataSize = 1024; |
| 8200 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8201 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8202 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 8203 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8204 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8205 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8206 | } |
| 8207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8208 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8209 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8210 | m_errorMonitor->SetDesiredFailureMsg( |
| 8211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8212 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8213 | |
| 8214 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8215 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8216 | |
| 8217 | // Renderpass is started here |
| 8218 | BeginCommandBuffer(); |
| 8219 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 8220 | VkClearColorValue clear_color; |
| 8221 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8222 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8223 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8224 | const int32_t tex_width = 32; |
| 8225 | const int32_t tex_height = 32; |
| 8226 | VkImageCreateInfo image_create_info = {}; |
| 8227 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8228 | image_create_info.pNext = NULL; |
| 8229 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8230 | image_create_info.format = tex_format; |
| 8231 | image_create_info.extent.width = tex_width; |
| 8232 | image_create_info.extent.height = tex_height; |
| 8233 | image_create_info.extent.depth = 1; |
| 8234 | image_create_info.mipLevels = 1; |
| 8235 | image_create_info.arrayLayers = 1; |
| 8236 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8237 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8238 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8240 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8241 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 8242 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8244 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 8245 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8246 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8247 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 8248 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8249 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8250 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8251 | } |
| 8252 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8253 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8254 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8255 | m_errorMonitor->SetDesiredFailureMsg( |
| 8256 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8257 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8258 | |
| 8259 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8260 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8261 | |
| 8262 | // Renderpass is started here |
| 8263 | BeginCommandBuffer(); |
| 8264 | |
| 8265 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 8266 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8267 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 8268 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8269 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8270 | image_create_info.extent.width = 64; |
| 8271 | image_create_info.extent.height = 64; |
| 8272 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8273 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8274 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8275 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8276 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 8277 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8279 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 8280 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8282 | vkCmdClearDepthStencilImage( |
| 8283 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 8284 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 8285 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8286 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8287 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8288 | } |
| 8289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8290 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8291 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8292 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8293 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8294 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8295 | "vkCmdClearAttachments: This call " |
| 8296 | "must be issued inside an active " |
| 8297 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8298 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8300 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8301 | |
| 8302 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8303 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8304 | ASSERT_VK_SUCCESS(err); |
| 8305 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8306 | VkClearAttachment color_attachment; |
| 8307 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8308 | color_attachment.clearValue.color.float32[0] = 0; |
| 8309 | color_attachment.clearValue.color.float32[1] = 0; |
| 8310 | color_attachment.clearValue.color.float32[2] = 0; |
| 8311 | color_attachment.clearValue.color.float32[3] = 0; |
| 8312 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8313 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 8314 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8315 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8316 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8317 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 8318 | } |
| 8319 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 8320 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 8321 | // Try to add a buffer memory barrier with no buffer. |
| 8322 | m_errorMonitor->SetDesiredFailureMsg( |
| 8323 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8324 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 8325 | |
| 8326 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8327 | BeginCommandBuffer(); |
| 8328 | |
| 8329 | VkBufferMemoryBarrier buf_barrier = {}; |
| 8330 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 8331 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8332 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8333 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8334 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8335 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 8336 | buf_barrier.offset = 0; |
| 8337 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8338 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8339 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 8340 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 8341 | |
| 8342 | m_errorMonitor->VerifyFound(); |
| 8343 | } |
| 8344 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 8345 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 8346 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 8347 | |
| 8348 | m_errorMonitor->SetDesiredFailureMsg( |
| 8349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 8350 | |
| 8351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8352 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8353 | |
| 8354 | VkMemoryBarrier mem_barrier = {}; |
| 8355 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 8356 | mem_barrier.pNext = NULL; |
| 8357 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8358 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8359 | BeginCommandBuffer(); |
| 8360 | // BeginCommandBuffer() starts a render pass |
| 8361 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8362 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8363 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 8364 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 8365 | m_errorMonitor->VerifyFound(); |
| 8366 | |
| 8367 | m_errorMonitor->SetDesiredFailureMsg( |
| 8368 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8369 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 8370 | VkImageObj image(m_device); |
| 8371 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8372 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 8373 | ASSERT_TRUE(image.initialized()); |
| 8374 | VkImageMemoryBarrier img_barrier = {}; |
| 8375 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 8376 | img_barrier.pNext = NULL; |
| 8377 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8378 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8379 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8380 | // New layout can't be UNDEFINED |
| 8381 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8382 | img_barrier.image = image.handle(); |
| 8383 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8384 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8385 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8386 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8387 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8388 | img_barrier.subresourceRange.layerCount = 1; |
| 8389 | img_barrier.subresourceRange.levelCount = 1; |
| 8390 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8391 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8392 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8393 | nullptr, 1, &img_barrier); |
| 8394 | m_errorMonitor->VerifyFound(); |
| 8395 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8396 | |
| 8397 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8398 | "Subresource must have the sum of the " |
| 8399 | "baseArrayLayer"); |
| 8400 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 8401 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 8402 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8403 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8404 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8405 | nullptr, 1, &img_barrier); |
| 8406 | m_errorMonitor->VerifyFound(); |
| 8407 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8408 | |
| 8409 | m_errorMonitor->SetDesiredFailureMsg( |
| 8410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8411 | "Subresource must have the sum of the baseMipLevel"); |
| 8412 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 8413 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 8414 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8415 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8416 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8417 | nullptr, 1, &img_barrier); |
| 8418 | m_errorMonitor->VerifyFound(); |
| 8419 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8420 | |
| 8421 | m_errorMonitor->SetDesiredFailureMsg( |
| 8422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8423 | "Buffer Barriers cannot be used during a render pass"); |
| 8424 | vk_testing::Buffer buffer; |
| 8425 | buffer.init(*m_device, 256); |
| 8426 | VkBufferMemoryBarrier buf_barrier = {}; |
| 8427 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 8428 | buf_barrier.pNext = NULL; |
| 8429 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8430 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8431 | buf_barrier.buffer = buffer.handle(); |
| 8432 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8433 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8434 | buf_barrier.offset = 0; |
| 8435 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8436 | // Can't send buffer barrier during a render pass |
| 8437 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8438 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8439 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8440 | &buf_barrier, 0, nullptr); |
| 8441 | m_errorMonitor->VerifyFound(); |
| 8442 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 8443 | |
| 8444 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8445 | "which is not less than total size"); |
| 8446 | buf_barrier.offset = 257; |
| 8447 | // Offset greater than total size |
| 8448 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8449 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8450 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8451 | &buf_barrier, 0, nullptr); |
| 8452 | m_errorMonitor->VerifyFound(); |
| 8453 | buf_barrier.offset = 0; |
| 8454 | |
| 8455 | m_errorMonitor->SetDesiredFailureMsg( |
| 8456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 8457 | buf_barrier.size = 257; |
| 8458 | // Size greater than total size |
| 8459 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8460 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8461 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 8462 | &buf_barrier, 0, nullptr); |
| 8463 | m_errorMonitor->VerifyFound(); |
| 8464 | buf_barrier.size = VK_WHOLE_SIZE; |
| 8465 | |
| 8466 | m_errorMonitor->SetDesiredFailureMsg( |
| 8467 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8468 | "Image is a depth and stencil format and thus must " |
| 8469 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 8470 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 8471 | VkDepthStencilObj ds_image(m_device); |
| 8472 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 8473 | ASSERT_TRUE(ds_image.initialized()); |
| 8474 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8475 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 8476 | img_barrier.image = ds_image.handle(); |
| 8477 | // Leave aspectMask at COLOR on purpose |
| 8478 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8479 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8480 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8481 | nullptr, 1, &img_barrier); |
| 8482 | m_errorMonitor->VerifyFound(); |
| 8483 | } |
| 8484 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8485 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8486 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8487 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8488 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8489 | m_errorMonitor->SetDesiredFailureMsg( |
| 8490 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8491 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 8492 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8493 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8495 | uint32_t qfi = 0; |
| 8496 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8497 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8498 | buffCI.size = 1024; |
| 8499 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 8500 | buffCI.queueFamilyIndexCount = 1; |
| 8501 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8502 | |
| 8503 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8504 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8505 | ASSERT_VK_SUCCESS(err); |
| 8506 | |
| 8507 | BeginCommandBuffer(); |
| 8508 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8509 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8510 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8511 | // 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] | 8512 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 8513 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8514 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8515 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8516 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8517 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 8518 | } |
| 8519 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8520 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 8521 | // Create an out-of-range queueFamilyIndex |
| 8522 | m_errorMonitor->SetDesiredFailureMsg( |
| 8523 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 8524 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 8525 | "of the indices specified when the device was created, via the " |
| 8526 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8527 | |
| 8528 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8529 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8530 | VkBufferCreateInfo buffCI = {}; |
| 8531 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8532 | buffCI.size = 1024; |
| 8533 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 8534 | buffCI.queueFamilyIndexCount = 1; |
| 8535 | // Introduce failure by specifying invalid queue_family_index |
| 8536 | uint32_t qfi = 777; |
| 8537 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 8538 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8539 | |
| 8540 | VkBuffer ib; |
| 8541 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 8542 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8543 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8544 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 8545 | } |
| 8546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8547 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 8548 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 8549 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8550 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8551 | m_errorMonitor->SetDesiredFailureMsg( |
| 8552 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8553 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8554 | |
| 8555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8557 | |
| 8558 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8559 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8560 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 8561 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8562 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8563 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 8564 | } |
| 8565 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 8566 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 8567 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 8568 | "that do not have correct usage bits sets."); |
| 8569 | VkResult err; |
| 8570 | |
| 8571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8572 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 8573 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8574 | ds_type_count[i].type = VkDescriptorType(i); |
| 8575 | ds_type_count[i].descriptorCount = 1; |
| 8576 | } |
| 8577 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8578 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8579 | ds_pool_ci.pNext = NULL; |
| 8580 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8581 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8582 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 8583 | |
| 8584 | VkDescriptorPool ds_pool; |
| 8585 | err = |
| 8586 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8587 | ASSERT_VK_SUCCESS(err); |
| 8588 | |
| 8589 | // Create 10 layouts where each has a single descriptor of different type |
| 8590 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 8591 | {}; |
| 8592 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8593 | dsl_binding[i].binding = 0; |
| 8594 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 8595 | dsl_binding[i].descriptorCount = 1; |
| 8596 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 8597 | dsl_binding[i].pImmutableSamplers = NULL; |
| 8598 | } |
| 8599 | |
| 8600 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8601 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8602 | ds_layout_ci.pNext = NULL; |
| 8603 | ds_layout_ci.bindingCount = 1; |
| 8604 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 8605 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8606 | ds_layout_ci.pBindings = dsl_binding + i; |
| 8607 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 8608 | NULL, ds_layouts + i); |
| 8609 | ASSERT_VK_SUCCESS(err); |
| 8610 | } |
| 8611 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 8612 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8613 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8614 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 8615 | alloc_info.descriptorPool = ds_pool; |
| 8616 | alloc_info.pSetLayouts = ds_layouts; |
| 8617 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8618 | descriptor_sets); |
| 8619 | ASSERT_VK_SUCCESS(err); |
| 8620 | |
| 8621 | // Create a buffer & bufferView to be used for invalid updates |
| 8622 | VkBufferCreateInfo buff_ci = {}; |
| 8623 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 8624 | // This usage is not valid for any descriptor type |
| 8625 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 8626 | buff_ci.size = 256; |
| 8627 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8628 | VkBuffer buffer; |
| 8629 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 8630 | ASSERT_VK_SUCCESS(err); |
| 8631 | |
| 8632 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 8633 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 8634 | buff_view_ci.buffer = buffer; |
| 8635 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 8636 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 8637 | VkBufferView buff_view; |
| 8638 | err = |
| 8639 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 8640 | ASSERT_VK_SUCCESS(err); |
| 8641 | |
| 8642 | // Create an image to be used for invalid updates |
| 8643 | VkImageCreateInfo image_ci = {}; |
| 8644 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8645 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8646 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8647 | image_ci.extent.width = 64; |
| 8648 | image_ci.extent.height = 64; |
| 8649 | image_ci.extent.depth = 1; |
| 8650 | image_ci.mipLevels = 1; |
| 8651 | image_ci.arrayLayers = 1; |
| 8652 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8653 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8654 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8655 | // This usage is not valid for any descriptor type |
| 8656 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8657 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8658 | VkImage image; |
| 8659 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8660 | ASSERT_VK_SUCCESS(err); |
| 8661 | // Bind memory to image |
| 8662 | VkMemoryRequirements mem_reqs; |
| 8663 | VkDeviceMemory image_mem; |
| 8664 | bool pass; |
| 8665 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8666 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8667 | mem_alloc.pNext = NULL; |
| 8668 | mem_alloc.allocationSize = 0; |
| 8669 | mem_alloc.memoryTypeIndex = 0; |
| 8670 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8671 | mem_alloc.allocationSize = mem_reqs.size; |
| 8672 | pass = |
| 8673 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8674 | ASSERT_TRUE(pass); |
| 8675 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8676 | ASSERT_VK_SUCCESS(err); |
| 8677 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8678 | ASSERT_VK_SUCCESS(err); |
| 8679 | // Now create view for image |
| 8680 | VkImageViewCreateInfo image_view_ci = {}; |
| 8681 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8682 | image_view_ci.image = image; |
| 8683 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8684 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8685 | image_view_ci.subresourceRange.layerCount = 1; |
| 8686 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8687 | image_view_ci.subresourceRange.levelCount = 1; |
| 8688 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8689 | VkImageView image_view; |
| 8690 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8691 | &image_view); |
| 8692 | ASSERT_VK_SUCCESS(err); |
| 8693 | |
| 8694 | VkDescriptorBufferInfo buff_info = {}; |
| 8695 | buff_info.buffer = buffer; |
| 8696 | VkDescriptorImageInfo img_info = {}; |
| 8697 | img_info.imageView = image_view; |
| 8698 | VkWriteDescriptorSet descriptor_write = {}; |
| 8699 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8700 | descriptor_write.dstBinding = 0; |
| 8701 | descriptor_write.descriptorCount = 1; |
| 8702 | descriptor_write.pTexelBufferView = &buff_view; |
| 8703 | descriptor_write.pBufferInfo = &buff_info; |
| 8704 | descriptor_write.pImageInfo = &img_info; |
| 8705 | |
| 8706 | // These error messages align with VkDescriptorType struct |
| 8707 | const char *error_msgs[] = { |
| 8708 | "", // placeholder, no error for SAMPLER descriptor |
| 8709 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8710 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8711 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 8712 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 8713 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 8714 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8715 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8716 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8717 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8718 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 8719 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 8720 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8721 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 8722 | descriptor_write.dstSet = descriptor_sets[i]; |
| 8723 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8724 | error_msgs[i]); |
| 8725 | |
| 8726 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 8727 | NULL); |
| 8728 | |
| 8729 | m_errorMonitor->VerifyFound(); |
| 8730 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 8731 | } |
| 8732 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 8733 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8734 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 8735 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8736 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 8737 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 8738 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 8739 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 8740 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8741 | } |
| 8742 | |
Tobin Ehlis | 2fc296b | 2016-06-15 14:05:27 -0600 | [diff] [blame] | 8743 | TEST_F(VkLayerTest, DSAspectBitsErrors) { |
| 8744 | // TODO : Initially only catching case where DEPTH & STENCIL aspect bits |
| 8745 | // are set, but could expand this test to hit more cases. |
| 8746 | TEST_DESCRIPTION("Attempt to update descriptor sets for images " |
| 8747 | "that do not have correct aspect bits sets."); |
| 8748 | VkResult err; |
| 8749 | |
| 8750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8751 | VkDescriptorPoolSize ds_type_count = {}; |
| 8752 | ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8753 | ds_type_count.descriptorCount = 1; |
| 8754 | |
| 8755 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8756 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8757 | ds_pool_ci.pNext = NULL; |
| 8758 | ds_pool_ci.maxSets = 5; |
| 8759 | ds_pool_ci.poolSizeCount = 1; |
| 8760 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8761 | |
| 8762 | VkDescriptorPool ds_pool; |
| 8763 | err = |
| 8764 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8765 | ASSERT_VK_SUCCESS(err); |
| 8766 | |
| 8767 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8768 | dsl_binding.binding = 0; |
| 8769 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8770 | dsl_binding.descriptorCount = 1; |
| 8771 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8772 | dsl_binding.pImmutableSamplers = NULL; |
| 8773 | |
| 8774 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8775 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8776 | ds_layout_ci.pNext = NULL; |
| 8777 | ds_layout_ci.bindingCount = 1; |
| 8778 | ds_layout_ci.pBindings = &dsl_binding; |
| 8779 | VkDescriptorSetLayout ds_layout; |
| 8780 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8781 | &ds_layout); |
| 8782 | ASSERT_VK_SUCCESS(err); |
| 8783 | |
| 8784 | VkDescriptorSet descriptor_set = {}; |
| 8785 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8786 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8787 | alloc_info.descriptorSetCount = 1; |
| 8788 | alloc_info.descriptorPool = ds_pool; |
| 8789 | alloc_info.pSetLayouts = &ds_layout; |
| 8790 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8791 | &descriptor_set); |
| 8792 | ASSERT_VK_SUCCESS(err); |
| 8793 | |
| 8794 | // Create an image to be used for invalid updates |
| 8795 | VkImageCreateInfo image_ci = {}; |
| 8796 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8797 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8798 | image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8799 | image_ci.extent.width = 64; |
| 8800 | image_ci.extent.height = 64; |
| 8801 | image_ci.extent.depth = 1; |
| 8802 | image_ci.mipLevels = 1; |
| 8803 | image_ci.arrayLayers = 1; |
| 8804 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8805 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8806 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8807 | image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8808 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8809 | VkImage image; |
| 8810 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8811 | ASSERT_VK_SUCCESS(err); |
| 8812 | // Bind memory to image |
| 8813 | VkMemoryRequirements mem_reqs; |
| 8814 | VkDeviceMemory image_mem; |
| 8815 | bool pass; |
| 8816 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8817 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8818 | mem_alloc.pNext = NULL; |
| 8819 | mem_alloc.allocationSize = 0; |
| 8820 | mem_alloc.memoryTypeIndex = 0; |
| 8821 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8822 | mem_alloc.allocationSize = mem_reqs.size; |
| 8823 | pass = |
| 8824 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8825 | ASSERT_TRUE(pass); |
| 8826 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8827 | ASSERT_VK_SUCCESS(err); |
| 8828 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8829 | ASSERT_VK_SUCCESS(err); |
| 8830 | // Now create view for image |
| 8831 | VkImageViewCreateInfo image_view_ci = {}; |
| 8832 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8833 | image_view_ci.image = image; |
| 8834 | image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8835 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8836 | image_view_ci.subresourceRange.layerCount = 1; |
| 8837 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8838 | image_view_ci.subresourceRange.levelCount = 1; |
| 8839 | // Setting both depth & stencil aspect bits is illegal for descriptor |
| 8840 | image_view_ci.subresourceRange.aspectMask = |
| 8841 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 8842 | |
| 8843 | VkImageView image_view; |
| 8844 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8845 | &image_view); |
| 8846 | ASSERT_VK_SUCCESS(err); |
| 8847 | |
| 8848 | VkDescriptorImageInfo img_info = {}; |
| 8849 | img_info.imageView = image_view; |
| 8850 | VkWriteDescriptorSet descriptor_write = {}; |
| 8851 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8852 | descriptor_write.dstBinding = 0; |
| 8853 | descriptor_write.descriptorCount = 1; |
| 8854 | descriptor_write.pTexelBufferView = NULL; |
| 8855 | descriptor_write.pBufferInfo = NULL; |
| 8856 | descriptor_write.pImageInfo = &img_info; |
| 8857 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8858 | descriptor_write.dstSet = descriptor_set; |
| 8859 | const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT " |
| 8860 | "or VK_IMAGE_ASPECT_STENCIL_BIT "; |
| 8861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8862 | error_msg); |
| 8863 | |
| 8864 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8865 | |
| 8866 | m_errorMonitor->VerifyFound(); |
| 8867 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8868 | vkDestroyImage(m_device->device(), image, NULL); |
| 8869 | vkFreeMemory(m_device->device(), image_mem, NULL); |
| 8870 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8871 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); |
| 8872 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8873 | } |
| 8874 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8875 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8876 | // 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] | 8877 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8878 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8879 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8881 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 8882 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8883 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8885 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8886 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8887 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8888 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8889 | |
| 8890 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8891 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8892 | ds_pool_ci.pNext = NULL; |
| 8893 | ds_pool_ci.maxSets = 1; |
| 8894 | ds_pool_ci.poolSizeCount = 1; |
| 8895 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8896 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8897 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8898 | err = |
| 8899 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8900 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8901 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8902 | dsl_binding.binding = 0; |
| 8903 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8904 | dsl_binding.descriptorCount = 1; |
| 8905 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8906 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8907 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8908 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8909 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8910 | ds_layout_ci.pNext = NULL; |
| 8911 | ds_layout_ci.bindingCount = 1; |
| 8912 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8913 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8914 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8915 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8916 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8917 | ASSERT_VK_SUCCESS(err); |
| 8918 | |
| 8919 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8920 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8921 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8922 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8923 | alloc_info.descriptorPool = ds_pool; |
| 8924 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8925 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8926 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8927 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8928 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 8929 | VkSamplerCreateInfo sampler_ci = {}; |
| 8930 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8931 | sampler_ci.pNext = NULL; |
| 8932 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8933 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8934 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8935 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8936 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8937 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8938 | sampler_ci.mipLodBias = 1.0; |
| 8939 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8940 | sampler_ci.maxAnisotropy = 1; |
| 8941 | sampler_ci.compareEnable = VK_FALSE; |
| 8942 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8943 | sampler_ci.minLod = 1.0; |
| 8944 | sampler_ci.maxLod = 1.0; |
| 8945 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8946 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 8947 | VkSampler sampler; |
| 8948 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 8949 | ASSERT_VK_SUCCESS(err); |
| 8950 | |
| 8951 | VkDescriptorImageInfo info = {}; |
| 8952 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8953 | |
| 8954 | VkWriteDescriptorSet descriptor_write; |
| 8955 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8956 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8957 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8958 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8959 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8960 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8961 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8962 | |
| 8963 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8964 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8965 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8966 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8967 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8968 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8969 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8970 | } |
| 8971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8972 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8973 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8974 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8976 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8977 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8978 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 8979 | "starting at binding offset of 0 combined with update array element " |
| 8980 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8981 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8983 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8984 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8985 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8986 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8987 | |
| 8988 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8989 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8990 | ds_pool_ci.pNext = NULL; |
| 8991 | ds_pool_ci.maxSets = 1; |
| 8992 | ds_pool_ci.poolSizeCount = 1; |
| 8993 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8994 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8995 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8996 | err = |
| 8997 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8998 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8999 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9000 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9001 | dsl_binding.binding = 0; |
| 9002 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9003 | dsl_binding.descriptorCount = 1; |
| 9004 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9005 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9006 | |
| 9007 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9008 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9009 | ds_layout_ci.pNext = NULL; |
| 9010 | ds_layout_ci.bindingCount = 1; |
| 9011 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9012 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9013 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9014 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9015 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9016 | ASSERT_VK_SUCCESS(err); |
| 9017 | |
| 9018 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9019 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9020 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9021 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9022 | alloc_info.descriptorPool = ds_pool; |
| 9023 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9024 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9025 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9026 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9027 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 9028 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 9029 | VkDescriptorBufferInfo buff_info = {}; |
| 9030 | buff_info.buffer = |
| 9031 | VkBuffer(0); // Don't care about buffer handle for this test |
| 9032 | buff_info.offset = 0; |
| 9033 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9034 | |
| 9035 | VkWriteDescriptorSet descriptor_write; |
| 9036 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9037 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9038 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9039 | descriptor_write.dstArrayElement = |
| 9040 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9041 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9042 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9043 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9044 | |
| 9045 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9046 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9047 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9048 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9049 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9050 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9051 | } |
| 9052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9053 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 9054 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 9055 | // index 2 |
| 9056 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9057 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9058 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9059 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9060 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9061 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9062 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9063 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9064 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9065 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9066 | |
| 9067 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9068 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9069 | ds_pool_ci.pNext = NULL; |
| 9070 | ds_pool_ci.maxSets = 1; |
| 9071 | ds_pool_ci.poolSizeCount = 1; |
| 9072 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9073 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9074 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9075 | err = |
| 9076 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9077 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9078 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9079 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9080 | dsl_binding.binding = 0; |
| 9081 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9082 | dsl_binding.descriptorCount = 1; |
| 9083 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9084 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9085 | |
| 9086 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9087 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9088 | ds_layout_ci.pNext = NULL; |
| 9089 | ds_layout_ci.bindingCount = 1; |
| 9090 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9091 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9092 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9093 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9094 | ASSERT_VK_SUCCESS(err); |
| 9095 | |
| 9096 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9097 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9098 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9099 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9100 | alloc_info.descriptorPool = ds_pool; |
| 9101 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9102 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9103 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9104 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9105 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9106 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9107 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9108 | sampler_ci.pNext = NULL; |
| 9109 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9110 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9111 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9112 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9113 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9114 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9115 | sampler_ci.mipLodBias = 1.0; |
| 9116 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9117 | sampler_ci.maxAnisotropy = 1; |
| 9118 | sampler_ci.compareEnable = VK_FALSE; |
| 9119 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9120 | sampler_ci.minLod = 1.0; |
| 9121 | sampler_ci.maxLod = 1.0; |
| 9122 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9123 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9124 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9125 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9126 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9127 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9128 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9129 | VkDescriptorImageInfo info = {}; |
| 9130 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9131 | |
| 9132 | VkWriteDescriptorSet descriptor_write; |
| 9133 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9134 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9135 | descriptor_write.dstSet = descriptorSet; |
| 9136 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9137 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9138 | // 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] | 9139 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9140 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9141 | |
| 9142 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9143 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9144 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9145 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9146 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9147 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9148 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9149 | } |
| 9150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9151 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 9152 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 9153 | // types |
| 9154 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9155 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9156 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 9157 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9158 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9159 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9160 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9161 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9162 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9163 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9164 | |
| 9165 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9166 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9167 | ds_pool_ci.pNext = NULL; |
| 9168 | ds_pool_ci.maxSets = 1; |
| 9169 | ds_pool_ci.poolSizeCount = 1; |
| 9170 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9171 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9172 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9173 | err = |
| 9174 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9175 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9176 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9177 | dsl_binding.binding = 0; |
| 9178 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9179 | dsl_binding.descriptorCount = 1; |
| 9180 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9181 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9182 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9183 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9184 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9185 | ds_layout_ci.pNext = NULL; |
| 9186 | ds_layout_ci.bindingCount = 1; |
| 9187 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9188 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9189 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9190 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9191 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9192 | ASSERT_VK_SUCCESS(err); |
| 9193 | |
| 9194 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9195 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9196 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9197 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9198 | alloc_info.descriptorPool = ds_pool; |
| 9199 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9200 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9201 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9202 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9203 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9204 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9205 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9206 | sampler_ci.pNext = NULL; |
| 9207 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9208 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9209 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9210 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9211 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9212 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9213 | sampler_ci.mipLodBias = 1.0; |
| 9214 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9215 | sampler_ci.maxAnisotropy = 1; |
| 9216 | sampler_ci.compareEnable = VK_FALSE; |
| 9217 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9218 | sampler_ci.minLod = 1.0; |
| 9219 | sampler_ci.maxLod = 1.0; |
| 9220 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9221 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9222 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9223 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9224 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9225 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9226 | VkDescriptorImageInfo info = {}; |
| 9227 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9228 | |
| 9229 | VkWriteDescriptorSet descriptor_write; |
| 9230 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9231 | descriptor_write.sType = |
| 9232 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9233 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9234 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9235 | // 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] | 9236 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9237 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9238 | |
| 9239 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9240 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9241 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9242 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9243 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9244 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9245 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9246 | } |
| 9247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9248 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9249 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9250 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9252 | m_errorMonitor->SetDesiredFailureMsg( |
| 9253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9254 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9255 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9256 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9257 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 9258 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9259 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9260 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9261 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9262 | |
| 9263 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9264 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9265 | ds_pool_ci.pNext = NULL; |
| 9266 | ds_pool_ci.maxSets = 1; |
| 9267 | ds_pool_ci.poolSizeCount = 1; |
| 9268 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9269 | |
| 9270 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9271 | err = |
| 9272 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9273 | ASSERT_VK_SUCCESS(err); |
| 9274 | |
| 9275 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9276 | dsl_binding.binding = 0; |
| 9277 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9278 | dsl_binding.descriptorCount = 1; |
| 9279 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9280 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9281 | |
| 9282 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9283 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9284 | ds_layout_ci.pNext = NULL; |
| 9285 | ds_layout_ci.bindingCount = 1; |
| 9286 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9287 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9288 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9289 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9290 | ASSERT_VK_SUCCESS(err); |
| 9291 | |
| 9292 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9293 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9294 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9295 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9296 | alloc_info.descriptorPool = ds_pool; |
| 9297 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9298 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9299 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9300 | ASSERT_VK_SUCCESS(err); |
| 9301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9302 | VkSampler sampler = |
| 9303 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9304 | |
| 9305 | VkDescriptorImageInfo descriptor_info; |
| 9306 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 9307 | descriptor_info.sampler = sampler; |
| 9308 | |
| 9309 | VkWriteDescriptorSet descriptor_write; |
| 9310 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9311 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9312 | descriptor_write.dstSet = descriptorSet; |
| 9313 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9314 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9315 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9316 | descriptor_write.pImageInfo = &descriptor_info; |
| 9317 | |
| 9318 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9319 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9320 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9321 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9322 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9323 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9324 | } |
| 9325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9326 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 9327 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 9328 | // imageView |
| 9329 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9330 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9332 | "Attempted write update to combined " |
| 9333 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 9334 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9335 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9337 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9338 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9339 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9340 | |
| 9341 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9342 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9343 | ds_pool_ci.pNext = NULL; |
| 9344 | ds_pool_ci.maxSets = 1; |
| 9345 | ds_pool_ci.poolSizeCount = 1; |
| 9346 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9347 | |
| 9348 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9349 | err = |
| 9350 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9351 | ASSERT_VK_SUCCESS(err); |
| 9352 | |
| 9353 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9354 | dsl_binding.binding = 0; |
| 9355 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9356 | dsl_binding.descriptorCount = 1; |
| 9357 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9358 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9359 | |
| 9360 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9361 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9362 | ds_layout_ci.pNext = NULL; |
| 9363 | ds_layout_ci.bindingCount = 1; |
| 9364 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9365 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9366 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9367 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9368 | ASSERT_VK_SUCCESS(err); |
| 9369 | |
| 9370 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9371 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9372 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9373 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9374 | alloc_info.descriptorPool = ds_pool; |
| 9375 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9376 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9377 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9378 | ASSERT_VK_SUCCESS(err); |
| 9379 | |
| 9380 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9381 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9382 | sampler_ci.pNext = NULL; |
| 9383 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9384 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9385 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9386 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9387 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9388 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9389 | sampler_ci.mipLodBias = 1.0; |
| 9390 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9391 | sampler_ci.maxAnisotropy = 1; |
| 9392 | sampler_ci.compareEnable = VK_FALSE; |
| 9393 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9394 | sampler_ci.minLod = 1.0; |
| 9395 | sampler_ci.maxLod = 1.0; |
| 9396 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9397 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9398 | |
| 9399 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9400 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9401 | ASSERT_VK_SUCCESS(err); |
| 9402 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9403 | VkImageView view = |
| 9404 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9405 | |
| 9406 | VkDescriptorImageInfo descriptor_info; |
| 9407 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 9408 | descriptor_info.sampler = sampler; |
| 9409 | descriptor_info.imageView = view; |
| 9410 | |
| 9411 | VkWriteDescriptorSet descriptor_write; |
| 9412 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 9413 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9414 | descriptor_write.dstSet = descriptorSet; |
| 9415 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9416 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9417 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 9418 | descriptor_write.pImageInfo = &descriptor_info; |
| 9419 | |
| 9420 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9422 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9424 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9425 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9426 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9427 | } |
| 9428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9429 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 9430 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 9431 | // into the other |
| 9432 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9433 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9434 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9435 | " binding #1 with type " |
| 9436 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 9437 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9438 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9440 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9441 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9442 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9443 | ds_type_count[0].descriptorCount = 1; |
| 9444 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9445 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9446 | |
| 9447 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9448 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9449 | ds_pool_ci.pNext = NULL; |
| 9450 | ds_pool_ci.maxSets = 1; |
| 9451 | ds_pool_ci.poolSizeCount = 2; |
| 9452 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9453 | |
| 9454 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9455 | err = |
| 9456 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9457 | ASSERT_VK_SUCCESS(err); |
| 9458 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9459 | dsl_binding[0].binding = 0; |
| 9460 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9461 | dsl_binding[0].descriptorCount = 1; |
| 9462 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 9463 | dsl_binding[0].pImmutableSamplers = NULL; |
| 9464 | dsl_binding[1].binding = 1; |
| 9465 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9466 | dsl_binding[1].descriptorCount = 1; |
| 9467 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 9468 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9469 | |
| 9470 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9471 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9472 | ds_layout_ci.pNext = NULL; |
| 9473 | ds_layout_ci.bindingCount = 2; |
| 9474 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9475 | |
| 9476 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9477 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9478 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9479 | ASSERT_VK_SUCCESS(err); |
| 9480 | |
| 9481 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9482 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9483 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9484 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9485 | alloc_info.descriptorPool = ds_pool; |
| 9486 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9487 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9488 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9489 | ASSERT_VK_SUCCESS(err); |
| 9490 | |
| 9491 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9492 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 9493 | sampler_ci.pNext = NULL; |
| 9494 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 9495 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 9496 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 9497 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9498 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9499 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 9500 | sampler_ci.mipLodBias = 1.0; |
| 9501 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 9502 | sampler_ci.maxAnisotropy = 1; |
| 9503 | sampler_ci.compareEnable = VK_FALSE; |
| 9504 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 9505 | sampler_ci.minLod = 1.0; |
| 9506 | sampler_ci.maxLod = 1.0; |
| 9507 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 9508 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9509 | |
| 9510 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9511 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9512 | ASSERT_VK_SUCCESS(err); |
| 9513 | |
| 9514 | VkDescriptorImageInfo info = {}; |
| 9515 | info.sampler = sampler; |
| 9516 | |
| 9517 | VkWriteDescriptorSet descriptor_write; |
| 9518 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 9519 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9520 | descriptor_write.dstSet = descriptorSet; |
| 9521 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9522 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9523 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 9524 | descriptor_write.pImageInfo = &info; |
| 9525 | // This write update should succeed |
| 9526 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 9527 | // Now perform a copy update that fails due to type mismatch |
| 9528 | VkCopyDescriptorSet copy_ds_update; |
| 9529 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9530 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9531 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9532 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9533 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9534 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9535 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9536 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9537 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9538 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9539 | // 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] | 9540 | m_errorMonitor->SetDesiredFailureMsg( |
| 9541 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9542 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9543 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9544 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9545 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9546 | copy_ds_update.srcBinding = |
| 9547 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9548 | copy_ds_update.dstSet = descriptorSet; |
| 9549 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9550 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9551 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9552 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9553 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9554 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9555 | // 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] | 9556 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 9558 | "update array offset of 0 and update of " |
| 9559 | "5 descriptors oversteps total number " |
| 9560 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9561 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9562 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 9563 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 9564 | copy_ds_update.srcSet = descriptorSet; |
| 9565 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9566 | copy_ds_update.dstSet = descriptorSet; |
| 9567 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9568 | copy_ds_update.descriptorCount = |
| 9569 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9570 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 9571 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9572 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9573 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9574 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 9575 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9576 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 9577 | } |
| 9578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9579 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 9580 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 9581 | // sampleCount |
| 9582 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9583 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9584 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9585 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9586 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9587 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9588 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9589 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9590 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9591 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9592 | |
| 9593 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9594 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9595 | ds_pool_ci.pNext = NULL; |
| 9596 | ds_pool_ci.maxSets = 1; |
| 9597 | ds_pool_ci.poolSizeCount = 1; |
| 9598 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9599 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9600 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9601 | err = |
| 9602 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9603 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9604 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9605 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 9606 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9607 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 9608 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9609 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9610 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9611 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9612 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9613 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9614 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9615 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 9616 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9617 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9618 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9619 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9620 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9621 | ASSERT_VK_SUCCESS(err); |
| 9622 | |
| 9623 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9624 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9625 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9626 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9627 | alloc_info.descriptorPool = ds_pool; |
| 9628 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9629 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9630 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9631 | ASSERT_VK_SUCCESS(err); |
| 9632 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9633 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9634 | pipe_ms_state_ci.sType = |
| 9635 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9636 | pipe_ms_state_ci.pNext = NULL; |
| 9637 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9638 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9639 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9640 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9641 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9642 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9643 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9644 | pipeline_layout_ci.pNext = NULL; |
| 9645 | pipeline_layout_ci.setLayoutCount = 1; |
| 9646 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9647 | |
| 9648 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9649 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9650 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9651 | ASSERT_VK_SUCCESS(err); |
| 9652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9653 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9654 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9655 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9656 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9657 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9658 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9659 | VkPipelineObj pipe(m_device); |
| 9660 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9661 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9662 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9663 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9664 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9665 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9666 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9667 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9668 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9669 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9670 | // Render triangle (the error should trigger on the attempt to draw). |
| 9671 | Draw(3, 1, 0, 0); |
| 9672 | |
| 9673 | // Finalize recording of the command buffer |
| 9674 | EndCommandBuffer(); |
| 9675 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9676 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9677 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9678 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9679 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9680 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9681 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9682 | |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9683 | TEST_F(VkLayerTest, RenderPassIncompatible) { |
| 9684 | TEST_DESCRIPTION("Hit RenderPass incompatible cases. " |
| 9685 | "Initial case is drawing with an active renderpass that's " |
| 9686 | "not compatible with the bound PSO's creation renderpass"); |
| 9687 | VkResult err; |
| 9688 | |
| 9689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9690 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9691 | |
| 9692 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9693 | dsl_binding.binding = 0; |
| 9694 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9695 | dsl_binding.descriptorCount = 1; |
| 9696 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9697 | dsl_binding.pImmutableSamplers = NULL; |
| 9698 | |
| 9699 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9700 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9701 | ds_layout_ci.pNext = NULL; |
| 9702 | ds_layout_ci.bindingCount = 1; |
| 9703 | ds_layout_ci.pBindings = &dsl_binding; |
| 9704 | |
| 9705 | VkDescriptorSetLayout ds_layout; |
| 9706 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9707 | &ds_layout); |
| 9708 | ASSERT_VK_SUCCESS(err); |
| 9709 | |
| 9710 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9711 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9712 | pipeline_layout_ci.pNext = NULL; |
| 9713 | pipeline_layout_ci.setLayoutCount = 1; |
| 9714 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9715 | |
| 9716 | VkPipelineLayout pipeline_layout; |
| 9717 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9718 | &pipeline_layout); |
| 9719 | ASSERT_VK_SUCCESS(err); |
| 9720 | |
| 9721 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9722 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9723 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9724 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 9725 | this); // We shouldn't need a fragment shader |
| 9726 | // but add it to be able to run on more devices |
| 9727 | // Create a renderpass that will be incompatible with default renderpass |
| 9728 | VkAttachmentReference attach = {}; |
| 9729 | attach.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 9730 | VkAttachmentReference color_att = {}; |
| 9731 | color_att.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9732 | VkSubpassDescription subpass = {}; |
| 9733 | subpass.inputAttachmentCount = 1; |
| 9734 | subpass.pInputAttachments = &attach; |
| 9735 | subpass.colorAttachmentCount = 1; |
| 9736 | subpass.pColorAttachments = &color_att; |
| 9737 | VkRenderPassCreateInfo rpci = {}; |
| 9738 | rpci.subpassCount = 1; |
| 9739 | rpci.pSubpasses = &subpass; |
| 9740 | rpci.attachmentCount = 1; |
| 9741 | VkAttachmentDescription attach_desc = {}; |
| 9742 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Cody Northrop | bd16af1 | 2016-06-21 09:25:48 -0600 | [diff] [blame] | 9743 | // Format incompatible with PSO RP color attach format B8G8R8A8_UNORM |
| 9744 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9745 | rpci.pAttachments = &attach_desc; |
| 9746 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 9747 | VkRenderPass rp; |
| 9748 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9749 | VkPipelineObj pipe(m_device); |
| 9750 | pipe.AddShader(&vs); |
| 9751 | pipe.AddShader(&fs); |
| 9752 | pipe.AddColorAttachment(); |
| 9753 | VkViewport view_port = {}; |
| 9754 | m_viewports.push_back(view_port); |
| 9755 | pipe.SetViewport(m_viewports); |
| 9756 | VkRect2D rect = {}; |
| 9757 | m_scissors.push_back(rect); |
| 9758 | pipe.SetScissor(m_scissors); |
| 9759 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9760 | |
| 9761 | VkCommandBufferInheritanceInfo cbii = {}; |
| 9762 | cbii.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 9763 | cbii.renderPass = rp; |
| 9764 | cbii.subpass = 0; |
| 9765 | VkCommandBufferBeginInfo cbbi = {}; |
| 9766 | cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 9767 | cbbi.pInheritanceInfo = &cbii; |
| 9768 | vkBeginCommandBuffer(m_commandBuffer->handle(), &cbbi); |
| 9769 | VkRenderPassBeginInfo rpbi = {}; |
| 9770 | rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 9771 | rpbi.framebuffer = m_framebuffer; |
| 9772 | rpbi.renderPass = rp; |
| 9773 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rpbi, |
| 9774 | VK_SUBPASS_CONTENTS_INLINE); |
| 9775 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9776 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9777 | |
| 9778 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9779 | " is incompatible w/ gfx pipeline "); |
| 9780 | // Render triangle (the error should trigger on the attempt to draw). |
| 9781 | Draw(3, 1, 0, 0); |
| 9782 | |
| 9783 | // Finalize recording of the command buffer |
| 9784 | EndCommandBuffer(); |
| 9785 | |
| 9786 | m_errorMonitor->VerifyFound(); |
| 9787 | |
| 9788 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9789 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9790 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 9791 | } |
| 9792 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9793 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 9794 | // Create Pipeline where the number of blend attachments doesn't match the |
| 9795 | // number of color attachments. In this case, we don't add any color |
| 9796 | // blend attachments even though we have a color attachment. |
| 9797 | VkResult err; |
| 9798 | |
| 9799 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9800 | "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] | 9801 | |
| 9802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9803 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9804 | VkDescriptorPoolSize ds_type_count = {}; |
| 9805 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9806 | ds_type_count.descriptorCount = 1; |
| 9807 | |
| 9808 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 9809 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9810 | ds_pool_ci.pNext = NULL; |
| 9811 | ds_pool_ci.maxSets = 1; |
| 9812 | ds_pool_ci.poolSizeCount = 1; |
| 9813 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 9814 | |
| 9815 | VkDescriptorPool ds_pool; |
| 9816 | err = |
| 9817 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 9818 | ASSERT_VK_SUCCESS(err); |
| 9819 | |
| 9820 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9821 | dsl_binding.binding = 0; |
| 9822 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9823 | dsl_binding.descriptorCount = 1; |
| 9824 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9825 | dsl_binding.pImmutableSamplers = NULL; |
| 9826 | |
| 9827 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9828 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9829 | ds_layout_ci.pNext = NULL; |
| 9830 | ds_layout_ci.bindingCount = 1; |
| 9831 | ds_layout_ci.pBindings = &dsl_binding; |
| 9832 | |
| 9833 | VkDescriptorSetLayout ds_layout; |
| 9834 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9835 | &ds_layout); |
| 9836 | ASSERT_VK_SUCCESS(err); |
| 9837 | |
| 9838 | VkDescriptorSet descriptorSet; |
| 9839 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 9840 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 9841 | alloc_info.descriptorSetCount = 1; |
| 9842 | alloc_info.descriptorPool = ds_pool; |
| 9843 | alloc_info.pSetLayouts = &ds_layout; |
| 9844 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9845 | &descriptorSet); |
| 9846 | ASSERT_VK_SUCCESS(err); |
| 9847 | |
| 9848 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 9849 | pipe_ms_state_ci.sType = |
| 9850 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9851 | pipe_ms_state_ci.pNext = NULL; |
| 9852 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 9853 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9854 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9855 | pipe_ms_state_ci.pSampleMask = NULL; |
| 9856 | |
| 9857 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9858 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9859 | pipeline_layout_ci.pNext = NULL; |
| 9860 | pipeline_layout_ci.setLayoutCount = 1; |
| 9861 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9862 | |
| 9863 | VkPipelineLayout pipeline_layout; |
| 9864 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9865 | &pipeline_layout); |
| 9866 | ASSERT_VK_SUCCESS(err); |
| 9867 | |
| 9868 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9869 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9870 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9871 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9872 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9873 | // but add it to be able to run on more devices |
| 9874 | VkPipelineObj pipe(m_device); |
| 9875 | pipe.AddShader(&vs); |
| 9876 | pipe.AddShader(&fs); |
| 9877 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9878 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9879 | |
| 9880 | BeginCommandBuffer(); |
| 9881 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9882 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9883 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9884 | // Render triangle (the error should trigger on the attempt to draw). |
| 9885 | Draw(3, 1, 0, 0); |
| 9886 | |
| 9887 | // Finalize recording of the command buffer |
| 9888 | EndCommandBuffer(); |
| 9889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9890 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9891 | |
| 9892 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 9895 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9896 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 9897 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 9898 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " |
| 9899 | "structure passed to vkCmdClearAttachments"); |
| 9900 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9901 | "vkCmdClearAttachments() attachment index 1 not found in attachment " |
| 9902 | "reference array of active subpass 0"); |
| 9903 | |
| 9904 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); |
| 9905 | m_errorMonitor->VerifyFound(); |
| 9906 | } |
| 9907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9908 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 9909 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 9910 | // to issuing a Draw |
| 9911 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9913 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 9914 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9915 | "vkCmdClearAttachments() issued on CB object "); |
| 9916 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9919 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9920 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9921 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9922 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9923 | |
| 9924 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9925 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9926 | ds_pool_ci.pNext = NULL; |
| 9927 | ds_pool_ci.maxSets = 1; |
| 9928 | ds_pool_ci.poolSizeCount = 1; |
| 9929 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9930 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9931 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9932 | err = |
| 9933 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9934 | ASSERT_VK_SUCCESS(err); |
| 9935 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9936 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9937 | dsl_binding.binding = 0; |
| 9938 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9939 | dsl_binding.descriptorCount = 1; |
| 9940 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9941 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9942 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9943 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9944 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9945 | ds_layout_ci.pNext = NULL; |
| 9946 | ds_layout_ci.bindingCount = 1; |
| 9947 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9948 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9949 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9950 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9951 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9952 | ASSERT_VK_SUCCESS(err); |
| 9953 | |
| 9954 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9955 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9956 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9957 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9958 | alloc_info.descriptorPool = ds_pool; |
| 9959 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9960 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9961 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9962 | ASSERT_VK_SUCCESS(err); |
| 9963 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9964 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9965 | pipe_ms_state_ci.sType = |
| 9966 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9967 | pipe_ms_state_ci.pNext = NULL; |
| 9968 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9969 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9970 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9971 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9972 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9973 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9974 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9975 | pipeline_layout_ci.pNext = NULL; |
| 9976 | pipeline_layout_ci.setLayoutCount = 1; |
| 9977 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9978 | |
| 9979 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9980 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9981 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9982 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9983 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9984 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9985 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9986 | // 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] | 9987 | // on more devices |
| 9988 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9989 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9990 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9991 | VkPipelineObj pipe(m_device); |
| 9992 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9993 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9994 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9995 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9996 | |
| 9997 | BeginCommandBuffer(); |
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 | // Main thing we care about for this test is that the VkImage obj we're |
| 10000 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10001 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 10002 | VkClearAttachment color_attachment; |
| 10003 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10004 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 10005 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 10006 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 10007 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 10008 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10009 | VkClearRect clear_rect = { |
| 10010 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10012 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 10013 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10014 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10015 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10016 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10017 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 10018 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10019 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10020 | } |
| 10021 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10022 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 10023 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10024 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10025 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10026 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 10027 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10028 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 10030 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10031 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10032 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10033 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10034 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 10035 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10036 | |
| 10037 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10038 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10039 | ds_pool_ci.pNext = NULL; |
| 10040 | ds_pool_ci.maxSets = 1; |
| 10041 | ds_pool_ci.poolSizeCount = 1; |
| 10042 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10043 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10044 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10045 | err = |
| 10046 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10047 | ASSERT_VK_SUCCESS(err); |
| 10048 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10049 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10050 | dsl_binding.binding = 0; |
| 10051 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 10052 | dsl_binding.descriptorCount = 1; |
| 10053 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10054 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10055 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10056 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10057 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10058 | ds_layout_ci.pNext = NULL; |
| 10059 | ds_layout_ci.bindingCount = 1; |
| 10060 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10061 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10062 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10063 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10064 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10065 | ASSERT_VK_SUCCESS(err); |
| 10066 | |
| 10067 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10068 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10069 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10070 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10071 | alloc_info.descriptorPool = ds_pool; |
| 10072 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10073 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10074 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10075 | ASSERT_VK_SUCCESS(err); |
| 10076 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10077 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10078 | pipe_ms_state_ci.sType = |
| 10079 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 10080 | pipe_ms_state_ci.pNext = NULL; |
| 10081 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 10082 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 10083 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 10084 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10085 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10086 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10087 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 10088 | pipeline_layout_ci.pNext = NULL; |
| 10089 | pipeline_layout_ci.setLayoutCount = 1; |
| 10090 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 10091 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10092 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10093 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 10094 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10095 | ASSERT_VK_SUCCESS(err); |
| 10096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10097 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 10098 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10099 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 10100 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10101 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10102 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10103 | VkPipelineObj pipe(m_device); |
| 10104 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 10105 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10106 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10107 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 10108 | pipe.SetViewport(m_viewports); |
| 10109 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10110 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 10111 | |
| 10112 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10113 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 10114 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 10115 | // Don't care about actual data, just need to get to draw to flag error |
| 10116 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10117 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 10118 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 10119 | 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] | 10120 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10121 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10122 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10123 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10124 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 10125 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10126 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 10127 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10128 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 10129 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 10130 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 10131 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 10132 | "images in the wrong layout when they're copied or transitioned."); |
| 10133 | // 3 in ValidateCmdBufImageLayouts |
| 10134 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 10135 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 10136 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 10137 | m_errorMonitor->SetDesiredFailureMsg( |
| 10138 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10139 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 10140 | |
| 10141 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10142 | // Create src & dst images to use for copy operations |
| 10143 | VkImage src_image; |
| 10144 | VkImage dst_image; |
| 10145 | |
| 10146 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10147 | const int32_t tex_width = 32; |
| 10148 | const int32_t tex_height = 32; |
| 10149 | |
| 10150 | VkImageCreateInfo image_create_info = {}; |
| 10151 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10152 | image_create_info.pNext = NULL; |
| 10153 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10154 | image_create_info.format = tex_format; |
| 10155 | image_create_info.extent.width = tex_width; |
| 10156 | image_create_info.extent.height = tex_height; |
| 10157 | image_create_info.extent.depth = 1; |
| 10158 | image_create_info.mipLevels = 1; |
| 10159 | image_create_info.arrayLayers = 4; |
| 10160 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10161 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10162 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10163 | image_create_info.flags = 0; |
| 10164 | |
| 10165 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 10166 | ASSERT_VK_SUCCESS(err); |
| 10167 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 10168 | ASSERT_VK_SUCCESS(err); |
| 10169 | |
| 10170 | BeginCommandBuffer(); |
| 10171 | VkImageCopy copyRegion; |
| 10172 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10173 | copyRegion.srcSubresource.mipLevel = 0; |
| 10174 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10175 | copyRegion.srcSubresource.layerCount = 1; |
| 10176 | copyRegion.srcOffset.x = 0; |
| 10177 | copyRegion.srcOffset.y = 0; |
| 10178 | copyRegion.srcOffset.z = 0; |
| 10179 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10180 | copyRegion.dstSubresource.mipLevel = 0; |
| 10181 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10182 | copyRegion.dstSubresource.layerCount = 1; |
| 10183 | copyRegion.dstOffset.x = 0; |
| 10184 | copyRegion.dstOffset.y = 0; |
| 10185 | copyRegion.dstOffset.z = 0; |
| 10186 | copyRegion.extent.width = 1; |
| 10187 | copyRegion.extent.height = 1; |
| 10188 | copyRegion.extent.depth = 1; |
| 10189 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10190 | m_errorMonitor->VerifyFound(); |
| 10191 | // Now cause error due to src image layout changing |
| 10192 | m_errorMonitor->SetDesiredFailureMsg( |
| 10193 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10194 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 10195 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10196 | m_errorMonitor->VerifyFound(); |
| 10197 | // Final src error is due to bad layout type |
| 10198 | m_errorMonitor->SetDesiredFailureMsg( |
| 10199 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10200 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 10201 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10202 | m_errorMonitor->VerifyFound(); |
| 10203 | // Now verify same checks for dst |
| 10204 | m_errorMonitor->SetDesiredFailureMsg( |
| 10205 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10206 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 10207 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10208 | m_errorMonitor->VerifyFound(); |
| 10209 | // Now cause error due to src image layout changing |
| 10210 | m_errorMonitor->SetDesiredFailureMsg( |
| 10211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10212 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 10213 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 10214 | m_errorMonitor->VerifyFound(); |
| 10215 | m_errorMonitor->SetDesiredFailureMsg( |
| 10216 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10217 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 10218 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 10219 | m_errorMonitor->VerifyFound(); |
| 10220 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 10221 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 10222 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10223 | image_barrier[0].image = src_image; |
| 10224 | image_barrier[0].subresourceRange.layerCount = 2; |
| 10225 | image_barrier[0].subresourceRange.levelCount = 2; |
| 10226 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10227 | m_errorMonitor->SetDesiredFailureMsg( |
| 10228 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10229 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 10230 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 10231 | m_errorMonitor->VerifyFound(); |
| 10232 | |
| 10233 | // Finally some layout errors at RenderPass create time |
| 10234 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 10235 | VkAttachmentReference attach = {}; |
| 10236 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 10237 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10238 | VkSubpassDescription subpass = {}; |
| 10239 | subpass.inputAttachmentCount = 1; |
| 10240 | subpass.pInputAttachments = &attach; |
| 10241 | VkRenderPassCreateInfo rpci = {}; |
| 10242 | rpci.subpassCount = 1; |
| 10243 | rpci.pSubpasses = &subpass; |
| 10244 | rpci.attachmentCount = 1; |
| 10245 | VkAttachmentDescription attach_desc = {}; |
| 10246 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 10247 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 10248 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10249 | VkRenderPass rp; |
| 10250 | m_errorMonitor->SetDesiredFailureMsg( |
| 10251 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10252 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 10253 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10254 | m_errorMonitor->VerifyFound(); |
| 10255 | // error w/ non-general layout |
| 10256 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10257 | |
| 10258 | m_errorMonitor->SetDesiredFailureMsg( |
| 10259 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10260 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 10261 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10262 | m_errorMonitor->VerifyFound(); |
| 10263 | subpass.inputAttachmentCount = 0; |
| 10264 | subpass.colorAttachmentCount = 1; |
| 10265 | subpass.pColorAttachments = &attach; |
| 10266 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10267 | // perf warning for GENERAL layout on color attachment |
| 10268 | m_errorMonitor->SetDesiredFailureMsg( |
| 10269 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10270 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 10271 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10272 | m_errorMonitor->VerifyFound(); |
| 10273 | // error w/ non-color opt or GENERAL layout for color attachment |
| 10274 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10275 | m_errorMonitor->SetDesiredFailureMsg( |
| 10276 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10277 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 10278 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10279 | m_errorMonitor->VerifyFound(); |
| 10280 | subpass.colorAttachmentCount = 0; |
| 10281 | subpass.pDepthStencilAttachment = &attach; |
| 10282 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10283 | // perf warning for GENERAL layout on DS attachment |
| 10284 | m_errorMonitor->SetDesiredFailureMsg( |
| 10285 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 10286 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 10287 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10288 | m_errorMonitor->VerifyFound(); |
| 10289 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 10290 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10291 | m_errorMonitor->SetDesiredFailureMsg( |
| 10292 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10293 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 10294 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10295 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 10296 | // For this error we need a valid renderpass so create default one |
| 10297 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10298 | attach.attachment = 0; |
| 10299 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10300 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10301 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 10302 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 10303 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 10304 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 10305 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 10306 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 10307 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10308 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10309 | " with invalid first layout " |
| 10310 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 10311 | "ONLY_OPTIMAL"); |
| 10312 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 10313 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 10314 | |
| 10315 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 10316 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 10317 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10318 | #endif // DRAW_STATE_TESTS |
| 10319 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 10320 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10321 | #if GTEST_IS_THREADSAFE |
| 10322 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10323 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10324 | VkEvent event; |
| 10325 | bool bailout; |
| 10326 | }; |
| 10327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10328 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 10329 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
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 | for (int i = 0; i < 10000; i++) { |
| 10332 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 10333 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10334 | if (data->bailout) { |
| 10335 | break; |
| 10336 | } |
| 10337 | } |
| 10338 | return NULL; |
| 10339 | } |
| 10340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10341 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10342 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10344 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10345 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10346 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10348 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 10349 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10350 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10351 | // Calls AllocateCommandBuffers |
| 10352 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 10353 | |
| 10354 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10355 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10356 | |
| 10357 | VkEventCreateInfo event_info; |
| 10358 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10359 | VkResult err; |
| 10360 | |
| 10361 | memset(&event_info, 0, sizeof(event_info)); |
| 10362 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 10363 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10364 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10365 | ASSERT_VK_SUCCESS(err); |
| 10366 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10367 | err = vkResetEvent(device(), event); |
| 10368 | ASSERT_VK_SUCCESS(err); |
| 10369 | |
| 10370 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10371 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10372 | data.event = event; |
| 10373 | data.bailout = false; |
| 10374 | m_errorMonitor->SetBailout(&data.bailout); |
| 10375 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10376 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10377 | // Add many entries to command buffer from this thread at the same time. |
| 10378 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 10379 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 10380 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10381 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10382 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 10383 | m_errorMonitor->SetBailout(NULL); |
| 10384 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10385 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10386 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10387 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 10388 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10389 | #endif // GTEST_IS_THREADSAFE |
| 10390 | #endif // THREADING_TESTS |
| 10391 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10392 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10393 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10394 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10395 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10396 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10397 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10398 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10399 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10400 | VkShaderModule module; |
| 10401 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10402 | struct icd_spv_header spv; |
| 10403 | |
| 10404 | spv.magic = ICD_SPV_MAGIC; |
| 10405 | spv.version = ICD_SPV_VERSION; |
| 10406 | spv.gen_magic = 0; |
| 10407 | |
| 10408 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10409 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10410 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10411 | moduleCreateInfo.codeSize = 4; |
| 10412 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10413 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10414 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10415 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10416 | } |
| 10417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10418 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10419 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10420 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10421 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10422 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10423 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10424 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10425 | VkShaderModule module; |
| 10426 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10427 | struct icd_spv_header spv; |
| 10428 | |
| 10429 | spv.magic = ~ICD_SPV_MAGIC; |
| 10430 | spv.version = ICD_SPV_VERSION; |
| 10431 | spv.gen_magic = 0; |
| 10432 | |
| 10433 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10434 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10435 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10436 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 10437 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10438 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10439 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10440 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10441 | } |
| 10442 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10443 | #if 0 |
| 10444 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10445 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10446 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10447 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10448 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10449 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10451 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10452 | VkShaderModule module; |
| 10453 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 10454 | struct icd_spv_header spv; |
| 10455 | |
| 10456 | spv.magic = ICD_SPV_MAGIC; |
| 10457 | spv.version = ~ICD_SPV_VERSION; |
| 10458 | spv.gen_magic = 0; |
| 10459 | |
| 10460 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 10461 | moduleCreateInfo.pNext = NULL; |
| 10462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10463 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10464 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 10465 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10466 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10467 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10468 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10469 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 10470 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 10471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10472 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10473 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10474 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10475 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10477 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10478 | |
| 10479 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10480 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10481 | "\n" |
| 10482 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10483 | "out gl_PerVertex {\n" |
| 10484 | " vec4 gl_Position;\n" |
| 10485 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10486 | "void main(){\n" |
| 10487 | " gl_Position = vec4(1);\n" |
| 10488 | " x = 0;\n" |
| 10489 | "}\n"; |
| 10490 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10491 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10492 | "\n" |
| 10493 | "layout(location=0) out vec4 color;\n" |
| 10494 | "void main(){\n" |
| 10495 | " color = vec4(1);\n" |
| 10496 | "}\n"; |
| 10497 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10498 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10499 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10500 | |
| 10501 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10502 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10503 | pipe.AddShader(&vs); |
| 10504 | pipe.AddShader(&fs); |
| 10505 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10506 | VkDescriptorSetObj descriptorSet(m_device); |
| 10507 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10508 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10509 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10510 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10511 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10512 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10513 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 10514 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10515 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10516 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10517 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10518 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10519 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10520 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10521 | |
| 10522 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10523 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10524 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10525 | "out gl_PerVertex {\n" |
| 10526 | " vec4 gl_Position;\n" |
| 10527 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10528 | "void main(){\n" |
| 10529 | " gl_Position = vec4(1);\n" |
| 10530 | "}\n"; |
| 10531 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10532 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10533 | "\n" |
| 10534 | "layout(location=0) in float x;\n" |
| 10535 | "layout(location=0) out vec4 color;\n" |
| 10536 | "void main(){\n" |
| 10537 | " color = vec4(x);\n" |
| 10538 | "}\n"; |
| 10539 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10540 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10541 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10542 | |
| 10543 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10544 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10545 | pipe.AddShader(&vs); |
| 10546 | pipe.AddShader(&fs); |
| 10547 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10548 | VkDescriptorSetObj descriptorSet(m_device); |
| 10549 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10550 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10551 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10552 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10553 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10554 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 10555 | } |
| 10556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10557 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10558 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10559 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10560 | |
| 10561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10562 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10563 | |
| 10564 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10565 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10566 | "\n" |
| 10567 | "out gl_PerVertex {\n" |
| 10568 | " vec4 gl_Position;\n" |
| 10569 | "};\n" |
| 10570 | "void main(){\n" |
| 10571 | " gl_Position = vec4(1);\n" |
| 10572 | "}\n"; |
| 10573 | char const *fsSource = |
| 10574 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10575 | "\n" |
| 10576 | "in block { layout(location=0) float x; } ins;\n" |
| 10577 | "layout(location=0) out vec4 color;\n" |
| 10578 | "void main(){\n" |
| 10579 | " color = vec4(ins.x);\n" |
| 10580 | "}\n"; |
| 10581 | |
| 10582 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10583 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10584 | |
| 10585 | VkPipelineObj pipe(m_device); |
| 10586 | pipe.AddColorAttachment(); |
| 10587 | pipe.AddShader(&vs); |
| 10588 | pipe.AddShader(&fs); |
| 10589 | |
| 10590 | VkDescriptorSetObj descriptorSet(m_device); |
| 10591 | descriptorSet.AppendDummy(); |
| 10592 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10593 | |
| 10594 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10595 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10596 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10597 | } |
| 10598 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10599 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10600 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10601 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10602 | "output arr[2] of float32' vs 'ptr to " |
| 10603 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10604 | |
| 10605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10606 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10607 | |
| 10608 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10609 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10610 | "\n" |
| 10611 | "layout(location=0) out float x[2];\n" |
| 10612 | "out gl_PerVertex {\n" |
| 10613 | " vec4 gl_Position;\n" |
| 10614 | "};\n" |
| 10615 | "void main(){\n" |
| 10616 | " x[0] = 0; x[1] = 0;\n" |
| 10617 | " gl_Position = vec4(1);\n" |
| 10618 | "}\n"; |
| 10619 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10620 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10621 | "\n" |
| 10622 | "layout(location=0) in float x[3];\n" |
| 10623 | "layout(location=0) out vec4 color;\n" |
| 10624 | "void main(){\n" |
| 10625 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 10626 | "}\n"; |
| 10627 | |
| 10628 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10629 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10630 | |
| 10631 | VkPipelineObj pipe(m_device); |
| 10632 | pipe.AddColorAttachment(); |
| 10633 | pipe.AddShader(&vs); |
| 10634 | pipe.AddShader(&fs); |
| 10635 | |
| 10636 | VkDescriptorSetObj descriptorSet(m_device); |
| 10637 | descriptorSet.AppendDummy(); |
| 10638 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10639 | |
| 10640 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10641 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10642 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10643 | } |
| 10644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10645 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10646 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10647 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10648 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10649 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10650 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10651 | |
| 10652 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10653 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10654 | "\n" |
| 10655 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10656 | "out gl_PerVertex {\n" |
| 10657 | " vec4 gl_Position;\n" |
| 10658 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10659 | "void main(){\n" |
| 10660 | " x = 0;\n" |
| 10661 | " gl_Position = vec4(1);\n" |
| 10662 | "}\n"; |
| 10663 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10664 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10665 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10666 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10667 | "layout(location=0) out vec4 color;\n" |
| 10668 | "void main(){\n" |
| 10669 | " color = vec4(x);\n" |
| 10670 | "}\n"; |
| 10671 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10672 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10673 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10674 | |
| 10675 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10676 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10677 | pipe.AddShader(&vs); |
| 10678 | pipe.AddShader(&fs); |
| 10679 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10680 | VkDescriptorSetObj descriptorSet(m_device); |
| 10681 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10682 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10683 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10684 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10685 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10686 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10687 | } |
| 10688 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10689 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10690 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10691 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10692 | |
| 10693 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10694 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10695 | |
| 10696 | char const *vsSource = |
| 10697 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10698 | "\n" |
| 10699 | "out block { layout(location=0) int x; } outs;\n" |
| 10700 | "out gl_PerVertex {\n" |
| 10701 | " vec4 gl_Position;\n" |
| 10702 | "};\n" |
| 10703 | "void main(){\n" |
| 10704 | " outs.x = 0;\n" |
| 10705 | " gl_Position = vec4(1);\n" |
| 10706 | "}\n"; |
| 10707 | char const *fsSource = |
| 10708 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10709 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10710 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10711 | "layout(location=0) out vec4 color;\n" |
| 10712 | "void main(){\n" |
| 10713 | " color = vec4(ins.x);\n" |
| 10714 | "}\n"; |
| 10715 | |
| 10716 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10717 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10718 | |
| 10719 | VkPipelineObj pipe(m_device); |
| 10720 | pipe.AddColorAttachment(); |
| 10721 | pipe.AddShader(&vs); |
| 10722 | pipe.AddShader(&fs); |
| 10723 | |
| 10724 | VkDescriptorSetObj descriptorSet(m_device); |
| 10725 | descriptorSet.AppendDummy(); |
| 10726 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10727 | |
| 10728 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10729 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10730 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10731 | } |
| 10732 | |
| 10733 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 10734 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10735 | "location 0.0 which is not written by vertex shader"); |
| 10736 | |
| 10737 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10738 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10739 | |
| 10740 | char const *vsSource = |
| 10741 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10742 | "\n" |
| 10743 | "out block { layout(location=1) float x; } outs;\n" |
| 10744 | "out gl_PerVertex {\n" |
| 10745 | " vec4 gl_Position;\n" |
| 10746 | "};\n" |
| 10747 | "void main(){\n" |
| 10748 | " outs.x = 0;\n" |
| 10749 | " gl_Position = vec4(1);\n" |
| 10750 | "}\n"; |
| 10751 | char const *fsSource = |
| 10752 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10753 | "\n" |
| 10754 | "in block { layout(location=0) float x; } ins;\n" |
| 10755 | "layout(location=0) out vec4 color;\n" |
| 10756 | "void main(){\n" |
| 10757 | " color = vec4(ins.x);\n" |
| 10758 | "}\n"; |
| 10759 | |
| 10760 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10761 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10762 | |
| 10763 | VkPipelineObj pipe(m_device); |
| 10764 | pipe.AddColorAttachment(); |
| 10765 | pipe.AddShader(&vs); |
| 10766 | pipe.AddShader(&fs); |
| 10767 | |
| 10768 | VkDescriptorSetObj descriptorSet(m_device); |
| 10769 | descriptorSet.AppendDummy(); |
| 10770 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10771 | |
| 10772 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10773 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10774 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10775 | } |
| 10776 | |
| 10777 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 10778 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10779 | "location 0.1 which is not written by vertex shader"); |
| 10780 | |
| 10781 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10782 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10783 | |
| 10784 | char const *vsSource = |
| 10785 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10786 | "\n" |
| 10787 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 10788 | "out gl_PerVertex {\n" |
| 10789 | " vec4 gl_Position;\n" |
| 10790 | "};\n" |
| 10791 | "void main(){\n" |
| 10792 | " outs.x = 0;\n" |
| 10793 | " gl_Position = vec4(1);\n" |
| 10794 | "}\n"; |
| 10795 | char const *fsSource = |
| 10796 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10797 | "\n" |
| 10798 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 10799 | "layout(location=0) out vec4 color;\n" |
| 10800 | "void main(){\n" |
| 10801 | " color = vec4(ins.x);\n" |
| 10802 | "}\n"; |
| 10803 | |
| 10804 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10805 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10806 | |
| 10807 | VkPipelineObj pipe(m_device); |
| 10808 | pipe.AddColorAttachment(); |
| 10809 | pipe.AddShader(&vs); |
| 10810 | pipe.AddShader(&fs); |
| 10811 | |
| 10812 | VkDescriptorSetObj descriptorSet(m_device); |
| 10813 | descriptorSet.AppendDummy(); |
| 10814 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10815 | |
| 10816 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10817 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10818 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10819 | } |
| 10820 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10821 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10822 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10823 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10824 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10825 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10826 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10827 | |
| 10828 | VkVertexInputBindingDescription input_binding; |
| 10829 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10830 | |
| 10831 | VkVertexInputAttributeDescription input_attrib; |
| 10832 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10833 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10834 | |
| 10835 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10836 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10837 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10838 | "out gl_PerVertex {\n" |
| 10839 | " vec4 gl_Position;\n" |
| 10840 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10841 | "void main(){\n" |
| 10842 | " gl_Position = vec4(1);\n" |
| 10843 | "}\n"; |
| 10844 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10845 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10846 | "\n" |
| 10847 | "layout(location=0) out vec4 color;\n" |
| 10848 | "void main(){\n" |
| 10849 | " color = vec4(1);\n" |
| 10850 | "}\n"; |
| 10851 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10852 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10853 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10854 | |
| 10855 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10856 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10857 | pipe.AddShader(&vs); |
| 10858 | pipe.AddShader(&fs); |
| 10859 | |
| 10860 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10861 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10862 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10863 | VkDescriptorSetObj descriptorSet(m_device); |
| 10864 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10865 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10866 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10867 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10868 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10869 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10870 | } |
| 10871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10872 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10874 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10875 | |
| 10876 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10877 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10878 | |
| 10879 | VkVertexInputBindingDescription input_binding; |
| 10880 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10881 | |
| 10882 | VkVertexInputAttributeDescription input_attrib; |
| 10883 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10884 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10885 | |
| 10886 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10887 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10888 | "\n" |
| 10889 | "layout(location=1) in float x;\n" |
| 10890 | "out gl_PerVertex {\n" |
| 10891 | " vec4 gl_Position;\n" |
| 10892 | "};\n" |
| 10893 | "void main(){\n" |
| 10894 | " gl_Position = vec4(x);\n" |
| 10895 | "}\n"; |
| 10896 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10897 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10898 | "\n" |
| 10899 | "layout(location=0) out vec4 color;\n" |
| 10900 | "void main(){\n" |
| 10901 | " color = vec4(1);\n" |
| 10902 | "}\n"; |
| 10903 | |
| 10904 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10905 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10906 | |
| 10907 | VkPipelineObj pipe(m_device); |
| 10908 | pipe.AddColorAttachment(); |
| 10909 | pipe.AddShader(&vs); |
| 10910 | pipe.AddShader(&fs); |
| 10911 | |
| 10912 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10913 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10914 | |
| 10915 | VkDescriptorSetObj descriptorSet(m_device); |
| 10916 | descriptorSet.AppendDummy(); |
| 10917 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10918 | |
| 10919 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10920 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10921 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10922 | } |
| 10923 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10924 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 10925 | m_errorMonitor->SetDesiredFailureMsg( |
| 10926 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10927 | "VS consumes input at location 0 but not provided"); |
| 10928 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10930 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10931 | |
| 10932 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10933 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10934 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10935 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10936 | "out gl_PerVertex {\n" |
| 10937 | " vec4 gl_Position;\n" |
| 10938 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10939 | "void main(){\n" |
| 10940 | " gl_Position = x;\n" |
| 10941 | "}\n"; |
| 10942 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10943 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10944 | "\n" |
| 10945 | "layout(location=0) out vec4 color;\n" |
| 10946 | "void main(){\n" |
| 10947 | " color = vec4(1);\n" |
| 10948 | "}\n"; |
| 10949 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10950 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10951 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10952 | |
| 10953 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10954 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10955 | pipe.AddShader(&vs); |
| 10956 | pipe.AddShader(&fs); |
| 10957 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10958 | VkDescriptorSetObj descriptorSet(m_device); |
| 10959 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10960 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10961 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10962 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10964 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10965 | } |
| 10966 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10967 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 10968 | m_errorMonitor->SetDesiredFailureMsg( |
| 10969 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10970 | "location 0 does not match VS input type"); |
| 10971 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10972 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10974 | |
| 10975 | VkVertexInputBindingDescription input_binding; |
| 10976 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10977 | |
| 10978 | VkVertexInputAttributeDescription input_attrib; |
| 10979 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10980 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10981 | |
| 10982 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10983 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10984 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10985 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10986 | "out gl_PerVertex {\n" |
| 10987 | " vec4 gl_Position;\n" |
| 10988 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10989 | "void main(){\n" |
| 10990 | " gl_Position = vec4(x);\n" |
| 10991 | "}\n"; |
| 10992 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10993 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10994 | "\n" |
| 10995 | "layout(location=0) out vec4 color;\n" |
| 10996 | "void main(){\n" |
| 10997 | " color = vec4(1);\n" |
| 10998 | "}\n"; |
| 10999 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11000 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11001 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11002 | |
| 11003 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11004 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11005 | pipe.AddShader(&vs); |
| 11006 | pipe.AddShader(&fs); |
| 11007 | |
| 11008 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 11009 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 11010 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11011 | VkDescriptorSetObj descriptorSet(m_device); |
| 11012 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11013 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11014 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11015 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11016 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11017 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 11018 | } |
| 11019 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 11020 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 11021 | m_errorMonitor->SetDesiredFailureMsg( |
| 11022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11023 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 11024 | |
| 11025 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11026 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11027 | |
| 11028 | char const *vsSource = |
| 11029 | "#version 450\n" |
| 11030 | "\n" |
| 11031 | "out gl_PerVertex {\n" |
| 11032 | " vec4 gl_Position;\n" |
| 11033 | "};\n" |
| 11034 | "void main(){\n" |
| 11035 | " gl_Position = vec4(1);\n" |
| 11036 | "}\n"; |
| 11037 | char const *fsSource = |
| 11038 | "#version 450\n" |
| 11039 | "\n" |
| 11040 | "layout(location=0) out vec4 color;\n" |
| 11041 | "void main(){\n" |
| 11042 | " color = vec4(1);\n" |
| 11043 | "}\n"; |
| 11044 | |
| 11045 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11046 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11047 | |
| 11048 | VkPipelineObj pipe(m_device); |
| 11049 | pipe.AddColorAttachment(); |
| 11050 | pipe.AddShader(&vs); |
| 11051 | pipe.AddShader(&vs); |
| 11052 | pipe.AddShader(&fs); |
| 11053 | |
| 11054 | VkDescriptorSetObj descriptorSet(m_device); |
| 11055 | descriptorSet.AppendDummy(); |
| 11056 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11057 | |
| 11058 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11059 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11060 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 11061 | } |
| 11062 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11063 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11064 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11065 | |
| 11066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11067 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11068 | |
| 11069 | VkVertexInputBindingDescription input_binding; |
| 11070 | memset(&input_binding, 0, sizeof(input_binding)); |
| 11071 | |
| 11072 | VkVertexInputAttributeDescription input_attribs[2]; |
| 11073 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11074 | |
| 11075 | for (int i = 0; i < 2; i++) { |
| 11076 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 11077 | input_attribs[i].location = i; |
| 11078 | } |
| 11079 | |
| 11080 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11081 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11082 | "\n" |
| 11083 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11084 | "out gl_PerVertex {\n" |
| 11085 | " vec4 gl_Position;\n" |
| 11086 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11087 | "void main(){\n" |
| 11088 | " gl_Position = x[0] + x[1];\n" |
| 11089 | "}\n"; |
| 11090 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11091 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11092 | "\n" |
| 11093 | "layout(location=0) out vec4 color;\n" |
| 11094 | "void main(){\n" |
| 11095 | " color = vec4(1);\n" |
| 11096 | "}\n"; |
| 11097 | |
| 11098 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11099 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11100 | |
| 11101 | VkPipelineObj pipe(m_device); |
| 11102 | pipe.AddColorAttachment(); |
| 11103 | pipe.AddShader(&vs); |
| 11104 | pipe.AddShader(&fs); |
| 11105 | |
| 11106 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 11107 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 11108 | |
| 11109 | VkDescriptorSetObj descriptorSet(m_device); |
| 11110 | descriptorSet.AppendDummy(); |
| 11111 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11112 | |
| 11113 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11114 | |
| 11115 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11116 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11117 | } |
| 11118 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11119 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 11120 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11121 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11122 | |
| 11123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11125 | |
| 11126 | VkVertexInputBindingDescription input_binding; |
| 11127 | memset(&input_binding, 0, sizeof(input_binding)); |
| 11128 | |
| 11129 | VkVertexInputAttributeDescription input_attribs[2]; |
| 11130 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11131 | |
| 11132 | for (int i = 0; i < 2; i++) { |
| 11133 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 11134 | input_attribs[i].location = i; |
| 11135 | } |
| 11136 | |
| 11137 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11138 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11139 | "\n" |
| 11140 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11141 | "out gl_PerVertex {\n" |
| 11142 | " vec4 gl_Position;\n" |
| 11143 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11144 | "void main(){\n" |
| 11145 | " gl_Position = x[0] + x[1];\n" |
| 11146 | "}\n"; |
| 11147 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11148 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11149 | "\n" |
| 11150 | "layout(location=0) out vec4 color;\n" |
| 11151 | "void main(){\n" |
| 11152 | " color = vec4(1);\n" |
| 11153 | "}\n"; |
| 11154 | |
| 11155 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11156 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11157 | |
| 11158 | VkPipelineObj pipe(m_device); |
| 11159 | pipe.AddColorAttachment(); |
| 11160 | pipe.AddShader(&vs); |
| 11161 | pipe.AddShader(&fs); |
| 11162 | |
| 11163 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 11164 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 11165 | |
| 11166 | VkDescriptorSetObj descriptorSet(m_device); |
| 11167 | descriptorSet.AppendDummy(); |
| 11168 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11169 | |
| 11170 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11171 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11172 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11173 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 11174 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11175 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 11176 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11177 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11178 | |
| 11179 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11180 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11181 | |
| 11182 | char const *vsSource = |
| 11183 | "#version 450\n" |
| 11184 | "out gl_PerVertex {\n" |
| 11185 | " vec4 gl_Position;\n" |
| 11186 | "};\n" |
| 11187 | "void main(){\n" |
| 11188 | " gl_Position = vec4(0);\n" |
| 11189 | "}\n"; |
| 11190 | char const *fsSource = |
| 11191 | "#version 450\n" |
| 11192 | "\n" |
| 11193 | "layout(location=0) out vec4 color;\n" |
| 11194 | "void main(){\n" |
| 11195 | " color = vec4(1);\n" |
| 11196 | "}\n"; |
| 11197 | |
| 11198 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11199 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11200 | |
| 11201 | VkPipelineObj pipe(m_device); |
| 11202 | pipe.AddColorAttachment(); |
| 11203 | pipe.AddShader(&vs); |
| 11204 | pipe.AddShader(&fs); |
| 11205 | |
| 11206 | VkDescriptorSetObj descriptorSet(m_device); |
| 11207 | descriptorSet.AppendDummy(); |
| 11208 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11209 | |
| 11210 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11211 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11212 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11213 | } |
| 11214 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11215 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 11216 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11217 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11218 | |
| 11219 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 11220 | |
| 11221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11222 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11223 | |
| 11224 | char const *vsSource = |
| 11225 | "#version 450\n" |
| 11226 | "out gl_PerVertex {\n" |
| 11227 | " vec4 gl_Position;\n" |
| 11228 | "};\n" |
| 11229 | "layout(location=0) out vec3 x;\n" |
| 11230 | "layout(location=1) out ivec3 y;\n" |
| 11231 | "layout(location=2) out vec3 z;\n" |
| 11232 | "void main(){\n" |
| 11233 | " gl_Position = vec4(0);\n" |
| 11234 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 11235 | "}\n"; |
| 11236 | char const *fsSource = |
| 11237 | "#version 450\n" |
| 11238 | "\n" |
| 11239 | "layout(location=0) out vec4 color;\n" |
| 11240 | "layout(location=0) in float x;\n" |
| 11241 | "layout(location=1) flat in int y;\n" |
| 11242 | "layout(location=2) in vec2 z;\n" |
| 11243 | "void main(){\n" |
| 11244 | " color = vec4(1 + x + y + z.x);\n" |
| 11245 | "}\n"; |
| 11246 | |
| 11247 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11248 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11249 | |
| 11250 | VkPipelineObj pipe(m_device); |
| 11251 | pipe.AddColorAttachment(); |
| 11252 | pipe.AddShader(&vs); |
| 11253 | pipe.AddShader(&fs); |
| 11254 | |
| 11255 | VkDescriptorSetObj descriptorSet(m_device); |
| 11256 | descriptorSet.AppendDummy(); |
| 11257 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11258 | |
Mike Stroyan | 255e958 | 2016-06-24 09:49:32 -0600 | [diff] [blame] | 11259 | VkResult err = VK_SUCCESS; |
| 11260 | err = |
| 11261 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11262 | ASSERT_VK_SUCCESS(err); |
| 11263 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11264 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11265 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 11266 | } |
| 11267 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11268 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 11269 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11270 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11271 | |
| 11272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11273 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11274 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 11275 | if (!m_device->phy().features().tessellationShader) { |
| 11276 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 11277 | return; |
| 11278 | } |
| 11279 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11280 | char const *vsSource = |
| 11281 | "#version 450\n" |
| 11282 | "void main(){}\n"; |
| 11283 | char const *tcsSource = |
| 11284 | "#version 450\n" |
| 11285 | "layout(location=0) out int x[];\n" |
| 11286 | "layout(vertices=3) out;\n" |
| 11287 | "void main(){\n" |
| 11288 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 11289 | " gl_TessLevelInner[0] = 1;\n" |
| 11290 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 11291 | "}\n"; |
| 11292 | char const *tesSource = |
| 11293 | "#version 450\n" |
| 11294 | "layout(triangles, equal_spacing, cw) in;\n" |
| 11295 | "layout(location=0) in int x[];\n" |
| 11296 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11297 | "void main(){\n" |
| 11298 | " gl_Position.xyz = gl_TessCoord;\n" |
| 11299 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 11300 | "}\n"; |
| 11301 | char const *fsSource = |
| 11302 | "#version 450\n" |
| 11303 | "layout(location=0) out vec4 color;\n" |
| 11304 | "void main(){\n" |
| 11305 | " color = vec4(1);\n" |
| 11306 | "}\n"; |
| 11307 | |
| 11308 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11309 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 11310 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 11311 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11312 | |
| 11313 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 11314 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 11315 | nullptr, |
| 11316 | 0, |
| 11317 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 11318 | VK_FALSE}; |
| 11319 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 11320 | VkPipelineTessellationStateCreateInfo tsci{ |
| 11321 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 11322 | nullptr, |
| 11323 | 0, |
| 11324 | 3}; |
| 11325 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11326 | VkPipelineObj pipe(m_device); |
| 11327 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 11328 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11329 | pipe.AddColorAttachment(); |
| 11330 | pipe.AddShader(&vs); |
| 11331 | pipe.AddShader(&tcs); |
| 11332 | pipe.AddShader(&tes); |
| 11333 | pipe.AddShader(&fs); |
| 11334 | |
| 11335 | VkDescriptorSetObj descriptorSet(m_device); |
| 11336 | descriptorSet.AppendDummy(); |
| 11337 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11338 | |
| 11339 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11340 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11341 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 11342 | } |
| 11343 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 11344 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 11345 | { |
| 11346 | m_errorMonitor->ExpectSuccess(); |
| 11347 | |
| 11348 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11349 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11350 | |
| 11351 | if (!m_device->phy().features().geometryShader) { |
| 11352 | printf("Device does not support geometry shaders; skipped.\n"); |
| 11353 | return; |
| 11354 | } |
| 11355 | |
| 11356 | char const *vsSource = |
| 11357 | "#version 450\n" |
| 11358 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 11359 | "void main(){\n" |
| 11360 | " vs_out.x = vec4(1);\n" |
| 11361 | "}\n"; |
| 11362 | char const *gsSource = |
| 11363 | "#version 450\n" |
| 11364 | "layout(triangles) in;\n" |
| 11365 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 11366 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 11367 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11368 | "void main() {\n" |
| 11369 | " gl_Position = gs_in[0].x;\n" |
| 11370 | " EmitVertex();\n" |
| 11371 | "}\n"; |
| 11372 | char const *fsSource = |
| 11373 | "#version 450\n" |
| 11374 | "layout(location=0) out vec4 color;\n" |
| 11375 | "void main(){\n" |
| 11376 | " color = vec4(1);\n" |
| 11377 | "}\n"; |
| 11378 | |
| 11379 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11380 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 11381 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11382 | |
| 11383 | VkPipelineObj pipe(m_device); |
| 11384 | pipe.AddColorAttachment(); |
| 11385 | pipe.AddShader(&vs); |
| 11386 | pipe.AddShader(&gs); |
| 11387 | pipe.AddShader(&fs); |
| 11388 | |
| 11389 | VkDescriptorSetObj descriptorSet(m_device); |
| 11390 | descriptorSet.AppendDummy(); |
| 11391 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11392 | |
| 11393 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11394 | |
| 11395 | m_errorMonitor->VerifyNotFound(); |
| 11396 | } |
| 11397 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11398 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 11399 | { |
| 11400 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11401 | "is per-vertex in tessellation control shader stage " |
| 11402 | "but per-patch in tessellation evaluation shader stage"); |
| 11403 | |
| 11404 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11405 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11406 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 11407 | if (!m_device->phy().features().tessellationShader) { |
| 11408 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 11409 | return; |
| 11410 | } |
| 11411 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11412 | char const *vsSource = |
| 11413 | "#version 450\n" |
| 11414 | "void main(){}\n"; |
| 11415 | char const *tcsSource = |
| 11416 | "#version 450\n" |
| 11417 | "layout(location=0) out int x[];\n" |
| 11418 | "layout(vertices=3) out;\n" |
| 11419 | "void main(){\n" |
| 11420 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 11421 | " gl_TessLevelInner[0] = 1;\n" |
| 11422 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 11423 | "}\n"; |
| 11424 | char const *tesSource = |
| 11425 | "#version 450\n" |
| 11426 | "layout(triangles, equal_spacing, cw) in;\n" |
| 11427 | "layout(location=0) patch in int x;\n" |
| 11428 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 11429 | "void main(){\n" |
| 11430 | " gl_Position.xyz = gl_TessCoord;\n" |
| 11431 | " gl_Position.w = x;\n" |
| 11432 | "}\n"; |
| 11433 | char const *fsSource = |
| 11434 | "#version 450\n" |
| 11435 | "layout(location=0) out vec4 color;\n" |
| 11436 | "void main(){\n" |
| 11437 | " color = vec4(1);\n" |
| 11438 | "}\n"; |
| 11439 | |
| 11440 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11441 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 11442 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 11443 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11444 | |
| 11445 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 11446 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 11447 | nullptr, |
| 11448 | 0, |
| 11449 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 11450 | VK_FALSE}; |
| 11451 | |
| 11452 | VkPipelineTessellationStateCreateInfo tsci{ |
| 11453 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 11454 | nullptr, |
| 11455 | 0, |
| 11456 | 3}; |
| 11457 | |
| 11458 | VkPipelineObj pipe(m_device); |
| 11459 | pipe.SetInputAssembly(&iasci); |
| 11460 | pipe.SetTessellation(&tsci); |
| 11461 | pipe.AddColorAttachment(); |
| 11462 | pipe.AddShader(&vs); |
| 11463 | pipe.AddShader(&tcs); |
| 11464 | pipe.AddShader(&tes); |
| 11465 | pipe.AddShader(&fs); |
| 11466 | |
| 11467 | VkDescriptorSetObj descriptorSet(m_device); |
| 11468 | descriptorSet.AppendDummy(); |
| 11469 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11470 | |
| 11471 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11473 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 11474 | } |
| 11475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11476 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 11477 | m_errorMonitor->SetDesiredFailureMsg( |
| 11478 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11479 | "Duplicate vertex input binding descriptions for binding 0"); |
| 11480 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11481 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 11482 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11483 | |
| 11484 | /* Two binding descriptions for binding 0 */ |
| 11485 | VkVertexInputBindingDescription input_bindings[2]; |
| 11486 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 11487 | |
| 11488 | VkVertexInputAttributeDescription input_attrib; |
| 11489 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 11490 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 11491 | |
| 11492 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11493 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11494 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11495 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11496 | "out gl_PerVertex {\n" |
| 11497 | " vec4 gl_Position;\n" |
| 11498 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11499 | "void main(){\n" |
| 11500 | " gl_Position = vec4(x);\n" |
| 11501 | "}\n"; |
| 11502 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11503 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11504 | "\n" |
| 11505 | "layout(location=0) out vec4 color;\n" |
| 11506 | "void main(){\n" |
| 11507 | " color = vec4(1);\n" |
| 11508 | "}\n"; |
| 11509 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11510 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11511 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11512 | |
| 11513 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11514 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11515 | pipe.AddShader(&vs); |
| 11516 | pipe.AddShader(&fs); |
| 11517 | |
| 11518 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 11519 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 11520 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11521 | VkDescriptorSetObj descriptorSet(m_device); |
| 11522 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11523 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11524 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11525 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11526 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11527 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 11528 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 11529 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 11530 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 11531 | m_errorMonitor->ExpectSuccess(); |
| 11532 | |
| 11533 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11534 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11535 | |
Chris Forbes | 91cf3a8 | 2016-06-28 17:51:35 +1200 | [diff] [blame] | 11536 | if (!m_device->phy().features().shaderFloat64) { |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 11537 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 11538 | return; |
| 11539 | } |
| 11540 | |
| 11541 | VkVertexInputBindingDescription input_bindings[1]; |
| 11542 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 11543 | |
| 11544 | VkVertexInputAttributeDescription input_attribs[4]; |
| 11545 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 11546 | input_attribs[0].location = 0; |
| 11547 | input_attribs[0].offset = 0; |
| 11548 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11549 | input_attribs[1].location = 2; |
| 11550 | input_attribs[1].offset = 32; |
| 11551 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11552 | input_attribs[2].location = 4; |
| 11553 | input_attribs[2].offset = 64; |
| 11554 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11555 | input_attribs[3].location = 6; |
| 11556 | input_attribs[3].offset = 96; |
| 11557 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 11558 | |
| 11559 | char const *vsSource = |
| 11560 | "#version 450\n" |
| 11561 | "\n" |
| 11562 | "layout(location=0) in dmat4 x;\n" |
| 11563 | "out gl_PerVertex {\n" |
| 11564 | " vec4 gl_Position;\n" |
| 11565 | "};\n" |
| 11566 | "void main(){\n" |
| 11567 | " gl_Position = vec4(x[0][0]);\n" |
| 11568 | "}\n"; |
| 11569 | char const *fsSource = |
| 11570 | "#version 450\n" |
| 11571 | "\n" |
| 11572 | "layout(location=0) out vec4 color;\n" |
| 11573 | "void main(){\n" |
| 11574 | " color = vec4(1);\n" |
| 11575 | "}\n"; |
| 11576 | |
| 11577 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11578 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11579 | |
| 11580 | VkPipelineObj pipe(m_device); |
| 11581 | pipe.AddColorAttachment(); |
| 11582 | pipe.AddShader(&vs); |
| 11583 | pipe.AddShader(&fs); |
| 11584 | |
| 11585 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 11586 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 11587 | |
| 11588 | VkDescriptorSetObj descriptorSet(m_device); |
| 11589 | descriptorSet.AppendDummy(); |
| 11590 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11591 | |
| 11592 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11593 | |
| 11594 | m_errorMonitor->VerifyNotFound(); |
| 11595 | } |
| 11596 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11597 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11598 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11599 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11600 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11601 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11602 | |
| 11603 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11604 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11605 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11606 | "out gl_PerVertex {\n" |
| 11607 | " vec4 gl_Position;\n" |
| 11608 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11609 | "void main(){\n" |
| 11610 | " gl_Position = vec4(1);\n" |
| 11611 | "}\n"; |
| 11612 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11613 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11614 | "\n" |
| 11615 | "void main(){\n" |
| 11616 | "}\n"; |
| 11617 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11618 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11619 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11620 | |
| 11621 | VkPipelineObj pipe(m_device); |
| 11622 | pipe.AddShader(&vs); |
| 11623 | pipe.AddShader(&fs); |
| 11624 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11625 | /* set up CB 0, not written */ |
| 11626 | pipe.AddColorAttachment(); |
| 11627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11628 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11629 | VkDescriptorSetObj descriptorSet(m_device); |
| 11630 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11631 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11632 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11633 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11634 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11635 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11636 | } |
| 11637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11638 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11639 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11640 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11641 | "FS writes to output location 1 with no matching attachment"); |
| 11642 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11643 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11644 | |
| 11645 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11646 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11647 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11648 | "out gl_PerVertex {\n" |
| 11649 | " vec4 gl_Position;\n" |
| 11650 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11651 | "void main(){\n" |
| 11652 | " gl_Position = vec4(1);\n" |
| 11653 | "}\n"; |
| 11654 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11655 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11656 | "\n" |
| 11657 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11658 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11659 | "void main(){\n" |
| 11660 | " x = vec4(1);\n" |
| 11661 | " y = vec4(1);\n" |
| 11662 | "}\n"; |
| 11663 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11664 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11665 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11666 | |
| 11667 | VkPipelineObj pipe(m_device); |
| 11668 | pipe.AddShader(&vs); |
| 11669 | pipe.AddShader(&fs); |
| 11670 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11671 | /* set up CB 0, not written */ |
| 11672 | pipe.AddColorAttachment(); |
| 11673 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11674 | /* FS writes CB 1, but we don't configure it */ |
| 11675 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11676 | VkDescriptorSetObj descriptorSet(m_device); |
| 11677 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11678 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11679 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11680 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11681 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11682 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11683 | } |
| 11684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11685 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11686 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11687 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11688 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11690 | |
| 11691 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11692 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11693 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11694 | "out gl_PerVertex {\n" |
| 11695 | " vec4 gl_Position;\n" |
| 11696 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11697 | "void main(){\n" |
| 11698 | " gl_Position = vec4(1);\n" |
| 11699 | "}\n"; |
| 11700 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11701 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11702 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11703 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11704 | "void main(){\n" |
| 11705 | " x = ivec4(1);\n" |
| 11706 | "}\n"; |
| 11707 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11708 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11709 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11710 | |
| 11711 | VkPipelineObj pipe(m_device); |
| 11712 | pipe.AddShader(&vs); |
| 11713 | pipe.AddShader(&fs); |
| 11714 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11715 | /* set up CB 0; type is UNORM by default */ |
| 11716 | pipe.AddColorAttachment(); |
| 11717 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11718 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11719 | VkDescriptorSetObj descriptorSet(m_device); |
| 11720 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11721 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11722 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11723 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11724 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11725 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11726 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 11727 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11728 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11730 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11731 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11733 | |
| 11734 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11735 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11736 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11737 | "out gl_PerVertex {\n" |
| 11738 | " vec4 gl_Position;\n" |
| 11739 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11740 | "void main(){\n" |
| 11741 | " gl_Position = vec4(1);\n" |
| 11742 | "}\n"; |
| 11743 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11744 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11745 | "\n" |
| 11746 | "layout(location=0) out vec4 x;\n" |
| 11747 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 11748 | "void main(){\n" |
| 11749 | " x = vec4(bar.y);\n" |
| 11750 | "}\n"; |
| 11751 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11752 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11753 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11754 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11755 | VkPipelineObj pipe(m_device); |
| 11756 | pipe.AddShader(&vs); |
| 11757 | pipe.AddShader(&fs); |
| 11758 | |
| 11759 | /* set up CB 0; type is UNORM by default */ |
| 11760 | pipe.AddColorAttachment(); |
| 11761 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11762 | |
| 11763 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11764 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11765 | |
| 11766 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11767 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11768 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11769 | } |
| 11770 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11771 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 11772 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11773 | "not declared in layout"); |
| 11774 | |
| 11775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11776 | |
| 11777 | char const *vsSource = |
| 11778 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11779 | "\n" |
| 11780 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 11781 | "out gl_PerVertex {\n" |
| 11782 | " vec4 gl_Position;\n" |
| 11783 | "};\n" |
| 11784 | "void main(){\n" |
| 11785 | " gl_Position = vec4(consts.x);\n" |
| 11786 | "}\n"; |
| 11787 | char const *fsSource = |
| 11788 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11789 | "\n" |
| 11790 | "layout(location=0) out vec4 x;\n" |
| 11791 | "void main(){\n" |
| 11792 | " x = vec4(1);\n" |
| 11793 | "}\n"; |
| 11794 | |
| 11795 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11796 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11797 | |
| 11798 | VkPipelineObj pipe(m_device); |
| 11799 | pipe.AddShader(&vs); |
| 11800 | pipe.AddShader(&fs); |
| 11801 | |
| 11802 | /* set up CB 0; type is UNORM by default */ |
| 11803 | pipe.AddColorAttachment(); |
| 11804 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11805 | |
| 11806 | VkDescriptorSetObj descriptorSet(m_device); |
| 11807 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11808 | |
| 11809 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11810 | |
| 11811 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11812 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11813 | } |
| 11814 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 11815 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 11816 | m_errorMonitor->SetDesiredFailureMsg( |
| 11817 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11818 | "Shader uses descriptor slot 0.0"); |
| 11819 | |
| 11820 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11821 | |
| 11822 | char const *csSource = |
| 11823 | "#version 450\n" |
| 11824 | "\n" |
| 11825 | "layout(local_size_x=1) in;\n" |
| 11826 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11827 | "void main(){\n" |
| 11828 | " x = vec4(1);\n" |
| 11829 | "}\n"; |
| 11830 | |
| 11831 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11832 | |
| 11833 | VkDescriptorSetObj descriptorSet(m_device); |
| 11834 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11835 | |
| 11836 | VkComputePipelineCreateInfo cpci = { |
| 11837 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11838 | nullptr, 0, { |
| 11839 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11840 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11841 | cs.handle(), "main", nullptr |
| 11842 | }, |
| 11843 | descriptorSet.GetPipelineLayout(), |
| 11844 | VK_NULL_HANDLE, -1 |
| 11845 | }; |
| 11846 | |
| 11847 | VkPipeline pipe; |
| 11848 | VkResult err = vkCreateComputePipelines( |
| 11849 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11850 | |
| 11851 | m_errorMonitor->VerifyFound(); |
| 11852 | |
| 11853 | if (err == VK_SUCCESS) { |
| 11854 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11855 | } |
| 11856 | } |
| 11857 | |
| 11858 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 11859 | m_errorMonitor->ExpectSuccess(); |
| 11860 | |
| 11861 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11862 | |
| 11863 | char const *csSource = |
| 11864 | "#version 450\n" |
| 11865 | "\n" |
| 11866 | "layout(local_size_x=1) in;\n" |
| 11867 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11868 | "void main(){\n" |
| 11869 | " // x is not used.\n" |
| 11870 | "}\n"; |
| 11871 | |
| 11872 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11873 | |
| 11874 | VkDescriptorSetObj descriptorSet(m_device); |
| 11875 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11876 | |
| 11877 | VkComputePipelineCreateInfo cpci = { |
| 11878 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11879 | nullptr, 0, { |
| 11880 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11881 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11882 | cs.handle(), "main", nullptr |
| 11883 | }, |
| 11884 | descriptorSet.GetPipelineLayout(), |
| 11885 | VK_NULL_HANDLE, -1 |
| 11886 | }; |
| 11887 | |
| 11888 | VkPipeline pipe; |
| 11889 | VkResult err = vkCreateComputePipelines( |
| 11890 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11891 | |
| 11892 | m_errorMonitor->VerifyNotFound(); |
| 11893 | |
| 11894 | if (err == VK_SUCCESS) { |
| 11895 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11896 | } |
| 11897 | } |
| 11898 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11899 | #endif // SHADER_CHECKER_TESTS |
| 11900 | |
| 11901 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11902 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11903 | m_errorMonitor->SetDesiredFailureMsg( |
| 11904 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11905 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11906 | |
| 11907 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11908 | |
| 11909 | // Create an image |
| 11910 | VkImage image; |
| 11911 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11912 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11913 | const int32_t tex_width = 32; |
| 11914 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11915 | |
| 11916 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11917 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11918 | image_create_info.pNext = NULL; |
| 11919 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11920 | image_create_info.format = tex_format; |
| 11921 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11922 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11923 | image_create_info.extent.depth = 1; |
| 11924 | image_create_info.mipLevels = 1; |
| 11925 | image_create_info.arrayLayers = 1; |
| 11926 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11927 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11928 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11929 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11930 | |
| 11931 | // Introduce error by sending down a bogus width extent |
| 11932 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11933 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11934 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11935 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11936 | } |
| 11937 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11938 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 11939 | m_errorMonitor->SetDesiredFailureMsg( |
| 11940 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11941 | "CreateImage extents is 0 for at least one required dimension"); |
| 11942 | |
| 11943 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11944 | |
| 11945 | // Create an image |
| 11946 | VkImage image; |
| 11947 | |
| 11948 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11949 | const int32_t tex_width = 32; |
| 11950 | const int32_t tex_height = 32; |
| 11951 | |
| 11952 | VkImageCreateInfo image_create_info = {}; |
| 11953 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11954 | image_create_info.pNext = NULL; |
| 11955 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11956 | image_create_info.format = tex_format; |
| 11957 | image_create_info.extent.width = tex_width; |
| 11958 | image_create_info.extent.height = tex_height; |
| 11959 | image_create_info.extent.depth = 1; |
| 11960 | image_create_info.mipLevels = 1; |
| 11961 | image_create_info.arrayLayers = 1; |
| 11962 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11963 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11964 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11965 | image_create_info.flags = 0; |
| 11966 | |
| 11967 | // Introduce error by sending down a bogus width extent |
| 11968 | image_create_info.extent.width = 0; |
| 11969 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 11970 | |
| 11971 | m_errorMonitor->VerifyFound(); |
| 11972 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11973 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11974 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11975 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11976 | TEST_F(VkLayerTest, InvalidImageView) { |
| 11977 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11978 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11979 | m_errorMonitor->SetDesiredFailureMsg( |
| 11980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11981 | "vkCreateImageView called with baseMipLevel 10 "); |
| 11982 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11984 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11985 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11986 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11987 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11988 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11989 | const int32_t tex_width = 32; |
| 11990 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11991 | |
| 11992 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11993 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11994 | image_create_info.pNext = NULL; |
| 11995 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11996 | image_create_info.format = tex_format; |
| 11997 | image_create_info.extent.width = tex_width; |
| 11998 | image_create_info.extent.height = tex_height; |
| 11999 | image_create_info.extent.depth = 1; |
| 12000 | image_create_info.mipLevels = 1; |
| 12001 | image_create_info.arrayLayers = 1; |
| 12002 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12003 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12004 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 12005 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12006 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12007 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12008 | ASSERT_VK_SUCCESS(err); |
| 12009 | |
| 12010 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12011 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12012 | image_view_create_info.image = image; |
| 12013 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12014 | image_view_create_info.format = tex_format; |
| 12015 | image_view_create_info.subresourceRange.layerCount = 1; |
| 12016 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 12017 | image_view_create_info.subresourceRange.levelCount = 1; |
| 12018 | image_view_create_info.subresourceRange.aspectMask = |
| 12019 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12020 | |
| 12021 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12022 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 12023 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12024 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12025 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 12026 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12027 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12029 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12030 | TEST_DESCRIPTION( |
| 12031 | "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] | 12032 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12033 | "vkCreateImageView: Color image " |
| 12034 | "formats must have ONLY the " |
| 12035 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12036 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12037 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12039 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12040 | VkImageObj image(m_device); |
| 12041 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 12042 | VK_IMAGE_TILING_LINEAR, 0); |
| 12043 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12044 | |
| 12045 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12046 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12047 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12048 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12049 | image_view_create_info.format = tex_format; |
| 12050 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 12051 | image_view_create_info.subresourceRange.levelCount = 1; |
| 12052 | // Cause an error by setting an invalid image aspect |
| 12053 | image_view_create_info.subresourceRange.aspectMask = |
| 12054 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12055 | |
| 12056 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 12057 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12058 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12059 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 12060 | } |
| 12061 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12062 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12063 | VkResult err; |
| 12064 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12065 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12066 | m_errorMonitor->SetDesiredFailureMsg( |
| 12067 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12068 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12069 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12071 | |
| 12072 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12073 | VkImage srcImage; |
| 12074 | VkImage dstImage; |
| 12075 | VkDeviceMemory srcMem; |
| 12076 | VkDeviceMemory destMem; |
| 12077 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12078 | |
| 12079 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12080 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12081 | image_create_info.pNext = NULL; |
| 12082 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12083 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12084 | image_create_info.extent.width = 32; |
| 12085 | image_create_info.extent.height = 32; |
| 12086 | image_create_info.extent.depth = 1; |
| 12087 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12088 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12089 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12090 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12091 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12092 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12094 | err = |
| 12095 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12096 | ASSERT_VK_SUCCESS(err); |
| 12097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12098 | err = |
| 12099 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12100 | ASSERT_VK_SUCCESS(err); |
| 12101 | |
| 12102 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12103 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12104 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12105 | memAlloc.pNext = NULL; |
| 12106 | memAlloc.allocationSize = 0; |
| 12107 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12108 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12109 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12110 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12111 | pass = |
| 12112 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12113 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12114 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12115 | ASSERT_VK_SUCCESS(err); |
| 12116 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12117 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12118 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12119 | pass = |
| 12120 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12121 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12122 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12123 | ASSERT_VK_SUCCESS(err); |
| 12124 | |
| 12125 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12126 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12127 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12128 | ASSERT_VK_SUCCESS(err); |
| 12129 | |
| 12130 | BeginCommandBuffer(); |
| 12131 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12132 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12133 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12134 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12135 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12136 | copyRegion.srcOffset.x = 0; |
| 12137 | copyRegion.srcOffset.y = 0; |
| 12138 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12139 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12140 | copyRegion.dstSubresource.mipLevel = 0; |
| 12141 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12142 | // Introduce failure by forcing the dst layerCount to differ from src |
| 12143 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12144 | copyRegion.dstOffset.x = 0; |
| 12145 | copyRegion.dstOffset.y = 0; |
| 12146 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12147 | copyRegion.extent.width = 1; |
| 12148 | copyRegion.extent.height = 1; |
| 12149 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12150 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12151 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12152 | EndCommandBuffer(); |
| 12153 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12154 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12155 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12156 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12157 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12158 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12159 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12160 | } |
| 12161 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12162 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 12163 | |
| 12164 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 12165 | |
| 12166 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12167 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 12168 | VkImageObj image(m_device); |
| 12169 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12170 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12171 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12172 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12173 | ASSERT_TRUE(image.initialized()); |
| 12174 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12175 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 12176 | VkImageCreateInfo image_create_info; |
| 12177 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12178 | image_create_info.pNext = NULL; |
| 12179 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12180 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 12181 | image_create_info.extent.width = 32; |
| 12182 | image_create_info.extent.height = 32; |
| 12183 | image_create_info.extent.depth = 1; |
| 12184 | image_create_info.mipLevels = 1; |
| 12185 | image_create_info.arrayLayers = 1; |
| 12186 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12187 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12188 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12189 | image_create_info.flags = 0; |
| 12190 | |
| 12191 | m_errorMonitor->SetDesiredFailureMsg( |
| 12192 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12193 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 12194 | |
| 12195 | VkImage localImage; |
| 12196 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 12197 | m_errorMonitor->VerifyFound(); |
| 12198 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12199 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12200 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12201 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 12202 | VkFormat format = static_cast<VkFormat>(f); |
| 12203 | VkFormatProperties fProps = m_device->format_properties(format); |
| 12204 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 12205 | fProps.optimalTilingFeatures == 0) { |
| 12206 | unsupported = format; |
| 12207 | break; |
| 12208 | } |
| 12209 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12210 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12211 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12212 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12213 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12214 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12215 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 12216 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 12217 | m_errorMonitor->VerifyFound(); |
| 12218 | } |
| 12219 | } |
| 12220 | |
| 12221 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 12222 | VkResult ret; |
| 12223 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 12224 | |
| 12225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12226 | |
| 12227 | VkImageObj image(m_device); |
| 12228 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12229 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12230 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12231 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12232 | ASSERT_TRUE(image.initialized()); |
| 12233 | |
| 12234 | VkImageView imgView; |
| 12235 | VkImageViewCreateInfo imgViewInfo = {}; |
| 12236 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 12237 | imgViewInfo.image = image.handle(); |
| 12238 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12239 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12240 | imgViewInfo.subresourceRange.layerCount = 1; |
| 12241 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 12242 | imgViewInfo.subresourceRange.levelCount = 1; |
| 12243 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12244 | |
| 12245 | m_errorMonitor->SetDesiredFailureMsg( |
| 12246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12247 | "vkCreateImageView called with baseMipLevel"); |
| 12248 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 12249 | // VIEW_CREATE_ERROR |
| 12250 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 12251 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12252 | m_errorMonitor->VerifyFound(); |
| 12253 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 12254 | |
| 12255 | m_errorMonitor->SetDesiredFailureMsg( |
| 12256 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12257 | "vkCreateImageView called with baseArrayLayer"); |
| 12258 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 12259 | // VIEW_CREATE_ERROR |
| 12260 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 12261 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12262 | m_errorMonitor->VerifyFound(); |
| 12263 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 12264 | |
| 12265 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12266 | "vkCreateImageView called with 0 in " |
| 12267 | "pCreateInfo->subresourceRange." |
| 12268 | "levelCount"); |
| 12269 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 12270 | imgViewInfo.subresourceRange.levelCount = 0; |
| 12271 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12272 | m_errorMonitor->VerifyFound(); |
| 12273 | imgViewInfo.subresourceRange.levelCount = 1; |
| 12274 | |
| 12275 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12276 | "vkCreateImageView called with 0 in " |
| 12277 | "pCreateInfo->subresourceRange." |
| 12278 | "layerCount"); |
| 12279 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 12280 | imgViewInfo.subresourceRange.layerCount = 0; |
| 12281 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12282 | m_errorMonitor->VerifyFound(); |
| 12283 | imgViewInfo.subresourceRange.layerCount = 1; |
| 12284 | |
| 12285 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12286 | "but both must be color formats"); |
| 12287 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 12288 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12289 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12290 | m_errorMonitor->VerifyFound(); |
| 12291 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12292 | |
| 12293 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12294 | "Formats MUST be IDENTICAL unless " |
| 12295 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 12296 | "was set on image creation."); |
| 12297 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 12298 | // VIEW_CREATE_ERROR |
| 12299 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 12300 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12301 | m_errorMonitor->VerifyFound(); |
| 12302 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12303 | |
| 12304 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12305 | "can support ImageViews with " |
| 12306 | "differing formats but they must be " |
| 12307 | "in the same compatibility class."); |
| 12308 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 12309 | // VIEW_CREATE_ERROR |
| 12310 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 12311 | VkImage mutImage; |
| 12312 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 12313 | assert( |
| 12314 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 12315 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 12316 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 12317 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12318 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 12319 | ASSERT_VK_SUCCESS(ret); |
| 12320 | imgViewInfo.image = mutImage; |
| 12321 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 12322 | m_errorMonitor->VerifyFound(); |
| 12323 | imgViewInfo.image = image.handle(); |
| 12324 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 12325 | } |
| 12326 | |
| 12327 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 12328 | |
| 12329 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 12330 | |
| 12331 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12332 | |
| 12333 | VkImageObj image(m_device); |
| 12334 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 12335 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 12336 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 12337 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 12338 | ASSERT_TRUE(image.initialized()); |
| 12339 | |
| 12340 | m_errorMonitor->SetDesiredFailureMsg( |
| 12341 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12342 | "number of layers in image subresource is zero"); |
| 12343 | vk_testing::Buffer buffer; |
| 12344 | VkMemoryPropertyFlags reqs = 0; |
| 12345 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 12346 | VkBufferImageCopy region = {}; |
| 12347 | region.bufferRowLength = 128; |
| 12348 | region.bufferImageHeight = 128; |
| 12349 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12350 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 12351 | region.imageSubresource.layerCount = 0; |
| 12352 | region.imageExtent.height = 4; |
| 12353 | region.imageExtent.width = 4; |
| 12354 | region.imageExtent.depth = 1; |
| 12355 | m_commandBuffer->BeginCommandBuffer(); |
| 12356 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 12357 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 12358 | 1, ®ion); |
| 12359 | m_errorMonitor->VerifyFound(); |
| 12360 | region.imageSubresource.layerCount = 1; |
| 12361 | |
| 12362 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12363 | "aspectMasks for each region must " |
| 12364 | "specify only COLOR or DEPTH or " |
| 12365 | "STENCIL"); |
| 12366 | // Expect MISMATCHED_IMAGE_ASPECT |
| 12367 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 12368 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 12369 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 12370 | 1, ®ion); |
| 12371 | m_errorMonitor->VerifyFound(); |
| 12372 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12373 | |
| 12374 | m_errorMonitor->SetDesiredFailureMsg( |
| 12375 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12376 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 12377 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 12378 | // Expect INVALID_FILTER |
| 12379 | VkImageObj intImage1(m_device); |
| 12380 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 12381 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 12382 | 0); |
| 12383 | VkImageObj intImage2(m_device); |
| 12384 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 12385 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 12386 | 0); |
| 12387 | VkImageBlit blitRegion = {}; |
| 12388 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12389 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 12390 | blitRegion.srcSubresource.layerCount = 1; |
| 12391 | blitRegion.srcSubresource.mipLevel = 0; |
| 12392 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12393 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 12394 | blitRegion.dstSubresource.layerCount = 1; |
| 12395 | blitRegion.dstSubresource.mipLevel = 0; |
| 12396 | |
| 12397 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 12398 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 12399 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 12400 | m_errorMonitor->VerifyFound(); |
| 12401 | |
| 12402 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12403 | "called with 0 in ppMemoryBarriers"); |
| 12404 | VkImageMemoryBarrier img_barrier; |
| 12405 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 12406 | img_barrier.pNext = NULL; |
| 12407 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 12408 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 12409 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12410 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12411 | img_barrier.image = image.handle(); |
| 12412 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 12413 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 12414 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12415 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 12416 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 12417 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 12418 | img_barrier.subresourceRange.layerCount = 0; |
| 12419 | img_barrier.subresourceRange.levelCount = 1; |
| 12420 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 12421 | VK_PIPELINE_STAGE_HOST_BIT, |
| 12422 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 12423 | nullptr, 1, &img_barrier); |
| 12424 | m_errorMonitor->VerifyFound(); |
| 12425 | img_barrier.subresourceRange.layerCount = 1; |
| 12426 | } |
| 12427 | |
| 12428 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 12429 | |
| 12430 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 12431 | |
| 12432 | m_errorMonitor->SetDesiredFailureMsg( |
| 12433 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12434 | "CreateImage extents exceed allowable limits for format"); |
| 12435 | VkImageCreateInfo image_create_info = {}; |
| 12436 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12437 | image_create_info.pNext = NULL; |
| 12438 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12439 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12440 | image_create_info.extent.width = 32; |
| 12441 | image_create_info.extent.height = 32; |
| 12442 | image_create_info.extent.depth = 1; |
| 12443 | image_create_info.mipLevels = 1; |
| 12444 | image_create_info.arrayLayers = 1; |
| 12445 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12446 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12447 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12448 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 12449 | image_create_info.flags = 0; |
| 12450 | |
| 12451 | VkImage nullImg; |
| 12452 | VkImageFormatProperties imgFmtProps; |
| 12453 | vkGetPhysicalDeviceImageFormatProperties( |
| 12454 | gpu(), image_create_info.format, image_create_info.imageType, |
| 12455 | image_create_info.tiling, image_create_info.usage, |
| 12456 | image_create_info.flags, &imgFmtProps); |
| 12457 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 12458 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12459 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12460 | m_errorMonitor->VerifyFound(); |
| 12461 | image_create_info.extent.depth = 1; |
| 12462 | |
| 12463 | m_errorMonitor->SetDesiredFailureMsg( |
| 12464 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12465 | "exceeds allowable maximum supported by format of"); |
| 12466 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 12467 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12468 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12469 | m_errorMonitor->VerifyFound(); |
| 12470 | image_create_info.mipLevels = 1; |
| 12471 | |
| 12472 | m_errorMonitor->SetDesiredFailureMsg( |
| 12473 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12474 | "exceeds allowable maximum supported by format of"); |
| 12475 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 12476 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12477 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12478 | m_errorMonitor->VerifyFound(); |
| 12479 | image_create_info.arrayLayers = 1; |
| 12480 | |
| 12481 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12482 | "is not supported by format"); |
| 12483 | int samples = imgFmtProps.sampleCounts >> 1; |
| 12484 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 12485 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 12486 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12487 | m_errorMonitor->VerifyFound(); |
| 12488 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12489 | |
| 12490 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12491 | "pCreateInfo->initialLayout, must be " |
| 12492 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 12493 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 12494 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 12495 | // Expect INVALID_LAYOUT |
| 12496 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 12497 | m_errorMonitor->VerifyFound(); |
| 12498 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 12499 | } |
| 12500 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12501 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 12502 | VkResult err; |
| 12503 | bool pass; |
| 12504 | |
| 12505 | // Create color images with different format sizes and try to copy between them |
| 12506 | m_errorMonitor->SetDesiredFailureMsg( |
| 12507 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12508 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 12509 | |
| 12510 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12511 | |
| 12512 | // Create two images of different types and try to copy between them |
| 12513 | VkImage srcImage; |
| 12514 | VkImage dstImage; |
| 12515 | VkDeviceMemory srcMem; |
| 12516 | VkDeviceMemory destMem; |
| 12517 | VkMemoryRequirements memReqs; |
| 12518 | |
| 12519 | VkImageCreateInfo image_create_info = {}; |
| 12520 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12521 | image_create_info.pNext = NULL; |
| 12522 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12523 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12524 | image_create_info.extent.width = 32; |
| 12525 | image_create_info.extent.height = 32; |
| 12526 | image_create_info.extent.depth = 1; |
| 12527 | image_create_info.mipLevels = 1; |
| 12528 | image_create_info.arrayLayers = 1; |
| 12529 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12530 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12531 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12532 | image_create_info.flags = 0; |
| 12533 | |
| 12534 | err = |
| 12535 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 12536 | ASSERT_VK_SUCCESS(err); |
| 12537 | |
| 12538 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 12539 | // Introduce failure by creating second image with a different-sized format. |
| 12540 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 12541 | |
| 12542 | err = |
| 12543 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 12544 | ASSERT_VK_SUCCESS(err); |
| 12545 | |
| 12546 | // Allocate memory |
| 12547 | VkMemoryAllocateInfo memAlloc = {}; |
| 12548 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12549 | memAlloc.pNext = NULL; |
| 12550 | memAlloc.allocationSize = 0; |
| 12551 | memAlloc.memoryTypeIndex = 0; |
| 12552 | |
| 12553 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 12554 | memAlloc.allocationSize = memReqs.size; |
| 12555 | pass = |
| 12556 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 12557 | ASSERT_TRUE(pass); |
| 12558 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 12559 | ASSERT_VK_SUCCESS(err); |
| 12560 | |
| 12561 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 12562 | memAlloc.allocationSize = memReqs.size; |
| 12563 | pass = |
| 12564 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 12565 | ASSERT_TRUE(pass); |
| 12566 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 12567 | ASSERT_VK_SUCCESS(err); |
| 12568 | |
| 12569 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12570 | ASSERT_VK_SUCCESS(err); |
| 12571 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 12572 | ASSERT_VK_SUCCESS(err); |
| 12573 | |
| 12574 | BeginCommandBuffer(); |
| 12575 | VkImageCopy copyRegion; |
| 12576 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12577 | copyRegion.srcSubresource.mipLevel = 0; |
| 12578 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 12579 | copyRegion.srcSubresource.layerCount = 0; |
| 12580 | copyRegion.srcOffset.x = 0; |
| 12581 | copyRegion.srcOffset.y = 0; |
| 12582 | copyRegion.srcOffset.z = 0; |
| 12583 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 12584 | copyRegion.dstSubresource.mipLevel = 0; |
| 12585 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 12586 | copyRegion.dstSubresource.layerCount = 0; |
| 12587 | copyRegion.dstOffset.x = 0; |
| 12588 | copyRegion.dstOffset.y = 0; |
| 12589 | copyRegion.dstOffset.z = 0; |
| 12590 | copyRegion.extent.width = 1; |
| 12591 | copyRegion.extent.height = 1; |
| 12592 | copyRegion.extent.depth = 1; |
| 12593 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12594 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 12595 | EndCommandBuffer(); |
| 12596 | |
| 12597 | m_errorMonitor->VerifyFound(); |
| 12598 | |
| 12599 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 12600 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 12601 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12602 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12603 | } |
| 12604 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12605 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 12606 | VkResult err; |
| 12607 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12608 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12609 | // 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] | 12610 | m_errorMonitor->SetDesiredFailureMsg( |
| 12611 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12612 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12613 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12615 | |
| 12616 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12617 | VkImage srcImage; |
| 12618 | VkImage dstImage; |
| 12619 | VkDeviceMemory srcMem; |
| 12620 | VkDeviceMemory destMem; |
| 12621 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12622 | |
| 12623 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12624 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12625 | image_create_info.pNext = NULL; |
| 12626 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12627 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12628 | image_create_info.extent.width = 32; |
| 12629 | image_create_info.extent.height = 32; |
| 12630 | image_create_info.extent.depth = 1; |
| 12631 | image_create_info.mipLevels = 1; |
| 12632 | image_create_info.arrayLayers = 1; |
| 12633 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12634 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12635 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12636 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12638 | err = |
| 12639 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12640 | ASSERT_VK_SUCCESS(err); |
| 12641 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 12642 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 12643 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12644 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12645 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12646 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12647 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12648 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12649 | err = |
| 12650 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12651 | ASSERT_VK_SUCCESS(err); |
| 12652 | |
| 12653 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12654 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12655 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12656 | memAlloc.pNext = NULL; |
| 12657 | memAlloc.allocationSize = 0; |
| 12658 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12659 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12660 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12661 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12662 | pass = |
| 12663 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12664 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12665 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12666 | ASSERT_VK_SUCCESS(err); |
| 12667 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12668 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12669 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12670 | pass = |
| 12671 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12672 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12673 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12674 | ASSERT_VK_SUCCESS(err); |
| 12675 | |
| 12676 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12677 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12678 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12679 | ASSERT_VK_SUCCESS(err); |
| 12680 | |
| 12681 | BeginCommandBuffer(); |
| 12682 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12683 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12684 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12685 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12686 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12687 | copyRegion.srcOffset.x = 0; |
| 12688 | copyRegion.srcOffset.y = 0; |
| 12689 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12690 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12691 | copyRegion.dstSubresource.mipLevel = 0; |
| 12692 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 12693 | copyRegion.dstSubresource.layerCount = 0; |
| 12694 | copyRegion.dstOffset.x = 0; |
| 12695 | copyRegion.dstOffset.y = 0; |
| 12696 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12697 | copyRegion.extent.width = 1; |
| 12698 | copyRegion.extent.height = 1; |
| 12699 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12700 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12701 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12702 | EndCommandBuffer(); |
| 12703 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12704 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12705 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12706 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12707 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12708 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12709 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12710 | } |
| 12711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12712 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 12713 | VkResult err; |
| 12714 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12715 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12716 | m_errorMonitor->SetDesiredFailureMsg( |
| 12717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12718 | "vkCmdResolveImage called with source sample count less than 2."); |
| 12719 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12721 | |
| 12722 | // 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] | 12723 | VkImage srcImage; |
| 12724 | VkImage dstImage; |
| 12725 | VkDeviceMemory srcMem; |
| 12726 | VkDeviceMemory destMem; |
| 12727 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12728 | |
| 12729 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12730 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12731 | image_create_info.pNext = NULL; |
| 12732 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12733 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12734 | image_create_info.extent.width = 32; |
| 12735 | image_create_info.extent.height = 1; |
| 12736 | image_create_info.extent.depth = 1; |
| 12737 | image_create_info.mipLevels = 1; |
| 12738 | image_create_info.arrayLayers = 1; |
| 12739 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12740 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12741 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12742 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12744 | err = |
| 12745 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12746 | ASSERT_VK_SUCCESS(err); |
| 12747 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12748 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12750 | err = |
| 12751 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12752 | ASSERT_VK_SUCCESS(err); |
| 12753 | |
| 12754 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12755 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12756 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12757 | memAlloc.pNext = NULL; |
| 12758 | memAlloc.allocationSize = 0; |
| 12759 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12760 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12761 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12762 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12763 | pass = |
| 12764 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12765 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12766 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12767 | ASSERT_VK_SUCCESS(err); |
| 12768 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12769 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12770 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12771 | pass = |
| 12772 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12773 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12774 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12775 | ASSERT_VK_SUCCESS(err); |
| 12776 | |
| 12777 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12778 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12779 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12780 | ASSERT_VK_SUCCESS(err); |
| 12781 | |
| 12782 | BeginCommandBuffer(); |
| 12783 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12784 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12785 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12786 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12787 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12788 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12789 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12790 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12791 | resolveRegion.srcOffset.x = 0; |
| 12792 | resolveRegion.srcOffset.y = 0; |
| 12793 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12794 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12795 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12796 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12797 | resolveRegion.dstSubresource.layerCount = 0; |
| 12798 | resolveRegion.dstOffset.x = 0; |
| 12799 | resolveRegion.dstOffset.y = 0; |
| 12800 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12801 | resolveRegion.extent.width = 1; |
| 12802 | resolveRegion.extent.height = 1; |
| 12803 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12804 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12805 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12806 | EndCommandBuffer(); |
| 12807 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12808 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12809 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12810 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12811 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12812 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12813 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12814 | } |
| 12815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12816 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 12817 | VkResult err; |
| 12818 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12820 | m_errorMonitor->SetDesiredFailureMsg( |
| 12821 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12822 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 12823 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12825 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12826 | // 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] | 12827 | VkImage srcImage; |
| 12828 | VkImage dstImage; |
| 12829 | VkDeviceMemory srcMem; |
| 12830 | VkDeviceMemory destMem; |
| 12831 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12832 | |
| 12833 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12834 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12835 | image_create_info.pNext = NULL; |
| 12836 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12837 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12838 | image_create_info.extent.width = 32; |
| 12839 | image_create_info.extent.height = 1; |
| 12840 | image_create_info.extent.depth = 1; |
| 12841 | image_create_info.mipLevels = 1; |
| 12842 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12843 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12844 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12845 | // Note: Some implementations expect color attachment usage for any |
| 12846 | // multisample surface |
| 12847 | image_create_info.usage = |
| 12848 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12849 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12850 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12851 | err = |
| 12852 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12853 | ASSERT_VK_SUCCESS(err); |
| 12854 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12855 | // Note: Some implementations expect color attachment usage for any |
| 12856 | // multisample surface |
| 12857 | image_create_info.usage = |
| 12858 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12860 | err = |
| 12861 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12862 | ASSERT_VK_SUCCESS(err); |
| 12863 | |
| 12864 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12865 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12866 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12867 | memAlloc.pNext = NULL; |
| 12868 | memAlloc.allocationSize = 0; |
| 12869 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12870 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12871 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12872 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12873 | pass = |
| 12874 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12875 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12876 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12877 | ASSERT_VK_SUCCESS(err); |
| 12878 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12879 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12880 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12881 | pass = |
| 12882 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12883 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12884 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12885 | ASSERT_VK_SUCCESS(err); |
| 12886 | |
| 12887 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12888 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12889 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12890 | ASSERT_VK_SUCCESS(err); |
| 12891 | |
| 12892 | BeginCommandBuffer(); |
| 12893 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12894 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12895 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12896 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12897 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12898 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12899 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12900 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12901 | resolveRegion.srcOffset.x = 0; |
| 12902 | resolveRegion.srcOffset.y = 0; |
| 12903 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12904 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12905 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12906 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12907 | resolveRegion.dstSubresource.layerCount = 0; |
| 12908 | resolveRegion.dstOffset.x = 0; |
| 12909 | resolveRegion.dstOffset.y = 0; |
| 12910 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12911 | resolveRegion.extent.width = 1; |
| 12912 | resolveRegion.extent.height = 1; |
| 12913 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12914 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12915 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12916 | EndCommandBuffer(); |
| 12917 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12918 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12919 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12920 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12921 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12922 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12923 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12924 | } |
| 12925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12926 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 12927 | VkResult err; |
| 12928 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12929 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12930 | m_errorMonitor->SetDesiredFailureMsg( |
| 12931 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12932 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 12933 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12935 | |
| 12936 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12937 | VkImage srcImage; |
| 12938 | VkImage dstImage; |
| 12939 | VkDeviceMemory srcMem; |
| 12940 | VkDeviceMemory destMem; |
| 12941 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12942 | |
| 12943 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12944 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12945 | image_create_info.pNext = NULL; |
| 12946 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12947 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12948 | image_create_info.extent.width = 32; |
| 12949 | image_create_info.extent.height = 1; |
| 12950 | image_create_info.extent.depth = 1; |
| 12951 | image_create_info.mipLevels = 1; |
| 12952 | image_create_info.arrayLayers = 1; |
| 12953 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 12954 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12955 | // Note: Some implementations expect color attachment usage for any |
| 12956 | // multisample surface |
| 12957 | image_create_info.usage = |
| 12958 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12959 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12961 | err = |
| 12962 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12963 | ASSERT_VK_SUCCESS(err); |
| 12964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12965 | // Set format to something other than source image |
| 12966 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 12967 | // Note: Some implementations expect color attachment usage for any |
| 12968 | // multisample surface |
| 12969 | image_create_info.usage = |
| 12970 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12971 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12973 | err = |
| 12974 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12975 | ASSERT_VK_SUCCESS(err); |
| 12976 | |
| 12977 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12978 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12979 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12980 | memAlloc.pNext = NULL; |
| 12981 | memAlloc.allocationSize = 0; |
| 12982 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12983 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12984 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12985 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12986 | pass = |
| 12987 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12988 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12989 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12990 | ASSERT_VK_SUCCESS(err); |
| 12991 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12992 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12993 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12994 | pass = |
| 12995 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12996 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12997 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12998 | ASSERT_VK_SUCCESS(err); |
| 12999 | |
| 13000 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 13001 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13002 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13003 | ASSERT_VK_SUCCESS(err); |
| 13004 | |
| 13005 | BeginCommandBuffer(); |
| 13006 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13007 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 13008 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13009 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13010 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13011 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 13012 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13013 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13014 | resolveRegion.srcOffset.x = 0; |
| 13015 | resolveRegion.srcOffset.y = 0; |
| 13016 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13017 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13018 | resolveRegion.dstSubresource.mipLevel = 0; |
| 13019 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 13020 | resolveRegion.dstSubresource.layerCount = 0; |
| 13021 | resolveRegion.dstOffset.x = 0; |
| 13022 | resolveRegion.dstOffset.y = 0; |
| 13023 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13024 | resolveRegion.extent.width = 1; |
| 13025 | resolveRegion.extent.height = 1; |
| 13026 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13027 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 13028 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13029 | EndCommandBuffer(); |
| 13030 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13031 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13032 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13033 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13034 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13035 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 13036 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13037 | } |
| 13038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13039 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 13040 | VkResult err; |
| 13041 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13043 | m_errorMonitor->SetDesiredFailureMsg( |
| 13044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13045 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 13046 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13048 | |
| 13049 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13050 | VkImage srcImage; |
| 13051 | VkImage dstImage; |
| 13052 | VkDeviceMemory srcMem; |
| 13053 | VkDeviceMemory destMem; |
| 13054 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13055 | |
| 13056 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13057 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13058 | image_create_info.pNext = NULL; |
| 13059 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13060 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 13061 | image_create_info.extent.width = 32; |
| 13062 | image_create_info.extent.height = 1; |
| 13063 | image_create_info.extent.depth = 1; |
| 13064 | image_create_info.mipLevels = 1; |
| 13065 | image_create_info.arrayLayers = 1; |
| 13066 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 13067 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13068 | // Note: Some implementations expect color attachment usage for any |
| 13069 | // multisample surface |
| 13070 | image_create_info.usage = |
| 13071 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13072 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13074 | err = |
| 13075 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13076 | ASSERT_VK_SUCCESS(err); |
| 13077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13078 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 13079 | // Note: Some implementations expect color attachment usage for any |
| 13080 | // multisample surface |
| 13081 | image_create_info.usage = |
| 13082 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13083 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13085 | err = |
| 13086 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13087 | ASSERT_VK_SUCCESS(err); |
| 13088 | |
| 13089 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13090 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13091 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 13092 | memAlloc.pNext = NULL; |
| 13093 | memAlloc.allocationSize = 0; |
| 13094 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13095 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 13096 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13097 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13098 | pass = |
| 13099 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13100 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13101 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13102 | ASSERT_VK_SUCCESS(err); |
| 13103 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13104 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13105 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13106 | pass = |
| 13107 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13108 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13109 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13110 | ASSERT_VK_SUCCESS(err); |
| 13111 | |
| 13112 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 13113 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13114 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13115 | ASSERT_VK_SUCCESS(err); |
| 13116 | |
| 13117 | BeginCommandBuffer(); |
| 13118 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13119 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 13120 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13121 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13122 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13123 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 13124 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13125 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13126 | resolveRegion.srcOffset.x = 0; |
| 13127 | resolveRegion.srcOffset.y = 0; |
| 13128 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13129 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13130 | resolveRegion.dstSubresource.mipLevel = 0; |
| 13131 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 13132 | resolveRegion.dstSubresource.layerCount = 0; |
| 13133 | resolveRegion.dstOffset.x = 0; |
| 13134 | resolveRegion.dstOffset.y = 0; |
| 13135 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13136 | resolveRegion.extent.width = 1; |
| 13137 | resolveRegion.extent.height = 1; |
| 13138 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13139 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 13140 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13141 | EndCommandBuffer(); |
| 13142 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13143 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13144 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13145 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13146 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13147 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 13148 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13149 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13151 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13152 | // 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] | 13153 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 13154 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13155 | // The image format check comes 2nd in validation so we trigger it first, |
| 13156 | // 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] | 13157 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13159 | m_errorMonitor->SetDesiredFailureMsg( |
| 13160 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13161 | "Combination depth/stencil image formats can have only the "); |
| 13162 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13163 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13164 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 13165 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13166 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 13167 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13168 | |
| 13169 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13170 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 13171 | ds_pool_ci.pNext = NULL; |
| 13172 | ds_pool_ci.maxSets = 1; |
| 13173 | ds_pool_ci.poolSizeCount = 1; |
| 13174 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13175 | |
| 13176 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13177 | err = |
| 13178 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13179 | ASSERT_VK_SUCCESS(err); |
| 13180 | |
| 13181 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13182 | dsl_binding.binding = 0; |
| 13183 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 13184 | dsl_binding.descriptorCount = 1; |
| 13185 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 13186 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13187 | |
| 13188 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13189 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 13190 | ds_layout_ci.pNext = NULL; |
| 13191 | ds_layout_ci.bindingCount = 1; |
| 13192 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13193 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13194 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 13195 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13196 | ASSERT_VK_SUCCESS(err); |
| 13197 | |
| 13198 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13199 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 13200 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 13201 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13202 | alloc_info.descriptorPool = ds_pool; |
| 13203 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13204 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 13205 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13206 | ASSERT_VK_SUCCESS(err); |
| 13207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13208 | VkImage image_bad; |
| 13209 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13210 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 13211 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13212 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13213 | const int32_t tex_width = 32; |
| 13214 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13215 | |
| 13216 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13217 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13218 | image_create_info.pNext = NULL; |
| 13219 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13220 | image_create_info.format = tex_format_bad; |
| 13221 | image_create_info.extent.width = tex_width; |
| 13222 | image_create_info.extent.height = tex_height; |
| 13223 | image_create_info.extent.depth = 1; |
| 13224 | image_create_info.mipLevels = 1; |
| 13225 | image_create_info.arrayLayers = 1; |
| 13226 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 13227 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13228 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 13229 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 13230 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13232 | err = |
| 13233 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13234 | ASSERT_VK_SUCCESS(err); |
| 13235 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13236 | image_create_info.usage = |
| 13237 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 13238 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 13239 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13240 | ASSERT_VK_SUCCESS(err); |
| 13241 | |
| 13242 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13243 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13244 | image_view_create_info.image = image_bad; |
| 13245 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 13246 | image_view_create_info.format = tex_format_bad; |
| 13247 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 13248 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 13249 | image_view_create_info.subresourceRange.layerCount = 1; |
| 13250 | image_view_create_info.subresourceRange.levelCount = 1; |
| 13251 | image_view_create_info.subresourceRange.aspectMask = |
| 13252 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13253 | |
| 13254 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13255 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 13256 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13257 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13258 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13259 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13260 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 13261 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13262 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 13263 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 13264 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 13265 | |
| 13266 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 13267 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 13268 | "ClearDepthStencilImage with a color image."); |
| 13269 | |
| 13270 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 13271 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 13272 | |
| 13273 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 13274 | BeginCommandBuffer(); |
| 13275 | m_commandBuffer->EndRenderPass(); |
| 13276 | |
| 13277 | // Color image |
| 13278 | VkClearColorValue clear_color; |
| 13279 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 13280 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 13281 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 13282 | const int32_t img_width = 32; |
| 13283 | const int32_t img_height = 32; |
| 13284 | VkImageCreateInfo image_create_info = {}; |
| 13285 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 13286 | image_create_info.pNext = NULL; |
| 13287 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13288 | image_create_info.format = color_format; |
| 13289 | image_create_info.extent.width = img_width; |
| 13290 | image_create_info.extent.height = img_height; |
| 13291 | image_create_info.extent.depth = 1; |
| 13292 | image_create_info.mipLevels = 1; |
| 13293 | image_create_info.arrayLayers = 1; |
| 13294 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 13295 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 13296 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 13297 | |
| 13298 | vk_testing::Image color_image; |
| 13299 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 13300 | reqs); |
| 13301 | |
| 13302 | const VkImageSubresourceRange color_range = |
| 13303 | vk_testing::Image::subresource_range(image_create_info, |
| 13304 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 13305 | |
| 13306 | // Depth/Stencil image |
| 13307 | VkClearDepthStencilValue clear_value = {0}; |
| 13308 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 13309 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 13310 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 13311 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 13312 | ds_image_create_info.extent.width = 64; |
| 13313 | ds_image_create_info.extent.height = 64; |
| 13314 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 13315 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 13316 | |
| 13317 | vk_testing::Image ds_image; |
| 13318 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 13319 | reqs); |
| 13320 | |
| 13321 | const VkImageSubresourceRange ds_range = |
| 13322 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 13323 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 13324 | |
| 13325 | m_errorMonitor->SetDesiredFailureMsg( |
| 13326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13327 | "vkCmdClearColorImage called with depth/stencil image."); |
| 13328 | |
| 13329 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 13330 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 13331 | &color_range); |
| 13332 | |
| 13333 | m_errorMonitor->VerifyFound(); |
| 13334 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 13335 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13336 | "vkCmdClearColorImage called with " |
| 13337 | "image created without " |
| 13338 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 13339 | |
| 13340 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 13341 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 13342 | &color_range); |
| 13343 | |
| 13344 | m_errorMonitor->VerifyFound(); |
| 13345 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 13346 | // Call CmdClearDepthStencilImage with color image |
| 13347 | m_errorMonitor->SetDesiredFailureMsg( |
| 13348 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 13349 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 13350 | |
| 13351 | vkCmdClearDepthStencilImage( |
| 13352 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 13353 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 13354 | &ds_range); |
| 13355 | |
| 13356 | m_errorMonitor->VerifyFound(); |
| 13357 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13358 | #endif // IMAGE_TESTS |
| 13359 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13360 | int main(int argc, char **argv) { |
| 13361 | int result; |
| 13362 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 13363 | #ifdef ANDROID |
| 13364 | int vulkanSupport = InitVulkan(); |
| 13365 | if (vulkanSupport == 0) |
| 13366 | return 1; |
| 13367 | #endif |
| 13368 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13369 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 13370 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13371 | |
| 13372 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 13373 | |
| 13374 | result = RUN_ALL_TESTS(); |
| 13375 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 13376 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 13377 | return result; |
| 13378 | } |