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 | } |
Tobin Ehlis | 93d57e1 | 2016-06-20 11:32:13 -0600 | [diff] [blame] | 2796 | #if 0 // Disabling this test for now, needs to be updated |
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 | |
| 2803 | m_errorMonitor->SetDesiredFailureMsg( |
| 2804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2805 | "for this object type are not compatible with the memory"); |
| 2806 | |
| 2807 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2808 | |
| 2809 | // Create an image, allocate memory, set a bad typeIndex and then try to |
| 2810 | // bind it |
| 2811 | VkImage image; |
| 2812 | VkDeviceMemory mem; |
| 2813 | VkMemoryRequirements mem_reqs; |
| 2814 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2815 | const int32_t tex_width = 32; |
| 2816 | const int32_t tex_height = 32; |
| 2817 | |
| 2818 | VkImageCreateInfo image_create_info = {}; |
| 2819 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2820 | image_create_info.pNext = NULL; |
| 2821 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2822 | image_create_info.format = tex_format; |
| 2823 | image_create_info.extent.width = tex_width; |
| 2824 | image_create_info.extent.height = tex_height; |
| 2825 | image_create_info.extent.depth = 1; |
| 2826 | image_create_info.mipLevels = 1; |
| 2827 | image_create_info.arrayLayers = 1; |
| 2828 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2829 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2830 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2831 | image_create_info.flags = 0; |
| 2832 | |
| 2833 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2834 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2835 | mem_alloc.pNext = NULL; |
| 2836 | mem_alloc.allocationSize = 0; |
| 2837 | mem_alloc.memoryTypeIndex = 0; |
| 2838 | |
| 2839 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2840 | ASSERT_VK_SUCCESS(err); |
| 2841 | |
| 2842 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 2843 | mem_alloc.allocationSize = mem_reqs.size; |
Tobin Ehlis | 93d57e1 | 2016-06-20 11:32:13 -0600 | [diff] [blame] | 2844 | // TODO : This is not an ideal way to cause the error and triggers a segF |
| 2845 | // on at least one android driver when attempting to Allocate the memory. |
| 2846 | // That segF may or may not be a driver bug, but really what we want to do |
| 2847 | // here is find a device-supported memory type that is also not supported |
| 2848 | // for the particular image we're binding the memory too. If no such |
| 2849 | // type exists, then we can print a message and skip the test. |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2850 | // Introduce Failure, select likely invalid TypeIndex |
| 2851 | mem_alloc.memoryTypeIndex = 31; |
| 2852 | |
| 2853 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2854 | ASSERT_VK_SUCCESS(err); |
| 2855 | |
| 2856 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2857 | (void)err; |
| 2858 | |
| 2859 | m_errorMonitor->VerifyFound(); |
| 2860 | |
| 2861 | vkDestroyImage(m_device->device(), image, NULL); |
| 2862 | vkFreeMemory(m_device->device(), mem, NULL); |
| 2863 | } |
Tobin Ehlis | 93d57e1 | 2016-06-20 11:32:13 -0600 | [diff] [blame] | 2864 | #endif |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2866 | VkResult err; |
| 2867 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2868 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2869 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2870 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2871 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2873 | |
| 2874 | // 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] | 2875 | VkImage image; |
| 2876 | VkDeviceMemory mem; |
| 2877 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2878 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2879 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2880 | const int32_t tex_width = 32; |
| 2881 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2882 | |
| 2883 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2884 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2885 | image_create_info.pNext = NULL; |
| 2886 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2887 | image_create_info.format = tex_format; |
| 2888 | image_create_info.extent.width = tex_width; |
| 2889 | image_create_info.extent.height = tex_height; |
| 2890 | image_create_info.extent.depth = 1; |
| 2891 | image_create_info.mipLevels = 1; |
| 2892 | image_create_info.arrayLayers = 1; |
| 2893 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2894 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2895 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2896 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2897 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2898 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2899 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2900 | mem_alloc.pNext = NULL; |
| 2901 | mem_alloc.allocationSize = 0; |
| 2902 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2903 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2904 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
| 2906 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2907 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2908 | |
| 2909 | mem_alloc.allocationSize = mem_reqs.size; |
| 2910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2911 | pass = |
| 2912 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2913 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2914 | |
| 2915 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2916 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2917 | ASSERT_VK_SUCCESS(err); |
| 2918 | |
| 2919 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2920 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2921 | |
| 2922 | // Try to bind free memory that has been freed |
| 2923 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2924 | // This may very well return an error. |
| 2925 | (void)err; |
| 2926 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2927 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2928 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2929 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2930 | } |
| 2931 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2932 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2933 | VkResult err; |
| 2934 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2935 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2936 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2937 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2938 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2940 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2941 | // Create an image object, allocate memory, destroy the object and then try |
| 2942 | // to bind it |
| 2943 | VkImage image; |
| 2944 | VkDeviceMemory mem; |
| 2945 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2946 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2947 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2948 | const int32_t tex_width = 32; |
| 2949 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2950 | |
| 2951 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2952 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2953 | image_create_info.pNext = NULL; |
| 2954 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2955 | image_create_info.format = tex_format; |
| 2956 | image_create_info.extent.width = tex_width; |
| 2957 | image_create_info.extent.height = tex_height; |
| 2958 | image_create_info.extent.depth = 1; |
| 2959 | image_create_info.mipLevels = 1; |
| 2960 | image_create_info.arrayLayers = 1; |
| 2961 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2962 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2963 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2964 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2965 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2966 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2967 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2968 | mem_alloc.pNext = NULL; |
| 2969 | mem_alloc.allocationSize = 0; |
| 2970 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2971 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2972 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2973 | ASSERT_VK_SUCCESS(err); |
| 2974 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2975 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2976 | |
| 2977 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2978 | pass = |
| 2979 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2980 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2981 | |
| 2982 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2983 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2984 | ASSERT_VK_SUCCESS(err); |
| 2985 | |
| 2986 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2987 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2988 | ASSERT_VK_SUCCESS(err); |
| 2989 | |
| 2990 | // Now Try to bind memory to this destroyed object |
| 2991 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2992 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2993 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2994 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2995 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2996 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2997 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2998 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2999 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3000 | #endif // OBJ_TRACKER_TESTS |
| 3001 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3002 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3003 | |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 3004 | // This is a positive test. No errors are expected. |
| 3005 | TEST_F(VkLayerTest, StencilLoadOp) { |
| 3006 | TEST_DESCRIPTION("Create a stencil-only attachment with a LOAD_OP set to " |
| 3007 | "CLEAR. stencil[Load|Store]Op used to be ignored."); |
| 3008 | VkResult result = VK_SUCCESS; |
| 3009 | VkImageFormatProperties formatProps; |
| 3010 | vkGetPhysicalDeviceImageFormatProperties( |
| 3011 | gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TYPE_2D, |
| 3012 | VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3013 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 3014 | 0, &formatProps); |
| 3015 | if (formatProps.maxExtent.width < 100 || formatProps.maxExtent.height < 100) { |
| 3016 | return; |
| 3017 | } |
| 3018 | |
| 3019 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3020 | VkFormat depth_stencil_fmt = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3021 | m_depthStencil->Init(m_device, 100, 100, depth_stencil_fmt, |
| 3022 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3023 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); |
| 3024 | VkAttachmentDescription att = {}; |
| 3025 | VkAttachmentReference ref = {}; |
| 3026 | att.format = depth_stencil_fmt; |
| 3027 | att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 3028 | att.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 3029 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 3030 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 3031 | att.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3032 | att.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3033 | |
| 3034 | VkClearValue clear; |
| 3035 | clear.depthStencil.depth = 1.0; |
| 3036 | clear.depthStencil.stencil = 0; |
| 3037 | ref.attachment = 0; |
| 3038 | ref.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3039 | |
| 3040 | VkSubpassDescription subpass = {}; |
| 3041 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; |
| 3042 | subpass.flags = 0; |
| 3043 | subpass.inputAttachmentCount = 0; |
| 3044 | subpass.pInputAttachments = NULL; |
| 3045 | subpass.colorAttachmentCount = 0; |
| 3046 | subpass.pColorAttachments = NULL; |
| 3047 | subpass.pResolveAttachments = NULL; |
| 3048 | subpass.pDepthStencilAttachment = &ref; |
| 3049 | subpass.preserveAttachmentCount = 0; |
| 3050 | subpass.pPreserveAttachments = NULL; |
| 3051 | |
| 3052 | VkRenderPass rp; |
| 3053 | VkRenderPassCreateInfo rp_info = {}; |
| 3054 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3055 | rp_info.attachmentCount = 1; |
| 3056 | rp_info.pAttachments = &att; |
| 3057 | rp_info.subpassCount = 1; |
| 3058 | rp_info.pSubpasses = &subpass; |
| 3059 | result = vkCreateRenderPass(device(), &rp_info, NULL, &rp); |
| 3060 | ASSERT_VK_SUCCESS(result); |
| 3061 | |
| 3062 | VkImageView *depthView = m_depthStencil->BindInfo(); |
| 3063 | VkFramebufferCreateInfo fb_info = {}; |
| 3064 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 3065 | fb_info.pNext = NULL; |
| 3066 | fb_info.renderPass = rp; |
| 3067 | fb_info.attachmentCount = 1; |
| 3068 | fb_info.pAttachments = depthView; |
| 3069 | fb_info.width = 100; |
| 3070 | fb_info.height = 100; |
| 3071 | fb_info.layers = 1; |
| 3072 | VkFramebuffer fb; |
| 3073 | result = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3074 | ASSERT_VK_SUCCESS(result); |
| 3075 | |
| 3076 | |
| 3077 | VkRenderPassBeginInfo rpbinfo = {}; |
| 3078 | rpbinfo.clearValueCount = 1; |
| 3079 | rpbinfo.pClearValues = &clear; |
| 3080 | rpbinfo.pNext = NULL; |
| 3081 | rpbinfo.renderPass = rp; |
| 3082 | rpbinfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3083 | rpbinfo.renderArea.extent.width = 100; |
| 3084 | rpbinfo.renderArea.extent.height = 100; |
| 3085 | rpbinfo.renderArea.offset.x = 0; |
| 3086 | rpbinfo.renderArea.offset.y = 0; |
| 3087 | rpbinfo.framebuffer = fb; |
| 3088 | |
| 3089 | VkFence fence = {}; |
| 3090 | VkFenceCreateInfo fence_ci = {}; |
| 3091 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3092 | fence_ci.pNext = nullptr; |
| 3093 | fence_ci.flags = 0; |
| 3094 | result = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fence); |
| 3095 | ASSERT_VK_SUCCESS(result); |
| 3096 | |
| 3097 | |
| 3098 | m_commandBuffer->BeginCommandBuffer(); |
| 3099 | m_commandBuffer->BeginRenderPass(rpbinfo); |
| 3100 | m_commandBuffer->EndRenderPass(); |
| 3101 | m_commandBuffer->EndCommandBuffer(); |
| 3102 | m_commandBuffer->QueueCommandBuffer(fence); |
| 3103 | |
| 3104 | VkImageObj destImage(m_device); |
| 3105 | destImage.init(100, 100, depth_stencil_fmt, |
| 3106 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 3107 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 3108 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 3109 | VkImageMemoryBarrier barrier = {}; |
| 3110 | VkImageSubresourceRange range; |
| 3111 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 3112 | barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | |
| 3113 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 3114 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | |
| 3115 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; |
| 3116 | barrier.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 3117 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 3118 | barrier.image = m_depthStencil->handle(); |
| 3119 | range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3120 | range.baseMipLevel = 0; |
| 3121 | range.levelCount = 1; |
| 3122 | range.baseArrayLayer = 0; |
| 3123 | range.layerCount = 1; |
| 3124 | barrier.subresourceRange = range; |
| 3125 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3126 | VkCommandBufferObj cmdbuf(m_device, m_commandPool); |
| 3127 | cmdbuf.BeginCommandBuffer(); |
| 3128 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3129 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, |
| 3130 | nullptr, 1, &barrier); |
| 3131 | barrier.srcAccessMask = 0; |
| 3132 | barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3133 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; |
| 3134 | barrier.image = destImage.handle(); |
| 3135 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | |
| 3136 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 3137 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3138 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, |
| 3139 | nullptr, 1, &barrier); |
| 3140 | VkImageCopy cregion; |
| 3141 | cregion.srcSubresource.aspectMask = |
| 3142 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3143 | cregion.srcSubresource.mipLevel = 0; |
| 3144 | cregion.srcSubresource.baseArrayLayer = 0; |
| 3145 | cregion.srcSubresource.layerCount = 1; |
| 3146 | cregion.srcOffset.x = 0; |
| 3147 | cregion.srcOffset.y = 0; |
| 3148 | cregion.srcOffset.z = 0; |
| 3149 | cregion.dstSubresource.aspectMask = |
| 3150 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 3151 | cregion.dstSubresource.mipLevel = 0; |
| 3152 | cregion.dstSubresource.baseArrayLayer = 0; |
| 3153 | cregion.dstSubresource.layerCount = 1; |
| 3154 | cregion.dstOffset.x = 0; |
| 3155 | cregion.dstOffset.y = 0; |
| 3156 | cregion.dstOffset.z = 0; |
| 3157 | cregion.extent.width = 100; |
| 3158 | cregion.extent.height = 100; |
| 3159 | cregion.extent.depth = 1; |
| 3160 | cmdbuf.CopyImage(m_depthStencil->handle(), |
| 3161 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, destImage.handle(), |
| 3162 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cregion); |
| 3163 | cmdbuf.EndCommandBuffer(); |
| 3164 | |
| 3165 | VkSubmitInfo submit_info; |
| 3166 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3167 | submit_info.pNext = NULL; |
| 3168 | submit_info.waitSemaphoreCount = 0; |
| 3169 | submit_info.pWaitSemaphores = NULL; |
| 3170 | submit_info.pWaitDstStageMask = NULL; |
| 3171 | submit_info.commandBufferCount = 1; |
| 3172 | submit_info.pCommandBuffers = &cmdbuf.handle(); |
| 3173 | submit_info.signalSemaphoreCount = 0; |
| 3174 | submit_info.pSignalSemaphores = NULL; |
| 3175 | |
| 3176 | m_errorMonitor->ExpectSuccess(); |
| 3177 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3178 | m_errorMonitor->VerifyNotFound(); |
| 3179 | |
Mark Lobodzinski | d0440da | 2016-06-17 15:10:03 -0600 | [diff] [blame] | 3180 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 3181 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3182 | vkDestroyRenderPass(m_device->device(), rp, nullptr); |
| 3183 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); |
| 3184 | } |
| 3185 | |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3186 | TEST_F(VkLayerTest, UnusedPreserveAttachment) { |
| 3187 | TEST_DESCRIPTION("Create a framebuffer where a subpass has a preserve " |
| 3188 | "attachment reference of VK_ATTACHMENT_UNUSED"); |
| 3189 | |
| 3190 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3191 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3192 | |
| 3193 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3194 | "must not be VK_ATTACHMENT_UNUSED"); |
| 3195 | |
| 3196 | VkAttachmentReference color_attach = {}; |
| 3197 | color_attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 3198 | color_attach.attachment = 0; |
| 3199 | uint32_t preserve_attachment = VK_ATTACHMENT_UNUSED; |
| 3200 | VkSubpassDescription subpass = {}; |
| 3201 | subpass.colorAttachmentCount = 1; |
| 3202 | subpass.pColorAttachments = &color_attach; |
| 3203 | subpass.preserveAttachmentCount = 1; |
| 3204 | subpass.pPreserveAttachments = &preserve_attachment; |
| 3205 | |
| 3206 | VkRenderPassCreateInfo rpci = {}; |
| 3207 | rpci.subpassCount = 1; |
| 3208 | rpci.pSubpasses = &subpass; |
| 3209 | rpci.attachmentCount = 1; |
| 3210 | VkAttachmentDescription attach_desc = {}; |
| 3211 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 3212 | rpci.pAttachments = &attach_desc; |
| 3213 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3214 | VkRenderPass rp; |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 3215 | VkResult result = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3216 | |
| 3217 | m_errorMonitor->VerifyFound(); |
| 3218 | |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 3219 | if (result == VK_SUCCESS) { |
| 3220 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3221 | } |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3222 | } |
| 3223 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3224 | TEST_F(VkLayerTest, FramebufferCreateErrors) { |
| 3225 | TEST_DESCRIPTION("Hit errors when attempting to create a framebuffer :\n" |
| 3226 | " 1. Mismatch between fb & renderPass attachmentCount\n" |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3227 | " 2. Use a color image as depthStencil attachment\n" |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3228 | " 3. Mismatch fb & renderPass attachment formats\n" |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3229 | " 4. Mismatch fb & renderPass attachment #samples\n" |
| 3230 | " 5. FB attachment w/ non-1 mip-levels\n"); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3231 | |
| 3232 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3233 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3234 | |
| 3235 | m_errorMonitor->SetDesiredFailureMsg( |
| 3236 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3237 | "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of 2 " |
| 3238 | "does not match attachmentCount of 1 of "); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3239 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3240 | // Create a renderPass with a single color attachment |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3241 | VkAttachmentReference attach = {}; |
| 3242 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 3243 | VkSubpassDescription subpass = {}; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3244 | subpass.pColorAttachments = &attach; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3245 | VkRenderPassCreateInfo rpci = {}; |
| 3246 | rpci.subpassCount = 1; |
| 3247 | rpci.pSubpasses = &subpass; |
| 3248 | rpci.attachmentCount = 1; |
| 3249 | VkAttachmentDescription attach_desc = {}; |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3250 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3251 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3252 | rpci.pAttachments = &attach_desc; |
| 3253 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 3254 | VkRenderPass rp; |
| 3255 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3256 | ASSERT_VK_SUCCESS(err); |
| 3257 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3258 | VkImageView ivs[2]; |
| 3259 | ivs[0] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
| 3260 | ivs[1] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3261 | VkFramebufferCreateInfo fb_info = {}; |
| 3262 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 3263 | fb_info.pNext = NULL; |
| 3264 | fb_info.renderPass = rp; |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3265 | // Set mis-matching attachmentCount |
| 3266 | fb_info.attachmentCount = 2; |
| 3267 | fb_info.pAttachments = ivs; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3268 | fb_info.width = 100; |
| 3269 | fb_info.height = 100; |
| 3270 | fb_info.layers = 1; |
| 3271 | |
| 3272 | VkFramebuffer fb; |
| 3273 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3274 | |
| 3275 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3276 | if (err == VK_SUCCESS) { |
| 3277 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3278 | } |
| 3279 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 3280 | |
| 3281 | // Create a renderPass with a depth-stencil attachment created with |
| 3282 | // IMAGE_USAGE_COLOR_ATTACHMENT |
| 3283 | // Add our color attachment to pDepthStencilAttachment |
| 3284 | subpass.pDepthStencilAttachment = &attach; |
| 3285 | subpass.pColorAttachments = NULL; |
| 3286 | VkRenderPass rp_ds; |
| 3287 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp_ds); |
| 3288 | ASSERT_VK_SUCCESS(err); |
| 3289 | // Set correct attachment count, but attachment has COLOR usage bit set |
| 3290 | fb_info.attachmentCount = 1; |
| 3291 | fb_info.renderPass = rp_ds; |
| 3292 | |
| 3293 | m_errorMonitor->SetDesiredFailureMsg( |
| 3294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3295 | " conflicts with the image's IMAGE_USAGE flags "); |
| 3296 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3297 | |
| 3298 | m_errorMonitor->VerifyFound(); |
| 3299 | if (err == VK_SUCCESS) { |
| 3300 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3301 | } |
| 3302 | vkDestroyRenderPass(m_device->device(), rp_ds, NULL); |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3303 | |
| 3304 | // Create new renderpass with alternate attachment format from fb |
| 3305 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3306 | subpass.pDepthStencilAttachment = NULL; |
| 3307 | subpass.pColorAttachments = &attach; |
| 3308 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3309 | ASSERT_VK_SUCCESS(err); |
| 3310 | |
| 3311 | // Cause error due to mis-matched formats between rp & fb |
| 3312 | // rp attachment 0 now has RGBA8 but corresponding fb attach is BGRA8 |
| 3313 | fb_info.renderPass = rp; |
| 3314 | m_errorMonitor->SetDesiredFailureMsg( |
| 3315 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3316 | " has format of VK_FORMAT_B8G8R8A8_UNORM that does not match "); |
| 3317 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3318 | |
| 3319 | m_errorMonitor->VerifyFound(); |
| 3320 | if (err == VK_SUCCESS) { |
| 3321 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3322 | } |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 3323 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3324 | |
| 3325 | // Create new renderpass with alternate sample count from fb |
| 3326 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3327 | attach_desc.samples = VK_SAMPLE_COUNT_4_BIT; |
| 3328 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3329 | ASSERT_VK_SUCCESS(err); |
| 3330 | |
| 3331 | // Cause error due to mis-matched sample count between rp & fb |
| 3332 | fb_info.renderPass = rp; |
| 3333 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3334 | " has VK_SAMPLE_COUNT_1_BIT samples " |
| 3335 | "that do not match the " |
| 3336 | "VK_SAMPLE_COUNT_4_BIT "); |
| 3337 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3338 | |
| 3339 | m_errorMonitor->VerifyFound(); |
| 3340 | if (err == VK_SUCCESS) { |
| 3341 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3342 | } |
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 3343 | |
| 3344 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 3345 | |
| 3346 | // Create a custom imageView with non-1 mip levels |
| 3347 | VkImageObj image(m_device); |
| 3348 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 3349 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 3350 | ASSERT_TRUE(image.initialized()); |
| 3351 | |
| 3352 | VkImageView view; |
| 3353 | VkImageViewCreateInfo ivci = {}; |
| 3354 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3355 | ivci.image = image.handle(); |
| 3356 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3357 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3358 | ivci.subresourceRange.layerCount = 1; |
| 3359 | ivci.subresourceRange.baseMipLevel = 0; |
| 3360 | // Set level count 2 (only 1 is allowed for FB attachment) |
| 3361 | ivci.subresourceRange.levelCount = 2; |
| 3362 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3363 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); |
| 3364 | ASSERT_VK_SUCCESS(err); |
| 3365 | // Re-create renderpass to have matching sample count |
| 3366 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3367 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 3368 | ASSERT_VK_SUCCESS(err); |
| 3369 | |
| 3370 | fb_info.renderPass = rp; |
| 3371 | fb_info.pAttachments = &view; |
| 3372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3373 | " has mip levelCount of 2 but only "); |
| 3374 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3375 | |
| 3376 | m_errorMonitor->VerifyFound(); |
| 3377 | if (err == VK_SUCCESS) { |
| 3378 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3379 | } |
| 3380 | |
| 3381 | vkDestroyImageView(m_device->device(), view, NULL); |
| 3382 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 3383 | } |
| 3384 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3385 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3386 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 3387 | TEST_DESCRIPTION( |
| 3388 | "Wait on a event then set it after the wait has been submitted."); |
| 3389 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3390 | m_errorMonitor->ExpectSuccess(); |
| 3391 | |
| 3392 | VkEvent event; |
| 3393 | VkEventCreateInfo event_create_info{}; |
| 3394 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3395 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3396 | |
| 3397 | VkCommandPool command_pool; |
| 3398 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3399 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3400 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3401 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3402 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3403 | &command_pool); |
| 3404 | |
| 3405 | VkCommandBuffer command_buffer; |
| 3406 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3407 | command_buffer_allocate_info.sType = |
| 3408 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3409 | command_buffer_allocate_info.commandPool = command_pool; |
| 3410 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3411 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3412 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3413 | &command_buffer); |
| 3414 | |
| 3415 | VkQueue queue = VK_NULL_HANDLE; |
| 3416 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3417 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3418 | |
| 3419 | { |
| 3420 | VkCommandBufferBeginInfo begin_info{}; |
| 3421 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3422 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3423 | |
| 3424 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 3425 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3426 | nullptr, 0, nullptr); |
| 3427 | vkCmdResetEvent(command_buffer, event, |
| 3428 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3429 | vkEndCommandBuffer(command_buffer); |
| 3430 | } |
| 3431 | { |
| 3432 | VkSubmitInfo submit_info{}; |
| 3433 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3434 | submit_info.commandBufferCount = 1; |
| 3435 | submit_info.pCommandBuffers = &command_buffer; |
| 3436 | submit_info.signalSemaphoreCount = 0; |
| 3437 | submit_info.pSignalSemaphores = nullptr; |
| 3438 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3439 | } |
| 3440 | { vkSetEvent(m_device->device(), event); } |
| 3441 | |
| 3442 | vkQueueWaitIdle(queue); |
| 3443 | |
| 3444 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3445 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3446 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3447 | |
| 3448 | m_errorMonitor->VerifyNotFound(); |
| 3449 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3450 | // This is a positive test. No errors should be generated. |
| 3451 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 3452 | TEST_DESCRIPTION( |
| 3453 | "Issue a query and copy from it on a second command buffer."); |
| 3454 | |
| 3455 | if ((m_device->queue_props.empty()) || |
| 3456 | (m_device->queue_props[0].queueCount < 2)) |
| 3457 | return; |
| 3458 | |
| 3459 | m_errorMonitor->ExpectSuccess(); |
| 3460 | |
| 3461 | VkQueryPool query_pool; |
| 3462 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 3463 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 3464 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 3465 | query_pool_create_info.queryCount = 1; |
| 3466 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 3467 | &query_pool); |
| 3468 | |
| 3469 | VkCommandPool command_pool; |
| 3470 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3471 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3472 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3473 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3474 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3475 | &command_pool); |
| 3476 | |
| 3477 | VkCommandBuffer command_buffer[2]; |
| 3478 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3479 | command_buffer_allocate_info.sType = |
| 3480 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3481 | command_buffer_allocate_info.commandPool = command_pool; |
| 3482 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3483 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3484 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3485 | command_buffer); |
| 3486 | |
| 3487 | VkQueue queue = VK_NULL_HANDLE; |
| 3488 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3489 | 1, &queue); |
| 3490 | |
| 3491 | uint32_t qfi = 0; |
| 3492 | VkBufferCreateInfo buff_create_info = {}; |
| 3493 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3494 | buff_create_info.size = 1024; |
| 3495 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 3496 | buff_create_info.queueFamilyIndexCount = 1; |
| 3497 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 3498 | |
| 3499 | VkResult err; |
| 3500 | VkBuffer buffer; |
| 3501 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 3502 | ASSERT_VK_SUCCESS(err); |
| 3503 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3504 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3505 | mem_alloc.pNext = NULL; |
| 3506 | mem_alloc.allocationSize = 1024; |
| 3507 | mem_alloc.memoryTypeIndex = 0; |
| 3508 | |
| 3509 | VkMemoryRequirements memReqs; |
| 3510 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 3511 | bool pass = |
| 3512 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 3513 | if (!pass) { |
| 3514 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3515 | return; |
| 3516 | } |
| 3517 | |
| 3518 | VkDeviceMemory mem; |
| 3519 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3520 | ASSERT_VK_SUCCESS(err); |
| 3521 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 3522 | ASSERT_VK_SUCCESS(err); |
| 3523 | |
| 3524 | { |
| 3525 | VkCommandBufferBeginInfo begin_info{}; |
| 3526 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3527 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3528 | |
| 3529 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 3530 | vkCmdWriteTimestamp(command_buffer[0], |
| 3531 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 3532 | |
| 3533 | vkEndCommandBuffer(command_buffer[0]); |
| 3534 | |
| 3535 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3536 | |
| 3537 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 3538 | 0, 0, 0); |
| 3539 | |
| 3540 | vkEndCommandBuffer(command_buffer[1]); |
| 3541 | } |
| 3542 | { |
| 3543 | VkSubmitInfo submit_info{}; |
| 3544 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3545 | submit_info.commandBufferCount = 2; |
| 3546 | submit_info.pCommandBuffers = command_buffer; |
| 3547 | submit_info.signalSemaphoreCount = 0; |
| 3548 | submit_info.pSignalSemaphores = nullptr; |
| 3549 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3550 | } |
| 3551 | |
| 3552 | vkQueueWaitIdle(queue); |
| 3553 | |
| 3554 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 3555 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 3556 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3557 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3558 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3559 | |
| 3560 | m_errorMonitor->VerifyNotFound(); |
| 3561 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3562 | |
| 3563 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 3564 | TEST_DESCRIPTION( |
| 3565 | "Reset an event then set it after the reset has been submitted."); |
| 3566 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3567 | m_errorMonitor->ExpectSuccess(); |
| 3568 | |
| 3569 | VkEvent event; |
| 3570 | VkEventCreateInfo event_create_info{}; |
| 3571 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3572 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3573 | |
| 3574 | VkCommandPool command_pool; |
| 3575 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3576 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3577 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3578 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3579 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3580 | &command_pool); |
| 3581 | |
| 3582 | VkCommandBuffer command_buffer; |
| 3583 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3584 | command_buffer_allocate_info.sType = |
| 3585 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3586 | command_buffer_allocate_info.commandPool = command_pool; |
| 3587 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3588 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3589 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3590 | &command_buffer); |
| 3591 | |
| 3592 | VkQueue queue = VK_NULL_HANDLE; |
| 3593 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3594 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3595 | |
| 3596 | { |
| 3597 | VkCommandBufferBeginInfo begin_info{}; |
| 3598 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3599 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3600 | |
| 3601 | vkCmdResetEvent(command_buffer, event, |
| 3602 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3603 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 3604 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3605 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3606 | nullptr, 0, nullptr); |
| 3607 | vkEndCommandBuffer(command_buffer); |
| 3608 | } |
| 3609 | { |
| 3610 | VkSubmitInfo submit_info{}; |
| 3611 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3612 | submit_info.commandBufferCount = 1; |
| 3613 | submit_info.pCommandBuffers = &command_buffer; |
| 3614 | submit_info.signalSemaphoreCount = 0; |
| 3615 | submit_info.pSignalSemaphores = nullptr; |
| 3616 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3617 | } |
| 3618 | { |
| 3619 | m_errorMonitor->SetDesiredFailureMsg( |
| 3620 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 3621 | "0x1 that is already in use by a " |
| 3622 | "command buffer."); |
| 3623 | vkSetEvent(m_device->device(), event); |
| 3624 | m_errorMonitor->VerifyFound(); |
| 3625 | } |
| 3626 | |
| 3627 | vkQueueWaitIdle(queue); |
| 3628 | |
| 3629 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3630 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3631 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3632 | } |
| 3633 | |
| 3634 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3635 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 3636 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 3637 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 3638 | "previously revealed a bug so running this positive test " |
| 3639 | "to prevent a regression."); |
| 3640 | m_errorMonitor->ExpectSuccess(); |
| 3641 | |
| 3642 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3643 | VkQueue queue = VK_NULL_HANDLE; |
| 3644 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3645 | 0, &queue); |
| 3646 | |
| 3647 | static const uint32_t NUM_OBJECTS = 2; |
| 3648 | static const uint32_t NUM_FRAMES = 3; |
| 3649 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 3650 | VkFence fences[NUM_OBJECTS] = {}; |
| 3651 | |
| 3652 | VkCommandPool cmd_pool; |
| 3653 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 3654 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3655 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3656 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3657 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3658 | nullptr, &cmd_pool); |
| 3659 | ASSERT_VK_SUCCESS(err); |
| 3660 | |
| 3661 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3662 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3663 | cmd_buf_info.commandPool = cmd_pool; |
| 3664 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3665 | cmd_buf_info.commandBufferCount = 1; |
| 3666 | |
| 3667 | VkFenceCreateInfo fence_ci = {}; |
| 3668 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3669 | fence_ci.pNext = nullptr; |
| 3670 | fence_ci.flags = 0; |
| 3671 | |
| 3672 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3673 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3674 | &cmd_buffers[i]); |
| 3675 | ASSERT_VK_SUCCESS(err); |
| 3676 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3677 | ASSERT_VK_SUCCESS(err); |
| 3678 | } |
| 3679 | |
| 3680 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3681 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3682 | // Create empty cmd buffer |
| 3683 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3684 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3685 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3686 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3687 | ASSERT_VK_SUCCESS(err); |
| 3688 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3689 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3690 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3691 | VkSubmitInfo submit_info = {}; |
| 3692 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3693 | submit_info.commandBufferCount = 1; |
| 3694 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3695 | // Submit cmd buffer and wait for fence |
| 3696 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3697 | ASSERT_VK_SUCCESS(err); |
| 3698 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3699 | UINT64_MAX); |
| 3700 | ASSERT_VK_SUCCESS(err); |
| 3701 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3702 | ASSERT_VK_SUCCESS(err); |
| 3703 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3704 | } |
| 3705 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3706 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3707 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3708 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3709 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3710 | } |
| 3711 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3712 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3713 | |
| 3714 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3715 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3716 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3717 | if ((m_device->queue_props.empty()) || |
| 3718 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3719 | return; |
| 3720 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3721 | m_errorMonitor->ExpectSuccess(); |
| 3722 | |
| 3723 | VkSemaphore semaphore; |
| 3724 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3725 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3726 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3727 | &semaphore); |
| 3728 | |
| 3729 | VkCommandPool command_pool; |
| 3730 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3731 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3732 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3733 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3734 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3735 | &command_pool); |
| 3736 | |
| 3737 | VkCommandBuffer command_buffer[2]; |
| 3738 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3739 | command_buffer_allocate_info.sType = |
| 3740 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3741 | command_buffer_allocate_info.commandPool = command_pool; |
| 3742 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3743 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3744 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3745 | command_buffer); |
| 3746 | |
| 3747 | VkQueue queue = VK_NULL_HANDLE; |
| 3748 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3749 | 1, &queue); |
| 3750 | |
| 3751 | { |
| 3752 | VkCommandBufferBeginInfo begin_info{}; |
| 3753 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3754 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3755 | |
| 3756 | vkCmdPipelineBarrier(command_buffer[0], |
| 3757 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3758 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3759 | 0, nullptr, 0, nullptr); |
| 3760 | |
| 3761 | VkViewport viewport{}; |
| 3762 | viewport.maxDepth = 1.0f; |
| 3763 | viewport.minDepth = 0.0f; |
| 3764 | viewport.width = 512; |
| 3765 | viewport.height = 512; |
| 3766 | viewport.x = 0; |
| 3767 | viewport.y = 0; |
| 3768 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3769 | vkEndCommandBuffer(command_buffer[0]); |
| 3770 | } |
| 3771 | { |
| 3772 | VkCommandBufferBeginInfo begin_info{}; |
| 3773 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3774 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3775 | |
| 3776 | VkViewport viewport{}; |
| 3777 | viewport.maxDepth = 1.0f; |
| 3778 | viewport.minDepth = 0.0f; |
| 3779 | viewport.width = 512; |
| 3780 | viewport.height = 512; |
| 3781 | viewport.x = 0; |
| 3782 | viewport.y = 0; |
| 3783 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3784 | vkEndCommandBuffer(command_buffer[1]); |
| 3785 | } |
| 3786 | { |
| 3787 | VkSubmitInfo submit_info{}; |
| 3788 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3789 | submit_info.commandBufferCount = 1; |
| 3790 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3791 | submit_info.signalSemaphoreCount = 1; |
| 3792 | submit_info.pSignalSemaphores = &semaphore; |
| 3793 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3794 | } |
| 3795 | { |
| 3796 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3797 | VkSubmitInfo submit_info{}; |
| 3798 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3799 | submit_info.commandBufferCount = 1; |
| 3800 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3801 | submit_info.waitSemaphoreCount = 1; |
| 3802 | submit_info.pWaitSemaphores = &semaphore; |
| 3803 | submit_info.pWaitDstStageMask = flags; |
| 3804 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3805 | } |
| 3806 | |
| 3807 | vkQueueWaitIdle(m_device->m_queue); |
| 3808 | |
| 3809 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3810 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3811 | &command_buffer[0]); |
| 3812 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3813 | |
| 3814 | m_errorMonitor->VerifyNotFound(); |
| 3815 | } |
| 3816 | |
| 3817 | // This is a positive test. No errors should be generated. |
| 3818 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3819 | |
| 3820 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3821 | "submitted on separate queues, the second having a fence" |
| 3822 | "followed by a QueueWaitIdle."); |
| 3823 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3824 | if ((m_device->queue_props.empty()) || |
| 3825 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3826 | return; |
| 3827 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3828 | m_errorMonitor->ExpectSuccess(); |
| 3829 | |
| 3830 | VkFence fence; |
| 3831 | VkFenceCreateInfo fence_create_info{}; |
| 3832 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3833 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3834 | |
| 3835 | VkSemaphore semaphore; |
| 3836 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3837 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3838 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3839 | &semaphore); |
| 3840 | |
| 3841 | VkCommandPool command_pool; |
| 3842 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3843 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3844 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3845 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3846 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3847 | &command_pool); |
| 3848 | |
| 3849 | VkCommandBuffer command_buffer[2]; |
| 3850 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3851 | command_buffer_allocate_info.sType = |
| 3852 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3853 | command_buffer_allocate_info.commandPool = command_pool; |
| 3854 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3855 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3856 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3857 | command_buffer); |
| 3858 | |
| 3859 | VkQueue queue = VK_NULL_HANDLE; |
| 3860 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3861 | 1, &queue); |
| 3862 | |
| 3863 | { |
| 3864 | VkCommandBufferBeginInfo begin_info{}; |
| 3865 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3866 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3867 | |
| 3868 | vkCmdPipelineBarrier(command_buffer[0], |
| 3869 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3870 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3871 | 0, nullptr, 0, nullptr); |
| 3872 | |
| 3873 | VkViewport viewport{}; |
| 3874 | viewport.maxDepth = 1.0f; |
| 3875 | viewport.minDepth = 0.0f; |
| 3876 | viewport.width = 512; |
| 3877 | viewport.height = 512; |
| 3878 | viewport.x = 0; |
| 3879 | viewport.y = 0; |
| 3880 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3881 | vkEndCommandBuffer(command_buffer[0]); |
| 3882 | } |
| 3883 | { |
| 3884 | VkCommandBufferBeginInfo begin_info{}; |
| 3885 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3886 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3887 | |
| 3888 | VkViewport viewport{}; |
| 3889 | viewport.maxDepth = 1.0f; |
| 3890 | viewport.minDepth = 0.0f; |
| 3891 | viewport.width = 512; |
| 3892 | viewport.height = 512; |
| 3893 | viewport.x = 0; |
| 3894 | viewport.y = 0; |
| 3895 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3896 | vkEndCommandBuffer(command_buffer[1]); |
| 3897 | } |
| 3898 | { |
| 3899 | VkSubmitInfo submit_info{}; |
| 3900 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3901 | submit_info.commandBufferCount = 1; |
| 3902 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3903 | submit_info.signalSemaphoreCount = 1; |
| 3904 | submit_info.pSignalSemaphores = &semaphore; |
| 3905 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3906 | } |
| 3907 | { |
| 3908 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3909 | VkSubmitInfo submit_info{}; |
| 3910 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3911 | submit_info.commandBufferCount = 1; |
| 3912 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3913 | submit_info.waitSemaphoreCount = 1; |
| 3914 | submit_info.pWaitSemaphores = &semaphore; |
| 3915 | submit_info.pWaitDstStageMask = flags; |
| 3916 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3917 | } |
| 3918 | |
| 3919 | vkQueueWaitIdle(m_device->m_queue); |
| 3920 | |
| 3921 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3922 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3923 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3924 | &command_buffer[0]); |
| 3925 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3926 | |
| 3927 | m_errorMonitor->VerifyNotFound(); |
| 3928 | } |
| 3929 | |
| 3930 | // This is a positive test. No errors should be generated. |
| 3931 | TEST_F(VkLayerTest, |
| 3932 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3933 | |
| 3934 | TEST_DESCRIPTION( |
| 3935 | "Two command buffers, each in a separate QueueSubmit call " |
| 3936 | "submitted on separate queues, the second having a fence" |
| 3937 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3938 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3939 | if ((m_device->queue_props.empty()) || |
| 3940 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3941 | return; |
| 3942 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3943 | m_errorMonitor->ExpectSuccess(); |
| 3944 | |
| 3945 | VkFence fence; |
| 3946 | VkFenceCreateInfo fence_create_info{}; |
| 3947 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3948 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3949 | |
| 3950 | VkSemaphore semaphore; |
| 3951 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3952 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3953 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3954 | &semaphore); |
| 3955 | |
| 3956 | VkCommandPool command_pool; |
| 3957 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3958 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3959 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3960 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3961 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3962 | &command_pool); |
| 3963 | |
| 3964 | VkCommandBuffer command_buffer[2]; |
| 3965 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3966 | command_buffer_allocate_info.sType = |
| 3967 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3968 | command_buffer_allocate_info.commandPool = command_pool; |
| 3969 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3970 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3971 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3972 | command_buffer); |
| 3973 | |
| 3974 | VkQueue queue = VK_NULL_HANDLE; |
| 3975 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3976 | 1, &queue); |
| 3977 | |
| 3978 | { |
| 3979 | VkCommandBufferBeginInfo begin_info{}; |
| 3980 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3981 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3982 | |
| 3983 | vkCmdPipelineBarrier(command_buffer[0], |
| 3984 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3985 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3986 | 0, nullptr, 0, nullptr); |
| 3987 | |
| 3988 | VkViewport viewport{}; |
| 3989 | viewport.maxDepth = 1.0f; |
| 3990 | viewport.minDepth = 0.0f; |
| 3991 | viewport.width = 512; |
| 3992 | viewport.height = 512; |
| 3993 | viewport.x = 0; |
| 3994 | viewport.y = 0; |
| 3995 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3996 | vkEndCommandBuffer(command_buffer[0]); |
| 3997 | } |
| 3998 | { |
| 3999 | VkCommandBufferBeginInfo begin_info{}; |
| 4000 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4001 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4002 | |
| 4003 | VkViewport viewport{}; |
| 4004 | viewport.maxDepth = 1.0f; |
| 4005 | viewport.minDepth = 0.0f; |
| 4006 | viewport.width = 512; |
| 4007 | viewport.height = 512; |
| 4008 | viewport.x = 0; |
| 4009 | viewport.y = 0; |
| 4010 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4011 | vkEndCommandBuffer(command_buffer[1]); |
| 4012 | } |
| 4013 | { |
| 4014 | VkSubmitInfo submit_info{}; |
| 4015 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4016 | submit_info.commandBufferCount = 1; |
| 4017 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4018 | submit_info.signalSemaphoreCount = 1; |
| 4019 | submit_info.pSignalSemaphores = &semaphore; |
| 4020 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4021 | } |
| 4022 | { |
| 4023 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4024 | VkSubmitInfo submit_info{}; |
| 4025 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4026 | submit_info.commandBufferCount = 1; |
| 4027 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4028 | submit_info.waitSemaphoreCount = 1; |
| 4029 | submit_info.pWaitSemaphores = &semaphore; |
| 4030 | submit_info.pWaitDstStageMask = flags; |
| 4031 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4032 | } |
| 4033 | |
| 4034 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4035 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4036 | |
| 4037 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4038 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4039 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4040 | &command_buffer[0]); |
| 4041 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4042 | |
| 4043 | m_errorMonitor->VerifyNotFound(); |
| 4044 | } |
| 4045 | |
| 4046 | // This is a positive test. No errors should be generated. |
| 4047 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 4048 | |
| 4049 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4050 | "submitted on separate queues, the second having a fence, " |
| 4051 | "followed by a WaitForFences call."); |
| 4052 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4053 | if ((m_device->queue_props.empty()) || |
| 4054 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4055 | return; |
| 4056 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4057 | m_errorMonitor->ExpectSuccess(); |
| 4058 | |
| 4059 | VkFence fence; |
| 4060 | VkFenceCreateInfo fence_create_info{}; |
| 4061 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4062 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4063 | |
| 4064 | VkSemaphore semaphore; |
| 4065 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4066 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4067 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4068 | &semaphore); |
| 4069 | |
| 4070 | VkCommandPool command_pool; |
| 4071 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4072 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4073 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4074 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4075 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4076 | &command_pool); |
| 4077 | |
| 4078 | VkCommandBuffer command_buffer[2]; |
| 4079 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4080 | command_buffer_allocate_info.sType = |
| 4081 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4082 | command_buffer_allocate_info.commandPool = command_pool; |
| 4083 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4084 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4085 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4086 | command_buffer); |
| 4087 | |
| 4088 | VkQueue queue = VK_NULL_HANDLE; |
| 4089 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 4090 | 1, &queue); |
| 4091 | |
| 4092 | |
| 4093 | { |
| 4094 | VkCommandBufferBeginInfo begin_info{}; |
| 4095 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4096 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4097 | |
| 4098 | vkCmdPipelineBarrier(command_buffer[0], |
| 4099 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4100 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4101 | 0, nullptr, 0, nullptr); |
| 4102 | |
| 4103 | VkViewport viewport{}; |
| 4104 | viewport.maxDepth = 1.0f; |
| 4105 | viewport.minDepth = 0.0f; |
| 4106 | viewport.width = 512; |
| 4107 | viewport.height = 512; |
| 4108 | viewport.x = 0; |
| 4109 | viewport.y = 0; |
| 4110 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4111 | vkEndCommandBuffer(command_buffer[0]); |
| 4112 | } |
| 4113 | { |
| 4114 | VkCommandBufferBeginInfo begin_info{}; |
| 4115 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4116 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4117 | |
| 4118 | VkViewport viewport{}; |
| 4119 | viewport.maxDepth = 1.0f; |
| 4120 | viewport.minDepth = 0.0f; |
| 4121 | viewport.width = 512; |
| 4122 | viewport.height = 512; |
| 4123 | viewport.x = 0; |
| 4124 | viewport.y = 0; |
| 4125 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4126 | vkEndCommandBuffer(command_buffer[1]); |
| 4127 | } |
| 4128 | { |
| 4129 | VkSubmitInfo submit_info{}; |
| 4130 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4131 | submit_info.commandBufferCount = 1; |
| 4132 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4133 | submit_info.signalSemaphoreCount = 1; |
| 4134 | submit_info.pSignalSemaphores = &semaphore; |
| 4135 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4136 | } |
| 4137 | { |
| 4138 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4139 | VkSubmitInfo submit_info{}; |
| 4140 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4141 | submit_info.commandBufferCount = 1; |
| 4142 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4143 | submit_info.waitSemaphoreCount = 1; |
| 4144 | submit_info.pWaitSemaphores = &semaphore; |
| 4145 | submit_info.pWaitDstStageMask = flags; |
| 4146 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4147 | } |
| 4148 | |
| 4149 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4150 | |
| 4151 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4152 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4153 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4154 | &command_buffer[0]); |
| 4155 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4156 | |
| 4157 | m_errorMonitor->VerifyNotFound(); |
| 4158 | } |
| 4159 | |
| 4160 | // This is a positive test. No errors should be generated. |
| 4161 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 4162 | |
| 4163 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4164 | "on the same queue, sharing a signal/wait semaphore, the " |
| 4165 | "second having a fence, " |
| 4166 | "followed by a WaitForFences call."); |
| 4167 | |
| 4168 | m_errorMonitor->ExpectSuccess(); |
| 4169 | |
| 4170 | VkFence fence; |
| 4171 | VkFenceCreateInfo fence_create_info{}; |
| 4172 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4173 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4174 | |
| 4175 | VkSemaphore semaphore; |
| 4176 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4177 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4178 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4179 | &semaphore); |
| 4180 | |
| 4181 | VkCommandPool command_pool; |
| 4182 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4183 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4184 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4185 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4186 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4187 | &command_pool); |
| 4188 | |
| 4189 | VkCommandBuffer command_buffer[2]; |
| 4190 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4191 | command_buffer_allocate_info.sType = |
| 4192 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4193 | command_buffer_allocate_info.commandPool = command_pool; |
| 4194 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4195 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4196 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4197 | command_buffer); |
| 4198 | |
| 4199 | { |
| 4200 | VkCommandBufferBeginInfo begin_info{}; |
| 4201 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4202 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4203 | |
| 4204 | vkCmdPipelineBarrier(command_buffer[0], |
| 4205 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4206 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4207 | 0, nullptr, 0, nullptr); |
| 4208 | |
| 4209 | VkViewport viewport{}; |
| 4210 | viewport.maxDepth = 1.0f; |
| 4211 | viewport.minDepth = 0.0f; |
| 4212 | viewport.width = 512; |
| 4213 | viewport.height = 512; |
| 4214 | viewport.x = 0; |
| 4215 | viewport.y = 0; |
| 4216 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4217 | vkEndCommandBuffer(command_buffer[0]); |
| 4218 | } |
| 4219 | { |
| 4220 | VkCommandBufferBeginInfo begin_info{}; |
| 4221 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4222 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4223 | |
| 4224 | VkViewport viewport{}; |
| 4225 | viewport.maxDepth = 1.0f; |
| 4226 | viewport.minDepth = 0.0f; |
| 4227 | viewport.width = 512; |
| 4228 | viewport.height = 512; |
| 4229 | viewport.x = 0; |
| 4230 | viewport.y = 0; |
| 4231 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4232 | vkEndCommandBuffer(command_buffer[1]); |
| 4233 | } |
| 4234 | { |
| 4235 | VkSubmitInfo submit_info{}; |
| 4236 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4237 | submit_info.commandBufferCount = 1; |
| 4238 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4239 | submit_info.signalSemaphoreCount = 1; |
| 4240 | submit_info.pSignalSemaphores = &semaphore; |
| 4241 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4242 | } |
| 4243 | { |
| 4244 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4245 | VkSubmitInfo submit_info{}; |
| 4246 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4247 | submit_info.commandBufferCount = 1; |
| 4248 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4249 | submit_info.waitSemaphoreCount = 1; |
| 4250 | submit_info.pWaitSemaphores = &semaphore; |
| 4251 | submit_info.pWaitDstStageMask = flags; |
| 4252 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4253 | } |
| 4254 | |
| 4255 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4256 | |
| 4257 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4258 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 4259 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4260 | &command_buffer[0]); |
| 4261 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4262 | |
| 4263 | m_errorMonitor->VerifyNotFound(); |
| 4264 | } |
| 4265 | |
| 4266 | // This is a positive test. No errors should be generated. |
| 4267 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 4268 | |
| 4269 | TEST_DESCRIPTION( |
| 4270 | "Two command buffers, each in a separate QueueSubmit call " |
| 4271 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 4272 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 4273 | |
| 4274 | m_errorMonitor->ExpectSuccess(); |
| 4275 | |
| 4276 | VkFence fence; |
| 4277 | VkFenceCreateInfo fence_create_info{}; |
| 4278 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4279 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4280 | |
| 4281 | VkCommandPool command_pool; |
| 4282 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4283 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4284 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4285 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4286 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4287 | &command_pool); |
| 4288 | |
| 4289 | VkCommandBuffer command_buffer[2]; |
| 4290 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4291 | command_buffer_allocate_info.sType = |
| 4292 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4293 | command_buffer_allocate_info.commandPool = command_pool; |
| 4294 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4295 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4296 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4297 | command_buffer); |
| 4298 | |
| 4299 | { |
| 4300 | VkCommandBufferBeginInfo begin_info{}; |
| 4301 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4302 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4303 | |
| 4304 | vkCmdPipelineBarrier(command_buffer[0], |
| 4305 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4306 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4307 | 0, nullptr, 0, nullptr); |
| 4308 | |
| 4309 | VkViewport viewport{}; |
| 4310 | viewport.maxDepth = 1.0f; |
| 4311 | viewport.minDepth = 0.0f; |
| 4312 | viewport.width = 512; |
| 4313 | viewport.height = 512; |
| 4314 | viewport.x = 0; |
| 4315 | viewport.y = 0; |
| 4316 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4317 | vkEndCommandBuffer(command_buffer[0]); |
| 4318 | } |
| 4319 | { |
| 4320 | VkCommandBufferBeginInfo begin_info{}; |
| 4321 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4322 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4323 | |
| 4324 | VkViewport viewport{}; |
| 4325 | viewport.maxDepth = 1.0f; |
| 4326 | viewport.minDepth = 0.0f; |
| 4327 | viewport.width = 512; |
| 4328 | viewport.height = 512; |
| 4329 | viewport.x = 0; |
| 4330 | viewport.y = 0; |
| 4331 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4332 | vkEndCommandBuffer(command_buffer[1]); |
| 4333 | } |
| 4334 | { |
| 4335 | VkSubmitInfo submit_info{}; |
| 4336 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4337 | submit_info.commandBufferCount = 1; |
| 4338 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4339 | submit_info.signalSemaphoreCount = 0; |
| 4340 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4341 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4342 | } |
| 4343 | { |
| 4344 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4345 | VkSubmitInfo submit_info{}; |
| 4346 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4347 | submit_info.commandBufferCount = 1; |
| 4348 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4349 | submit_info.waitSemaphoreCount = 0; |
| 4350 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4351 | submit_info.pWaitDstStageMask = flags; |
| 4352 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4353 | } |
| 4354 | |
| 4355 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 4356 | |
| 4357 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4358 | |
| 4359 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4360 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4361 | &command_buffer[0]); |
| 4362 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4363 | |
| 4364 | m_errorMonitor->VerifyNotFound(); |
| 4365 | } |
| 4366 | |
| 4367 | // This is a positive test. No errors should be generated. |
| 4368 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 4369 | |
| 4370 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4371 | "on the same queue, the second having a fence, followed " |
| 4372 | "by a WaitForFences call."); |
| 4373 | |
| 4374 | m_errorMonitor->ExpectSuccess(); |
| 4375 | |
| 4376 | VkFence fence; |
| 4377 | VkFenceCreateInfo fence_create_info{}; |
| 4378 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4379 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4380 | |
| 4381 | VkCommandPool command_pool; |
| 4382 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4383 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4384 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4385 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4386 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4387 | &command_pool); |
| 4388 | |
| 4389 | VkCommandBuffer command_buffer[2]; |
| 4390 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4391 | command_buffer_allocate_info.sType = |
| 4392 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4393 | command_buffer_allocate_info.commandPool = command_pool; |
| 4394 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4395 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4396 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4397 | command_buffer); |
| 4398 | |
| 4399 | { |
| 4400 | VkCommandBufferBeginInfo begin_info{}; |
| 4401 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4402 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4403 | |
| 4404 | vkCmdPipelineBarrier(command_buffer[0], |
| 4405 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4406 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4407 | 0, nullptr, 0, nullptr); |
| 4408 | |
| 4409 | VkViewport viewport{}; |
| 4410 | viewport.maxDepth = 1.0f; |
| 4411 | viewport.minDepth = 0.0f; |
| 4412 | viewport.width = 512; |
| 4413 | viewport.height = 512; |
| 4414 | viewport.x = 0; |
| 4415 | viewport.y = 0; |
| 4416 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4417 | vkEndCommandBuffer(command_buffer[0]); |
| 4418 | } |
| 4419 | { |
| 4420 | VkCommandBufferBeginInfo begin_info{}; |
| 4421 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4422 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4423 | |
| 4424 | VkViewport viewport{}; |
| 4425 | viewport.maxDepth = 1.0f; |
| 4426 | viewport.minDepth = 0.0f; |
| 4427 | viewport.width = 512; |
| 4428 | viewport.height = 512; |
| 4429 | viewport.x = 0; |
| 4430 | viewport.y = 0; |
| 4431 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4432 | vkEndCommandBuffer(command_buffer[1]); |
| 4433 | } |
| 4434 | { |
| 4435 | VkSubmitInfo submit_info{}; |
| 4436 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4437 | submit_info.commandBufferCount = 1; |
| 4438 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4439 | submit_info.signalSemaphoreCount = 0; |
| 4440 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4441 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4442 | } |
| 4443 | { |
| 4444 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4445 | VkSubmitInfo submit_info{}; |
| 4446 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4447 | submit_info.commandBufferCount = 1; |
| 4448 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4449 | submit_info.waitSemaphoreCount = 0; |
| 4450 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4451 | submit_info.pWaitDstStageMask = flags; |
| 4452 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4453 | } |
| 4454 | |
| 4455 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4456 | |
| 4457 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4458 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4459 | &command_buffer[0]); |
| 4460 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4461 | |
| 4462 | m_errorMonitor->VerifyNotFound(); |
| 4463 | } |
| 4464 | |
| 4465 | // This is a positive test. No errors should be generated. |
| 4466 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 4467 | |
| 4468 | TEST_DESCRIPTION( |
| 4469 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 4470 | "QueueSubmit call followed by a WaitForFences call."); |
| 4471 | |
| 4472 | m_errorMonitor->ExpectSuccess(); |
| 4473 | |
| 4474 | VkFence fence; |
| 4475 | VkFenceCreateInfo fence_create_info{}; |
| 4476 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4477 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4478 | |
| 4479 | VkSemaphore semaphore; |
| 4480 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4481 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4482 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4483 | &semaphore); |
| 4484 | |
| 4485 | VkCommandPool command_pool; |
| 4486 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4487 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4488 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4489 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4490 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4491 | &command_pool); |
| 4492 | |
| 4493 | VkCommandBuffer command_buffer[2]; |
| 4494 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4495 | command_buffer_allocate_info.sType = |
| 4496 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4497 | command_buffer_allocate_info.commandPool = command_pool; |
| 4498 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4499 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4500 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4501 | command_buffer); |
| 4502 | |
| 4503 | { |
| 4504 | VkCommandBufferBeginInfo begin_info{}; |
| 4505 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4506 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4507 | |
| 4508 | vkCmdPipelineBarrier(command_buffer[0], |
| 4509 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4510 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4511 | 0, nullptr, 0, nullptr); |
| 4512 | |
| 4513 | VkViewport viewport{}; |
| 4514 | viewport.maxDepth = 1.0f; |
| 4515 | viewport.minDepth = 0.0f; |
| 4516 | viewport.width = 512; |
| 4517 | viewport.height = 512; |
| 4518 | viewport.x = 0; |
| 4519 | viewport.y = 0; |
| 4520 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4521 | vkEndCommandBuffer(command_buffer[0]); |
| 4522 | } |
| 4523 | { |
| 4524 | VkCommandBufferBeginInfo begin_info{}; |
| 4525 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4526 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4527 | |
| 4528 | VkViewport viewport{}; |
| 4529 | viewport.maxDepth = 1.0f; |
| 4530 | viewport.minDepth = 0.0f; |
| 4531 | viewport.width = 512; |
| 4532 | viewport.height = 512; |
| 4533 | viewport.x = 0; |
| 4534 | viewport.y = 0; |
| 4535 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4536 | vkEndCommandBuffer(command_buffer[1]); |
| 4537 | } |
| 4538 | { |
| 4539 | VkSubmitInfo submit_info[2]; |
| 4540 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4541 | |
| 4542 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4543 | submit_info[0].pNext = NULL; |
| 4544 | submit_info[0].commandBufferCount = 1; |
| 4545 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 4546 | submit_info[0].signalSemaphoreCount = 1; |
| 4547 | submit_info[0].pSignalSemaphores = &semaphore; |
| 4548 | submit_info[0].waitSemaphoreCount = 0; |
| 4549 | submit_info[0].pWaitSemaphores = NULL; |
| 4550 | submit_info[0].pWaitDstStageMask = 0; |
| 4551 | |
| 4552 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4553 | submit_info[1].pNext = NULL; |
| 4554 | submit_info[1].commandBufferCount = 1; |
| 4555 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 4556 | submit_info[1].waitSemaphoreCount = 1; |
| 4557 | submit_info[1].pWaitSemaphores = &semaphore; |
| 4558 | submit_info[1].pWaitDstStageMask = flags; |
| 4559 | submit_info[1].signalSemaphoreCount = 0; |
| 4560 | submit_info[1].pSignalSemaphores = NULL; |
| 4561 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 4562 | } |
| 4563 | |
| 4564 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4565 | |
| 4566 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4567 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4568 | &command_buffer[0]); |
| 4569 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4570 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4571 | |
| 4572 | m_errorMonitor->VerifyNotFound(); |
| 4573 | } |
| 4574 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4575 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4576 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4577 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 4578 | "state is required but not correctly bound."); |
| 4579 | |
| 4580 | // Dynamic depth bias |
| 4581 | m_errorMonitor->SetDesiredFailureMsg( |
| 4582 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4583 | "Dynamic depth bias state not set for this command buffer"); |
| 4584 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4585 | BsoFailDepthBias); |
| 4586 | m_errorMonitor->VerifyFound(); |
| 4587 | } |
| 4588 | |
| 4589 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 4590 | TEST_DESCRIPTION( |
| 4591 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 4592 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4593 | |
| 4594 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4595 | m_errorMonitor->SetDesiredFailureMsg( |
| 4596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4597 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4598 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4599 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4600 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4601 | } |
| 4602 | |
| 4603 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 4604 | TEST_DESCRIPTION( |
| 4605 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 4606 | "state is required but not correctly bound."); |
| 4607 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4608 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4609 | m_errorMonitor->SetDesiredFailureMsg( |
| 4610 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4611 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4612 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4613 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4614 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4615 | } |
| 4616 | |
| 4617 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 4618 | TEST_DESCRIPTION( |
| 4619 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 4620 | "state is required but not correctly bound."); |
| 4621 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4622 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4623 | m_errorMonitor->SetDesiredFailureMsg( |
| 4624 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4625 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4626 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4627 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4628 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4629 | } |
| 4630 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4631 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4632 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4633 | "Run a simple draw calls to validate failure when Blend Constants " |
| 4634 | "dynamic state is required but not correctly bound."); |
| 4635 | // Dynamic blend constant state |
| 4636 | m_errorMonitor->SetDesiredFailureMsg( |
| 4637 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4638 | "Dynamic blend constants state not set for this command buffer"); |
| 4639 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4640 | BsoFailBlend); |
| 4641 | m_errorMonitor->VerifyFound(); |
| 4642 | } |
| 4643 | |
| 4644 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 4645 | TEST_DESCRIPTION( |
| 4646 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4647 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4648 | if (!m_device->phy().features().depthBounds) { |
| 4649 | printf("Device does not support depthBounds test; skipped.\n"); |
| 4650 | return; |
| 4651 | } |
| 4652 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4653 | m_errorMonitor->SetDesiredFailureMsg( |
| 4654 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4655 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4656 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4657 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4658 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4662 | TEST_DESCRIPTION( |
| 4663 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4664 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4665 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4666 | m_errorMonitor->SetDesiredFailureMsg( |
| 4667 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4668 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4669 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4670 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4671 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4672 | } |
| 4673 | |
| 4674 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4675 | TEST_DESCRIPTION( |
| 4676 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4677 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4678 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4679 | m_errorMonitor->SetDesiredFailureMsg( |
| 4680 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4681 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4682 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4683 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4684 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4685 | } |
| 4686 | |
| 4687 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4688 | TEST_DESCRIPTION( |
| 4689 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4690 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4691 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4692 | m_errorMonitor->SetDesiredFailureMsg( |
| 4693 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4694 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4695 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4696 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4697 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4698 | } |
| 4699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4700 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4701 | m_errorMonitor->SetDesiredFailureMsg( |
| 4702 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4703 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4704 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4705 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4706 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4707 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4708 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4710 | // We luck out b/c by default the framework creates CB w/ the |
| 4711 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4712 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4714 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4715 | EndCommandBuffer(); |
| 4716 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4717 | // Bypass framework since it does the waits automatically |
| 4718 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4719 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4720 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4721 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4722 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4723 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4724 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4725 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4726 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4727 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4728 | submit_info.pSignalSemaphores = NULL; |
| 4729 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4730 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4731 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4732 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4733 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4734 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4735 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4736 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4737 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4738 | } |
| 4739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4740 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4741 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4742 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4743 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4744 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4745 | "Unable to allocate 1 descriptors of " |
| 4746 | "type " |
| 4747 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4748 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4752 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4753 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4754 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4756 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4757 | |
| 4758 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4759 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4760 | ds_pool_ci.pNext = NULL; |
| 4761 | ds_pool_ci.flags = 0; |
| 4762 | ds_pool_ci.maxSets = 1; |
| 4763 | ds_pool_ci.poolSizeCount = 1; |
| 4764 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4765 | |
| 4766 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4767 | err = |
| 4768 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4769 | ASSERT_VK_SUCCESS(err); |
| 4770 | |
| 4771 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4772 | dsl_binding.binding = 0; |
| 4773 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4774 | dsl_binding.descriptorCount = 1; |
| 4775 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4776 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4777 | |
| 4778 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4779 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4780 | ds_layout_ci.pNext = NULL; |
| 4781 | ds_layout_ci.bindingCount = 1; |
| 4782 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4783 | |
| 4784 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4785 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4786 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4787 | ASSERT_VK_SUCCESS(err); |
| 4788 | |
| 4789 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4790 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4791 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4792 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4793 | alloc_info.descriptorPool = ds_pool; |
| 4794 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4795 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4796 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4797 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4798 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4799 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4800 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4801 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4802 | } |
| 4803 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4804 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4805 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4806 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4807 | m_errorMonitor->SetDesiredFailureMsg( |
| 4808 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4809 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4810 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4811 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4813 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4814 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4815 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4816 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4817 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4818 | |
| 4819 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4820 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4821 | ds_pool_ci.pNext = NULL; |
| 4822 | ds_pool_ci.maxSets = 1; |
| 4823 | ds_pool_ci.poolSizeCount = 1; |
| 4824 | ds_pool_ci.flags = 0; |
| 4825 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4826 | // app can only call vkResetDescriptorPool on this pool.; |
| 4827 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4828 | |
| 4829 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4830 | err = |
| 4831 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4832 | ASSERT_VK_SUCCESS(err); |
| 4833 | |
| 4834 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4835 | dsl_binding.binding = 0; |
| 4836 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4837 | dsl_binding.descriptorCount = 1; |
| 4838 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4839 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4840 | |
| 4841 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4842 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4843 | ds_layout_ci.pNext = NULL; |
| 4844 | ds_layout_ci.bindingCount = 1; |
| 4845 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4846 | |
| 4847 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4848 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4849 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4850 | ASSERT_VK_SUCCESS(err); |
| 4851 | |
| 4852 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4853 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4854 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4855 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4856 | alloc_info.descriptorPool = ds_pool; |
| 4857 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4858 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4859 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4860 | ASSERT_VK_SUCCESS(err); |
| 4861 | |
| 4862 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4863 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4864 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4865 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4866 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4867 | } |
| 4868 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4869 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4870 | // Attempt to clear Descriptor Pool with bad object. |
| 4871 | // ObjectTracker should catch this. |
| 4872 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4873 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4874 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4875 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4876 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4877 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4878 | } |
| 4879 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4880 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4881 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4882 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4883 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4884 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4885 | |
| 4886 | uint64_t fake_set_handle = 0xbaad6001; |
| 4887 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4888 | VkResult err; |
| 4889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4890 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4891 | |
| 4892 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4893 | |
| 4894 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4895 | layout_bindings[0].binding = 0; |
| 4896 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4897 | layout_bindings[0].descriptorCount = 1; |
| 4898 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4899 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4900 | |
| 4901 | VkDescriptorSetLayout descriptor_set_layout; |
| 4902 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4903 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4904 | dslci.pNext = NULL; |
| 4905 | dslci.bindingCount = 1; |
| 4906 | dslci.pBindings = layout_bindings; |
| 4907 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4908 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4909 | |
| 4910 | VkPipelineLayout pipeline_layout; |
| 4911 | VkPipelineLayoutCreateInfo plci = {}; |
| 4912 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4913 | plci.pNext = NULL; |
| 4914 | plci.setLayoutCount = 1; |
| 4915 | plci.pSetLayouts = &descriptor_set_layout; |
| 4916 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4917 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4918 | |
| 4919 | BeginCommandBuffer(); |
| 4920 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4921 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4922 | m_errorMonitor->VerifyFound(); |
| 4923 | EndCommandBuffer(); |
| 4924 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4925 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4926 | } |
| 4927 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4928 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4929 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4930 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4931 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4932 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4933 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4934 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4935 | |
| 4936 | VkPipelineLayout pipeline_layout; |
| 4937 | VkPipelineLayoutCreateInfo plci = {}; |
| 4938 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4939 | plci.pNext = NULL; |
| 4940 | plci.setLayoutCount = 1; |
| 4941 | plci.pSetLayouts = &bad_layout; |
| 4942 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4943 | |
| 4944 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4945 | } |
| 4946 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4947 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
| 4948 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " |
| 4949 | "1) A uniform buffer update must have a valid buffer index." |
| 4950 | "2) When using an array of descriptors in a single WriteDescriptor," |
| 4951 | " the descriptor types and stageflags must all be the same." |
| 4952 | "3) Immutable Sampler state must match across descriptors"); |
| 4953 | |
| 4954 | const char *invalid_BufferInfo_ErrorMessage = |
| 4955 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " |
| 4956 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " |
| 4957 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; |
| 4958 | const char *stateFlag_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4959 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4960 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4961 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4962 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
| 4964 | |
| 4965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4966 | VkDescriptorPoolSize ds_type_count[4] = {}; |
| 4967 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4968 | ds_type_count[0].descriptorCount = 1; |
| 4969 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4970 | ds_type_count[1].descriptorCount = 1; |
| 4971 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4972 | ds_type_count[2].descriptorCount = 1; |
| 4973 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4974 | ds_type_count[3].descriptorCount = 1; |
| 4975 | |
| 4976 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4977 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4978 | ds_pool_ci.maxSets = 1; |
| 4979 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); |
| 4980 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 4981 | |
| 4982 | VkDescriptorPool ds_pool; |
| 4983 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4984 | ASSERT_VK_SUCCESS(err); |
| 4985 | |
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4986 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4987 | layout_binding[0].binding = 0; |
| 4988 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4989 | layout_binding[0].descriptorCount = 1; |
| 4990 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4991 | layout_binding[0].pImmutableSamplers = NULL; |
| 4992 | |
| 4993 | layout_binding[1].binding = 1; |
| 4994 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4995 | layout_binding[1].descriptorCount = 1; |
| 4996 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 4997 | layout_binding[1].pImmutableSamplers = NULL; |
| 4998 | |
| 4999 | VkSamplerCreateInfo sampler_ci = {}; |
| 5000 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5001 | sampler_ci.pNext = NULL; |
| 5002 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5003 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5004 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5005 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5006 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5007 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5008 | sampler_ci.mipLodBias = 1.0; |
| 5009 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5010 | sampler_ci.maxAnisotropy = 1; |
| 5011 | sampler_ci.compareEnable = VK_FALSE; |
| 5012 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5013 | sampler_ci.minLod = 1.0; |
| 5014 | sampler_ci.maxLod = 1.0; |
| 5015 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5016 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5017 | VkSampler sampler; |
| 5018 | |
| 5019 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5020 | ASSERT_VK_SUCCESS(err); |
| 5021 | |
| 5022 | layout_binding[2].binding = 2; |
| 5023 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5024 | layout_binding[2].descriptorCount = 1; |
| 5025 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 5026 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); |
| 5027 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5028 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5029 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5030 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); |
| 5031 | ds_layout_ci.pBindings = layout_binding; |
| 5032 | VkDescriptorSetLayout ds_layout; |
| 5033 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 5034 | ASSERT_VK_SUCCESS(err); |
| 5035 | |
| 5036 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5037 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5038 | alloc_info.descriptorSetCount = 1; |
| 5039 | alloc_info.descriptorPool = ds_pool; |
| 5040 | alloc_info.pSetLayouts = &ds_layout; |
| 5041 | VkDescriptorSet descriptorSet; |
| 5042 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 5043 | ASSERT_VK_SUCCESS(err); |
| 5044 | |
| 5045 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5046 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5047 | pipeline_layout_ci.pNext = NULL; |
| 5048 | pipeline_layout_ci.setLayoutCount = 1; |
| 5049 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5050 | |
| 5051 | VkPipelineLayout pipeline_layout; |
| 5052 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 5053 | ASSERT_VK_SUCCESS(err); |
| 5054 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5055 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5056 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5057 | descriptor_write.dstSet = descriptorSet; |
| 5058 | descriptor_write.dstBinding = 0; |
| 5059 | descriptor_write.descriptorCount = 1; |
| 5060 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5061 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5062 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5063 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5064 | m_errorMonitor->VerifyFound(); |
| 5065 | |
| 5066 | // Create a buffer to update the descriptor with |
| 5067 | uint32_t qfi = 0; |
| 5068 | VkBufferCreateInfo buffCI = {}; |
| 5069 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5070 | buffCI.size = 1024; |
| 5071 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5072 | buffCI.queueFamilyIndexCount = 1; |
| 5073 | buffCI.pQueueFamilyIndices = &qfi; |
| 5074 | |
| 5075 | VkBuffer dyub; |
| 5076 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5077 | ASSERT_VK_SUCCESS(err); |
| 5078 | VkDescriptorBufferInfo buffInfo = {}; |
| 5079 | buffInfo.buffer = dyub; |
| 5080 | buffInfo.offset = 0; |
| 5081 | buffInfo.range = 1024; |
| 5082 | |
| 5083 | descriptor_write.pBufferInfo = &buffInfo; |
| 5084 | descriptor_write.descriptorCount = 2; |
| 5085 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5086 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5087 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
| 5088 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5089 | m_errorMonitor->VerifyFound(); |
| 5090 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5091 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
| 5092 | // the third descriptor contains an immutable sampler |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5093 | descriptor_write.dstBinding = 1; |
| 5094 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 5095 | |
| 5096 | |
| 5097 | // Make pImageInfo index non-null to avoid complaints of it missing |
| 5098 | VkDescriptorImageInfo imageInfo = {}; |
| 5099 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5100 | descriptor_write.pImageInfo = &imageInfo; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5101 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
| 5102 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5103 | m_errorMonitor->VerifyFound(); |
| 5104 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 5105 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5106 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5107 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5108 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5109 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5110 | } |
| 5111 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5112 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5113 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 5114 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5115 | // Create a valid cmd buffer |
| 5116 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 5117 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 5118 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5119 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5120 | "Invalid VkPipeline Object 0xbaad6001"); |
| 5121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5122 | BeginCommandBuffer(); |
| 5123 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5124 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 5125 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5126 | // Now issue a draw call with no pipeline bound |
| 5127 | m_errorMonitor->SetDesiredFailureMsg( |
| 5128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5129 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5130 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5131 | BeginCommandBuffer(); |
| 5132 | Draw(1, 0, 0, 0); |
| 5133 | m_errorMonitor->VerifyFound(); |
| 5134 | // Finally same check once more but with Dispatch/Compute |
| 5135 | m_errorMonitor->SetDesiredFailureMsg( |
| 5136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5137 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 5138 | BeginCommandBuffer(); |
| 5139 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 5140 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5141 | } |
| 5142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 5144 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 5145 | // CommandBuffer |
| 5146 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5147 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5148 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5149 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5150 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5151 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5152 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5153 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5154 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5156 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5157 | |
| 5158 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5160 | ds_pool_ci.pNext = NULL; |
| 5161 | ds_pool_ci.maxSets = 1; |
| 5162 | ds_pool_ci.poolSizeCount = 1; |
| 5163 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 5164 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5165 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5166 | err = |
| 5167 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5168 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5169 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5170 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5171 | dsl_binding.binding = 0; |
| 5172 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5173 | dsl_binding.descriptorCount = 1; |
| 5174 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5175 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5176 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5177 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5178 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5179 | ds_layout_ci.pNext = NULL; |
| 5180 | ds_layout_ci.bindingCount = 1; |
| 5181 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5182 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5183 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5184 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5185 | ASSERT_VK_SUCCESS(err); |
| 5186 | |
| 5187 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5188 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5189 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5190 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5191 | alloc_info.descriptorPool = ds_pool; |
| 5192 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5193 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5194 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5195 | ASSERT_VK_SUCCESS(err); |
| 5196 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5197 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5198 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5199 | pipeline_layout_ci.pNext = NULL; |
| 5200 | pipeline_layout_ci.setLayoutCount = 1; |
| 5201 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5202 | |
| 5203 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5204 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5205 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5206 | ASSERT_VK_SUCCESS(err); |
| 5207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5208 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5209 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5210 | // 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] | 5211 | // on more devices |
| 5212 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5213 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5214 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5215 | VkPipelineObj pipe(m_device); |
| 5216 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5217 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5218 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 5219 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5220 | |
| 5221 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5222 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5223 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5224 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5225 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5226 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5227 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5228 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5229 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5230 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5231 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5232 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5233 | } |
| 5234 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5235 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5236 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5240 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 5241 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5242 | |
| 5243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5244 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5245 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5246 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5247 | |
| 5248 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5249 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5250 | ds_pool_ci.pNext = NULL; |
| 5251 | ds_pool_ci.maxSets = 1; |
| 5252 | ds_pool_ci.poolSizeCount = 1; |
| 5253 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5254 | |
| 5255 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | err = |
| 5257 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5258 | ASSERT_VK_SUCCESS(err); |
| 5259 | |
| 5260 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5261 | dsl_binding.binding = 0; |
| 5262 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5263 | dsl_binding.descriptorCount = 1; |
| 5264 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5265 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5266 | |
| 5267 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5268 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5269 | ds_layout_ci.pNext = NULL; |
| 5270 | ds_layout_ci.bindingCount = 1; |
| 5271 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5272 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5273 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5274 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5275 | ASSERT_VK_SUCCESS(err); |
| 5276 | |
| 5277 | VkDescriptorSet descriptorSet; |
| 5278 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5279 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5280 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5281 | alloc_info.descriptorPool = ds_pool; |
| 5282 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5283 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5284 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5285 | ASSERT_VK_SUCCESS(err); |
| 5286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5287 | VkBufferView view = |
| 5288 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5289 | VkWriteDescriptorSet descriptor_write; |
| 5290 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5291 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5292 | descriptor_write.dstSet = descriptorSet; |
| 5293 | descriptor_write.dstBinding = 0; |
| 5294 | descriptor_write.descriptorCount = 1; |
| 5295 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 5296 | descriptor_write.pTexelBufferView = &view; |
| 5297 | |
| 5298 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5299 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5300 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 5301 | |
| 5302 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5303 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5304 | } |
| 5305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5306 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 5307 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 5308 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5309 | // 1. No dynamicOffset supplied |
| 5310 | // 2. Too many dynamicOffsets supplied |
| 5311 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5312 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5313 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5314 | " requires 1 dynamicOffsets, but only " |
| 5315 | "0 dynamicOffsets are left in " |
| 5316 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5317 | |
| 5318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5319 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5320 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5321 | |
| 5322 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5323 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5324 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5325 | |
| 5326 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5327 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5328 | ds_pool_ci.pNext = NULL; |
| 5329 | ds_pool_ci.maxSets = 1; |
| 5330 | ds_pool_ci.poolSizeCount = 1; |
| 5331 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5332 | |
| 5333 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5334 | err = |
| 5335 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5336 | ASSERT_VK_SUCCESS(err); |
| 5337 | |
| 5338 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5339 | dsl_binding.binding = 0; |
| 5340 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5341 | dsl_binding.descriptorCount = 1; |
| 5342 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5343 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5344 | |
| 5345 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5346 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5347 | ds_layout_ci.pNext = NULL; |
| 5348 | ds_layout_ci.bindingCount = 1; |
| 5349 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5350 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5351 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5352 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5353 | ASSERT_VK_SUCCESS(err); |
| 5354 | |
| 5355 | VkDescriptorSet descriptorSet; |
| 5356 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5357 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5358 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5359 | alloc_info.descriptorPool = ds_pool; |
| 5360 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5361 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5362 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5363 | ASSERT_VK_SUCCESS(err); |
| 5364 | |
| 5365 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5366 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5367 | pipeline_layout_ci.pNext = NULL; |
| 5368 | pipeline_layout_ci.setLayoutCount = 1; |
| 5369 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5370 | |
| 5371 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5372 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5373 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5374 | ASSERT_VK_SUCCESS(err); |
| 5375 | |
| 5376 | // Create a buffer to update the descriptor with |
| 5377 | uint32_t qfi = 0; |
| 5378 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5379 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5380 | buffCI.size = 1024; |
| 5381 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5382 | buffCI.queueFamilyIndexCount = 1; |
| 5383 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5384 | |
| 5385 | VkBuffer dyub; |
| 5386 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5387 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5388 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 5389 | // error |
| 5390 | VkMemoryAllocateInfo mem_alloc = {}; |
| 5391 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5392 | mem_alloc.pNext = NULL; |
| 5393 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 5394 | mem_alloc.memoryTypeIndex = 0; |
| 5395 | |
| 5396 | VkMemoryRequirements memReqs; |
| 5397 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 5398 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 5399 | 0); |
| 5400 | if (!pass) { |
| 5401 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5402 | return; |
| 5403 | } |
| 5404 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5405 | VkDeviceMemory mem; |
| 5406 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 5407 | ASSERT_VK_SUCCESS(err); |
| 5408 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 5409 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5410 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5411 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5412 | buffInfo.buffer = dyub; |
| 5413 | buffInfo.offset = 0; |
| 5414 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5415 | |
| 5416 | VkWriteDescriptorSet descriptor_write; |
| 5417 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5418 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5419 | descriptor_write.dstSet = descriptorSet; |
| 5420 | descriptor_write.dstBinding = 0; |
| 5421 | descriptor_write.descriptorCount = 1; |
| 5422 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5423 | descriptor_write.pBufferInfo = &buffInfo; |
| 5424 | |
| 5425 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5426 | |
| 5427 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5429 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5430 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5431 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5432 | uint32_t pDynOff[2] = {512, 756}; |
| 5433 | // 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] | 5434 | m_errorMonitor->SetDesiredFailureMsg( |
| 5435 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5436 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5437 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5438 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5439 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5440 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5441 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5442 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5443 | " dynamic offset 512 combined with " |
| 5444 | "offset 0 and range 1024 that " |
| 5445 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5446 | // Create PSO to be used for draw-time errors below |
| 5447 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5448 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5449 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5450 | "out gl_PerVertex { \n" |
| 5451 | " vec4 gl_Position;\n" |
| 5452 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5453 | "void main(){\n" |
| 5454 | " gl_Position = vec4(1);\n" |
| 5455 | "}\n"; |
| 5456 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5457 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5458 | "\n" |
| 5459 | "layout(location=0) out vec4 x;\n" |
| 5460 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5461 | "void main(){\n" |
| 5462 | " x = vec4(bar.y);\n" |
| 5463 | "}\n"; |
| 5464 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5465 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5466 | VkPipelineObj pipe(m_device); |
| 5467 | pipe.AddShader(&vs); |
| 5468 | pipe.AddShader(&fs); |
| 5469 | pipe.AddColorAttachment(); |
| 5470 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 5471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5472 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5473 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5474 | // This update should succeed, but offset size of 512 will overstep buffer |
| 5475 | // /w range 1024 & size 1024 |
| 5476 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5477 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5478 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5479 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5480 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5481 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5482 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 5483 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5484 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5485 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5486 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5487 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5488 | } |
| 5489 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5490 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5491 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5493 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5495 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5496 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5497 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5498 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5499 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5500 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 5501 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 5502 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5503 | // |
| 5504 | // Check for invalid push constant ranges in pipeline layouts. |
| 5505 | // |
| 5506 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5507 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5508 | char const *msg; |
| 5509 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5510 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5511 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 5512 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 5513 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5514 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5515 | "size 0."}, |
| 5516 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5517 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5518 | "size 1."}, |
| 5519 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5520 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5521 | "size 1."}, |
| 5522 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5523 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5524 | "size 0."}, |
| 5525 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5526 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5527 | "offset 1. Offset must"}, |
| 5528 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 5529 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5530 | "with offset "}, |
| 5531 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 5532 | "vkCreatePipelineLayout() call has push constants " |
| 5533 | "index 0 with offset "}, |
| 5534 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 5535 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5536 | "with offset "}, |
| 5537 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 5538 | "vkCreatePipelineLayout() call has push " |
| 5539 | "constants index 0 with offset "}, |
| 5540 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 5541 | "vkCreatePipelineLayout() call has push " |
| 5542 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5543 | }}; |
| 5544 | |
| 5545 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5546 | for (const auto &iter : range_tests) { |
| 5547 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5549 | iter.msg); |
| 5550 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5551 | NULL, &pipeline_layout); |
| 5552 | m_errorMonitor->VerifyFound(); |
| 5553 | if (VK_SUCCESS == err) { |
| 5554 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5555 | } |
| 5556 | } |
| 5557 | |
| 5558 | // Check for invalid stage flag |
| 5559 | pc_range.offset = 0; |
| 5560 | pc_range.size = 16; |
| 5561 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5562 | m_errorMonitor->SetDesiredFailureMsg( |
| 5563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5564 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5565 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5566 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5567 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5568 | if (VK_SUCCESS == err) { |
| 5569 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5570 | } |
| 5571 | |
| 5572 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5573 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5574 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5575 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5576 | char const *msg; |
| 5577 | }; |
| 5578 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5579 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5580 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5581 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5582 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5583 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5584 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5585 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 5586 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 5587 | { |
| 5588 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5589 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5590 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5591 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5592 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5593 | "vkCreatePipelineLayout() call has push constants with " |
| 5594 | "overlapping " |
| 5595 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 5596 | }, |
| 5597 | { |
| 5598 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5599 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5600 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5601 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5602 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5603 | "vkCreatePipelineLayout() call has push constants with " |
| 5604 | "overlapping " |
| 5605 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 5606 | }, |
| 5607 | { |
| 5608 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5609 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5610 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5611 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5612 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5613 | "vkCreatePipelineLayout() call has push constants with " |
| 5614 | "overlapping " |
| 5615 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 5616 | }, |
| 5617 | { |
| 5618 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5619 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 5620 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 5621 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 5622 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 5623 | "vkCreatePipelineLayout() call has push constants with " |
| 5624 | "overlapping " |
| 5625 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 5626 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5627 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5628 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5629 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5630 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 5631 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5632 | iter.msg); |
| 5633 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5634 | NULL, &pipeline_layout); |
| 5635 | m_errorMonitor->VerifyFound(); |
| 5636 | if (VK_SUCCESS == err) { |
| 5637 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5638 | } |
| 5639 | } |
| 5640 | |
| 5641 | // 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] | 5642 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 5643 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5644 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5645 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5646 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 5647 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5648 | ""}, |
| 5649 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 5650 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 5651 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 5652 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 5653 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5654 | ""}}}; |
| 5655 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5656 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 5657 | m_errorMonitor->ExpectSuccess(); |
| 5658 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5659 | NULL, &pipeline_layout); |
| 5660 | m_errorMonitor->VerifyNotFound(); |
| 5661 | if (VK_SUCCESS == err) { |
| 5662 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5663 | } |
| 5664 | } |
| 5665 | |
| 5666 | // |
| 5667 | // CmdPushConstants tests |
| 5668 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5669 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5670 | |
| 5671 | // 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] | 5672 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 5673 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5674 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 5675 | "must be greater than zero and a multiple of 4."}, |
| 5676 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5677 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5678 | "must be greater than zero and a multiple of 4."}, |
| 5679 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5680 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5681 | "must be greater than zero and a multiple of 4."}, |
| 5682 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5683 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5684 | "Offset must be a multiple of 4."}, |
| 5685 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5686 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5687 | "Offset must be a multiple of 4."}, |
| 5688 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5689 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5690 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5691 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 5692 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 5693 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5694 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 5695 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 5696 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5697 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 5698 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 5699 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5700 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 5701 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 5702 | "any of the ranges in pipeline layout"}, |
| 5703 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5704 | 0, 16}, |
| 5705 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 5706 | "any of the ranges in pipeline layout"}, |
| 5707 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5708 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5709 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5710 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5711 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5712 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5713 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5714 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5715 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5716 | "vkCmdPushConstants() call has push constants with offset "}, |
| 5717 | }}; |
| 5718 | |
| 5719 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5720 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5721 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5722 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5723 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5724 | pipeline_layout_ci.pushConstantRangeCount = |
| 5725 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5726 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5727 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5728 | &pipeline_layout); |
| 5729 | ASSERT_VK_SUCCESS(err); |
| 5730 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5731 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5732 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5733 | iter.msg); |
| 5734 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5735 | iter.range.stageFlags, iter.range.offset, |
| 5736 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5737 | m_errorMonitor->VerifyFound(); |
| 5738 | } |
| 5739 | |
| 5740 | // Check for invalid stage flag |
| 5741 | m_errorMonitor->SetDesiredFailureMsg( |
| 5742 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5743 | "vkCmdPushConstants() call has no stageFlags set."); |
| 5744 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5745 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5746 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5747 | EndCommandBuffer(); |
| 5748 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5749 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5750 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5751 | // overlapping range tests with cmd |
| 5752 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 5753 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5754 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5755 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5756 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5757 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 5758 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5759 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 5760 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 5761 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5762 | }}; |
| 5763 | const VkPushConstantRange pc_range3[] = { |
| 5764 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5765 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5766 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5767 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5768 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5769 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5770 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5771 | }; |
| 5772 | pipeline_layout_ci.pushConstantRangeCount = |
| 5773 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 5774 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 5775 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5776 | &pipeline_layout); |
| 5777 | ASSERT_VK_SUCCESS(err); |
| 5778 | BeginCommandBuffer(); |
| 5779 | for (const auto &iter : cmd_overlap_tests) { |
| 5780 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5781 | iter.msg); |
| 5782 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5783 | iter.range.stageFlags, iter.range.offset, |
| 5784 | iter.range.size, dummy_values); |
| 5785 | m_errorMonitor->VerifyFound(); |
| 5786 | } |
| 5787 | EndCommandBuffer(); |
| 5788 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5789 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5790 | |
| 5791 | // positive overlapping range tests with cmd |
| 5792 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 5793 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 5794 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 5795 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 5796 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 5797 | }}; |
| 5798 | const VkPushConstantRange pc_range4[] = { |
| 5799 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 5800 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5801 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5802 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5803 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5804 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5805 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5806 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5807 | }; |
| 5808 | pipeline_layout_ci.pushConstantRangeCount = |
| 5809 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 5810 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 5811 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5812 | &pipeline_layout); |
| 5813 | ASSERT_VK_SUCCESS(err); |
| 5814 | BeginCommandBuffer(); |
| 5815 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5816 | m_errorMonitor->ExpectSuccess(); |
| 5817 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5818 | iter.range.stageFlags, iter.range.offset, |
| 5819 | iter.range.size, dummy_values); |
| 5820 | m_errorMonitor->VerifyNotFound(); |
| 5821 | } |
| 5822 | EndCommandBuffer(); |
| 5823 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5824 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5825 | } |
| 5826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5827 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5828 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5829 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5830 | |
| 5831 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5832 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5833 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5834 | |
| 5835 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5836 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5838 | ds_type_count[0].descriptorCount = 10; |
| 5839 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5840 | ds_type_count[1].descriptorCount = 2; |
| 5841 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5842 | ds_type_count[2].descriptorCount = 2; |
| 5843 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5844 | ds_type_count[3].descriptorCount = 5; |
| 5845 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5846 | // type |
| 5847 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5848 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5849 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5850 | |
| 5851 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5853 | ds_pool_ci.pNext = NULL; |
| 5854 | ds_pool_ci.maxSets = 5; |
| 5855 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5856 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5857 | |
| 5858 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | err = |
| 5860 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5861 | ASSERT_VK_SUCCESS(err); |
| 5862 | |
| 5863 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5864 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5865 | dsl_binding[0].binding = 0; |
| 5866 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5867 | dsl_binding[0].descriptorCount = 5; |
| 5868 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5869 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5870 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5871 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5872 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5873 | dsl_fs_stage_only.binding = 0; |
| 5874 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5875 | dsl_fs_stage_only.descriptorCount = 5; |
| 5876 | dsl_fs_stage_only.stageFlags = |
| 5877 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5878 | // bind time |
| 5879 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5880 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5882 | ds_layout_ci.pNext = NULL; |
| 5883 | ds_layout_ci.bindingCount = 1; |
| 5884 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5885 | static const uint32_t NUM_LAYOUTS = 4; |
| 5886 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5887 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5888 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5889 | // layout for error case |
| 5890 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5891 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5892 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5893 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5894 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5895 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5896 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5897 | dsl_binding[0].binding = 0; |
| 5898 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5899 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5900 | dsl_binding[1].binding = 1; |
| 5901 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5902 | dsl_binding[1].descriptorCount = 2; |
| 5903 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5904 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5905 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5906 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5907 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5908 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5909 | ASSERT_VK_SUCCESS(err); |
| 5910 | dsl_binding[0].binding = 0; |
| 5911 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5912 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5913 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5914 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5915 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5916 | ASSERT_VK_SUCCESS(err); |
| 5917 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5918 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5919 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5920 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5921 | ASSERT_VK_SUCCESS(err); |
| 5922 | |
| 5923 | static const uint32_t NUM_SETS = 4; |
| 5924 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5925 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5926 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5927 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5928 | alloc_info.descriptorPool = ds_pool; |
| 5929 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5930 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5931 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5932 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5933 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5934 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5935 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5936 | err = |
| 5937 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5938 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5939 | |
| 5940 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5941 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5942 | pipeline_layout_ci.pNext = NULL; |
| 5943 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5944 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5945 | |
| 5946 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5947 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5948 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5950 | // Create pipelineLayout with only one setLayout |
| 5951 | pipeline_layout_ci.setLayoutCount = 1; |
| 5952 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5954 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5955 | ASSERT_VK_SUCCESS(err); |
| 5956 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5957 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5958 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5959 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5960 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5961 | ASSERT_VK_SUCCESS(err); |
| 5962 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5963 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5964 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5965 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5966 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5967 | ASSERT_VK_SUCCESS(err); |
| 5968 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5969 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5970 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5972 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5973 | ASSERT_VK_SUCCESS(err); |
| 5974 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5975 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5976 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5977 | pl_bad_s0[1] = ds_layout[1]; |
| 5978 | pipeline_layout_ci.setLayoutCount = 2; |
| 5979 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5980 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5981 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5982 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5983 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5984 | |
| 5985 | // Create a buffer to update the descriptor with |
| 5986 | uint32_t qfi = 0; |
| 5987 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5988 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5989 | buffCI.size = 1024; |
| 5990 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5991 | buffCI.queueFamilyIndexCount = 1; |
| 5992 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5993 | |
| 5994 | VkBuffer dyub; |
| 5995 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5996 | ASSERT_VK_SUCCESS(err); |
| 5997 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5998 | static const uint32_t NUM_BUFFS = 5; |
| 5999 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6000 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6001 | buffInfo[i].buffer = dyub; |
| 6002 | buffInfo[i].offset = 0; |
| 6003 | buffInfo[i].range = 1024; |
| 6004 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6005 | VkImage image; |
| 6006 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6007 | const int32_t tex_width = 32; |
| 6008 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6009 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6010 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6011 | image_create_info.pNext = NULL; |
| 6012 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6013 | image_create_info.format = tex_format; |
| 6014 | image_create_info.extent.width = tex_width; |
| 6015 | image_create_info.extent.height = tex_height; |
| 6016 | image_create_info.extent.depth = 1; |
| 6017 | image_create_info.mipLevels = 1; |
| 6018 | image_create_info.arrayLayers = 1; |
| 6019 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6020 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6021 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6022 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6023 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 6024 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6026 | VkMemoryRequirements memReqs; |
| 6027 | VkDeviceMemory imageMem; |
| 6028 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6029 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6030 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6031 | memAlloc.pNext = NULL; |
| 6032 | memAlloc.allocationSize = 0; |
| 6033 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6034 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 6035 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6036 | pass = |
| 6037 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 6038 | ASSERT_TRUE(pass); |
| 6039 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 6040 | ASSERT_VK_SUCCESS(err); |
| 6041 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 6042 | ASSERT_VK_SUCCESS(err); |
| 6043 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6044 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6045 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 6046 | image_view_create_info.image = image; |
| 6047 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6048 | image_view_create_info.format = tex_format; |
| 6049 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6050 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6051 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6052 | image_view_create_info.subresourceRange.aspectMask = |
| 6053 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6054 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6055 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6056 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6057 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6058 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6059 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6060 | imageInfo[0].imageView = view; |
| 6061 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6062 | imageInfo[1].imageView = view; |
| 6063 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6064 | imageInfo[2].imageView = view; |
| 6065 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 6066 | imageInfo[3].imageView = view; |
| 6067 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6068 | |
| 6069 | static const uint32_t NUM_SET_UPDATES = 3; |
| 6070 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 6071 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6072 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 6073 | descriptor_write[0].dstBinding = 0; |
| 6074 | descriptor_write[0].descriptorCount = 5; |
| 6075 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6076 | descriptor_write[0].pBufferInfo = buffInfo; |
| 6077 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6078 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 6079 | descriptor_write[1].dstBinding = 0; |
| 6080 | descriptor_write[1].descriptorCount = 2; |
| 6081 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6082 | descriptor_write[1].pImageInfo = imageInfo; |
| 6083 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 6084 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 6085 | descriptor_write[2].dstBinding = 1; |
| 6086 | descriptor_write[2].descriptorCount = 2; |
| 6087 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6088 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6089 | |
| 6090 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6091 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6092 | // Create PSO to be used for draw-time errors below |
| 6093 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6094 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6095 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6096 | "out gl_PerVertex {\n" |
| 6097 | " vec4 gl_Position;\n" |
| 6098 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6099 | "void main(){\n" |
| 6100 | " gl_Position = vec4(1);\n" |
| 6101 | "}\n"; |
| 6102 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6103 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6104 | "\n" |
| 6105 | "layout(location=0) out vec4 x;\n" |
| 6106 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6107 | "void main(){\n" |
| 6108 | " x = vec4(bar.y);\n" |
| 6109 | "}\n"; |
| 6110 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6111 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6112 | VkPipelineObj pipe(m_device); |
| 6113 | pipe.AddShader(&vs); |
| 6114 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6115 | pipe.AddColorAttachment(); |
| 6116 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6117 | |
| 6118 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6120 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6121 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6122 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 6123 | // of PSO |
| 6124 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 6125 | // cmd_pipeline.c |
| 6126 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 6127 | // cmd_bind_graphics_pipeline() |
| 6128 | // TODO : Want to cause various binding incompatibility issues here to test |
| 6129 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6130 | // First cause various verify_layout_compatibility() fails |
| 6131 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6132 | // verify_set_layout_compatibility fail cases: |
| 6133 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6134 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6135 | " due to: invalid VkPipelineLayout "); |
| 6136 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6137 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6138 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 6139 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6140 | m_errorMonitor->VerifyFound(); |
| 6141 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6142 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6143 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6144 | " attempting to bind set to index 1"); |
| 6145 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6146 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 6147 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6148 | m_errorMonitor->VerifyFound(); |
| 6149 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6150 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6151 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 6152 | // descriptors |
| 6153 | m_errorMonitor->SetDesiredFailureMsg( |
| 6154 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6155 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | vkCmdBindDescriptorSets( |
| 6157 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6158 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6159 | m_errorMonitor->VerifyFound(); |
| 6160 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6161 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 6162 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6163 | m_errorMonitor->SetDesiredFailureMsg( |
| 6164 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6165 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6166 | vkCmdBindDescriptorSets( |
| 6167 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6168 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6169 | m_errorMonitor->VerifyFound(); |
| 6170 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6171 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 6172 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6173 | m_errorMonitor->SetDesiredFailureMsg( |
| 6174 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 6175 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6176 | vkCmdBindDescriptorSets( |
| 6177 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6178 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6179 | m_errorMonitor->VerifyFound(); |
| 6180 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6181 | // Cause INFO messages due to disturbing previously bound Sets |
| 6182 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6183 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6184 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6185 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6186 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6187 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6188 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | " previously bound as set #0 was disturbed "); |
| 6190 | vkCmdBindDescriptorSets( |
| 6191 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6192 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6193 | m_errorMonitor->VerifyFound(); |
| 6194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6196 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6197 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6198 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6199 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6200 | " newly bound as set #0 so set #1 and " |
| 6201 | "any subsequent sets were disturbed "); |
| 6202 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6203 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6204 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6205 | m_errorMonitor->VerifyFound(); |
| 6206 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6207 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6208 | // 1. Error due to not binding required set (we actually use same code as |
| 6209 | // above to disturb set0) |
| 6210 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6211 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6212 | 2, &descriptorSet[0], 0, NULL); |
| 6213 | vkCmdBindDescriptorSets( |
| 6214 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 6215 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 6216 | m_errorMonitor->SetDesiredFailureMsg( |
| 6217 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6218 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6219 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6220 | m_errorMonitor->VerifyFound(); |
| 6221 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 6222 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6223 | // 2. Error due to bound set not being compatible with PSO's |
| 6224 | // VkPipelineLayout (diff stageFlags in this case) |
| 6225 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 6226 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 6227 | 2, &descriptorSet[0], 0, NULL); |
| 6228 | m_errorMonitor->SetDesiredFailureMsg( |
| 6229 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6230 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 6231 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6232 | m_errorMonitor->VerifyFound(); |
| 6233 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6234 | // Remaining clean-up |
| 6235 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6236 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6237 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 6238 | } |
| 6239 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 6240 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 6241 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 6242 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6243 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6244 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6245 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 6246 | vkDestroyImage(m_device->device(), image, NULL); |
| 6247 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6248 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 6249 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6250 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6252 | m_errorMonitor->SetDesiredFailureMsg( |
| 6253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6254 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6255 | |
| 6256 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6257 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6258 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6259 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6260 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6261 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6262 | } |
| 6263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6264 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 6265 | VkResult err; |
| 6266 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6268 | m_errorMonitor->SetDesiredFailureMsg( |
| 6269 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 6270 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6271 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6273 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6274 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6275 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6276 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6277 | cmd.commandPool = m_commandPool; |
| 6278 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6279 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6280 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6281 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6282 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6283 | |
| 6284 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6285 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6286 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6287 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 6288 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6289 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 6290 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6291 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6292 | |
| 6293 | // The error should be caught by validation of the BeginCommandBuffer call |
| 6294 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 6295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6296 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6297 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 6298 | } |
| 6299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6300 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6301 | // Cause error due to Begin while recording CB |
| 6302 | // Then cause 2 errors for attempting to reset CB w/o having |
| 6303 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 6304 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6305 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6306 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6307 | |
| 6308 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6309 | |
| 6310 | // Calls AllocateCommandBuffers |
| 6311 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 6312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6313 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 6314 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6315 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6316 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6317 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6318 | cmd_buf_info.pNext = NULL; |
| 6319 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6320 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6321 | |
| 6322 | // Begin CB to transition to recording state |
| 6323 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 6324 | // Can't re-begin. This should trigger error |
| 6325 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6326 | m_errorMonitor->VerifyFound(); |
| 6327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6329 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6330 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 6331 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 6332 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6333 | m_errorMonitor->VerifyFound(); |
| 6334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6335 | m_errorMonitor->SetDesiredFailureMsg( |
| 6336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6337 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6338 | // Transition CB to RECORDED state |
| 6339 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 6340 | // Now attempting to Begin will implicitly reset, which triggers error |
| 6341 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6342 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 6343 | } |
| 6344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6345 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6346 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6347 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6349 | m_errorMonitor->SetDesiredFailureMsg( |
| 6350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6351 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 6352 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6354 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6355 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6356 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6357 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6358 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6359 | |
| 6360 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6361 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6362 | ds_pool_ci.pNext = NULL; |
| 6363 | ds_pool_ci.maxSets = 1; |
| 6364 | ds_pool_ci.poolSizeCount = 1; |
| 6365 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6366 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6367 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6368 | err = |
| 6369 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6370 | ASSERT_VK_SUCCESS(err); |
| 6371 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6372 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6373 | dsl_binding.binding = 0; |
| 6374 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6375 | dsl_binding.descriptorCount = 1; |
| 6376 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6377 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6378 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6379 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6380 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6381 | ds_layout_ci.pNext = NULL; |
| 6382 | ds_layout_ci.bindingCount = 1; |
| 6383 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6384 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6385 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6386 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6387 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6388 | ASSERT_VK_SUCCESS(err); |
| 6389 | |
| 6390 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6391 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6392 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6393 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6394 | alloc_info.descriptorPool = ds_pool; |
| 6395 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6396 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6397 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6398 | ASSERT_VK_SUCCESS(err); |
| 6399 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6400 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6401 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6402 | pipeline_layout_ci.setLayoutCount = 1; |
| 6403 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6404 | |
| 6405 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6406 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6407 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6408 | ASSERT_VK_SUCCESS(err); |
| 6409 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6410 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6412 | |
| 6413 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6414 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6415 | vp_state_ci.scissorCount = 1; |
| 6416 | vp_state_ci.pScissors = ≻ |
| 6417 | vp_state_ci.viewportCount = 1; |
| 6418 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6419 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6420 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6421 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6422 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6423 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6424 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6425 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6426 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6427 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6428 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6429 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6431 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6432 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6433 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6434 | gp_ci.layout = pipeline_layout; |
| 6435 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6436 | |
| 6437 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6438 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6439 | pc_ci.initialDataSize = 0; |
| 6440 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6441 | |
| 6442 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6443 | VkPipelineCache pipelineCache; |
| 6444 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6445 | err = |
| 6446 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6447 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6448 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6449 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6450 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6451 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6452 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6453 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6454 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6455 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6456 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6457 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6458 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 6459 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 6460 | { |
| 6461 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6462 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6463 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6464 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6465 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 6466 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6467 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6468 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6469 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6470 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6471 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6472 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6473 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6474 | |
| 6475 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6476 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6477 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6478 | ds_pool_ci.poolSizeCount = 1; |
| 6479 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6480 | |
| 6481 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6482 | err = vkCreateDescriptorPool(m_device->device(), |
| 6483 | 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] | 6484 | ASSERT_VK_SUCCESS(err); |
| 6485 | |
| 6486 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6487 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6488 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6489 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6490 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6491 | dsl_binding.pImmutableSamplers = NULL; |
| 6492 | |
| 6493 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6494 | ds_layout_ci.sType = |
| 6495 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6496 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6497 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6498 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6499 | |
| 6500 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6501 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6502 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6503 | ASSERT_VK_SUCCESS(err); |
| 6504 | |
| 6505 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6506 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 6507 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6508 | ASSERT_VK_SUCCESS(err); |
| 6509 | |
| 6510 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6511 | pipeline_layout_ci.sType = |
| 6512 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6513 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6514 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6515 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6516 | |
| 6517 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6518 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6519 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6520 | ASSERT_VK_SUCCESS(err); |
| 6521 | |
| 6522 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 6523 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6524 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6525 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 6526 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6527 | // 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] | 6528 | VkShaderObj |
| 6529 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 6530 | this); |
| 6531 | VkShaderObj |
| 6532 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 6533 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6535 | shaderStages[0].sType = |
| 6536 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6537 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6538 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6539 | shaderStages[1].sType = |
| 6540 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6541 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6542 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6543 | shaderStages[2].sType = |
| 6544 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6545 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6546 | shaderStages[2].shader = te.handle(); |
| 6547 | |
| 6548 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6549 | iaCI.sType = |
| 6550 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6551 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6552 | |
| 6553 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 6554 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 6555 | tsCI.patchControlPoints = 0; // This will cause an error |
| 6556 | |
| 6557 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6558 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6559 | gp_ci.pNext = NULL; |
| 6560 | gp_ci.stageCount = 3; |
| 6561 | gp_ci.pStages = shaderStages; |
| 6562 | gp_ci.pVertexInputState = NULL; |
| 6563 | gp_ci.pInputAssemblyState = &iaCI; |
| 6564 | gp_ci.pTessellationState = &tsCI; |
| 6565 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6566 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6567 | gp_ci.pMultisampleState = NULL; |
| 6568 | gp_ci.pDepthStencilState = NULL; |
| 6569 | gp_ci.pColorBlendState = NULL; |
| 6570 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6571 | gp_ci.layout = pipeline_layout; |
| 6572 | gp_ci.renderPass = renderPass(); |
| 6573 | |
| 6574 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6575 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6576 | pc_ci.pNext = NULL; |
| 6577 | pc_ci.initialSize = 0; |
| 6578 | pc_ci.initialData = 0; |
| 6579 | pc_ci.maxSize = 0; |
| 6580 | |
| 6581 | VkPipeline pipeline; |
| 6582 | VkPipelineCache pipelineCache; |
| 6583 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6584 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 6585 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6586 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6587 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6588 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6589 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6590 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6591 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6592 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6593 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6594 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6595 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6596 | } |
| 6597 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6598 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6599 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6600 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6602 | m_errorMonitor->SetDesiredFailureMsg( |
| 6603 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6604 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 6605 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6606 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6607 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6608 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6609 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6610 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6611 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6612 | |
| 6613 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6615 | ds_pool_ci.maxSets = 1; |
| 6616 | ds_pool_ci.poolSizeCount = 1; |
| 6617 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6618 | |
| 6619 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6620 | err = |
| 6621 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6622 | ASSERT_VK_SUCCESS(err); |
| 6623 | |
| 6624 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6625 | dsl_binding.binding = 0; |
| 6626 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6627 | dsl_binding.descriptorCount = 1; |
| 6628 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6629 | |
| 6630 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6631 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6632 | ds_layout_ci.bindingCount = 1; |
| 6633 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6634 | |
| 6635 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6636 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6637 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6638 | ASSERT_VK_SUCCESS(err); |
| 6639 | |
| 6640 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6641 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6642 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6643 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6644 | alloc_info.descriptorPool = ds_pool; |
| 6645 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6647 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6648 | ASSERT_VK_SUCCESS(err); |
| 6649 | |
| 6650 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6651 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6652 | pipeline_layout_ci.setLayoutCount = 1; |
| 6653 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6654 | |
| 6655 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6656 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6657 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6658 | ASSERT_VK_SUCCESS(err); |
| 6659 | |
| 6660 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6661 | |
| 6662 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6663 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6664 | vp_state_ci.scissorCount = 0; |
| 6665 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 6666 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6667 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6668 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6669 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6670 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6671 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6672 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6673 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6674 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6675 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6676 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6677 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6678 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6679 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6680 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6681 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6682 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6683 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6684 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6685 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6686 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6687 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6688 | |
| 6689 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6691 | gp_ci.stageCount = 2; |
| 6692 | gp_ci.pStages = shaderStages; |
| 6693 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6694 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6695 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6696 | gp_ci.layout = pipeline_layout; |
| 6697 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6698 | |
| 6699 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6700 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6701 | |
| 6702 | VkPipeline pipeline; |
| 6703 | VkPipelineCache pipelineCache; |
| 6704 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6705 | err = |
| 6706 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6707 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6708 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6709 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6711 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6712 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6713 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6714 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6715 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6716 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6717 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6718 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 6719 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6720 | // 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] | 6721 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6722 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6723 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6724 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | m_errorMonitor->SetDesiredFailureMsg( |
| 6726 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6727 | "Gfx Pipeline pViewportState is null. Even if "); |
| 6728 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6730 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6731 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6732 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6733 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6734 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6735 | |
| 6736 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6737 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6738 | ds_pool_ci.maxSets = 1; |
| 6739 | ds_pool_ci.poolSizeCount = 1; |
| 6740 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6741 | |
| 6742 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6743 | err = |
| 6744 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6745 | ASSERT_VK_SUCCESS(err); |
| 6746 | |
| 6747 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6748 | dsl_binding.binding = 0; |
| 6749 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6750 | dsl_binding.descriptorCount = 1; |
| 6751 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6752 | |
| 6753 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6754 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6755 | ds_layout_ci.bindingCount = 1; |
| 6756 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6757 | |
| 6758 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6760 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6761 | ASSERT_VK_SUCCESS(err); |
| 6762 | |
| 6763 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6764 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6765 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6766 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6767 | alloc_info.descriptorPool = ds_pool; |
| 6768 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6769 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6770 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6771 | ASSERT_VK_SUCCESS(err); |
| 6772 | |
| 6773 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6774 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6775 | pipeline_layout_ci.setLayoutCount = 1; |
| 6776 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6777 | |
| 6778 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6779 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6780 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6781 | ASSERT_VK_SUCCESS(err); |
| 6782 | |
| 6783 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6784 | // Set scissor as dynamic to avoid second error |
| 6785 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6786 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6787 | dyn_state_ci.dynamicStateCount = 1; |
| 6788 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6789 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6790 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6791 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6792 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6793 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6794 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6795 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6796 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6797 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6798 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6799 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6800 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6801 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6802 | |
| 6803 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6804 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6805 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6806 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6807 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6808 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6809 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6810 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6811 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6812 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6813 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6814 | gp_ci.stageCount = 2; |
| 6815 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6816 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6817 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6818 | // should cause validation error |
| 6819 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6820 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6821 | gp_ci.layout = pipeline_layout; |
| 6822 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6823 | |
| 6824 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6825 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6826 | |
| 6827 | VkPipeline pipeline; |
| 6828 | VkPipelineCache pipelineCache; |
| 6829 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | err = |
| 6831 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6832 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6834 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6835 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6836 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6837 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6838 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6839 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6840 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6841 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6842 | } |
| 6843 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6844 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6845 | // count |
| 6846 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6847 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6849 | m_errorMonitor->SetDesiredFailureMsg( |
| 6850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6851 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6852 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6854 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6855 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6856 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6857 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6858 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6859 | |
| 6860 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6861 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6862 | ds_pool_ci.maxSets = 1; |
| 6863 | ds_pool_ci.poolSizeCount = 1; |
| 6864 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6865 | |
| 6866 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6867 | err = |
| 6868 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6869 | ASSERT_VK_SUCCESS(err); |
| 6870 | |
| 6871 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6872 | dsl_binding.binding = 0; |
| 6873 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6874 | dsl_binding.descriptorCount = 1; |
| 6875 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6876 | |
| 6877 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6878 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6879 | ds_layout_ci.bindingCount = 1; |
| 6880 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6881 | |
| 6882 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6883 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6884 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6885 | ASSERT_VK_SUCCESS(err); |
| 6886 | |
| 6887 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6888 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6889 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6890 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6891 | alloc_info.descriptorPool = ds_pool; |
| 6892 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6893 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6894 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6895 | ASSERT_VK_SUCCESS(err); |
| 6896 | |
| 6897 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6898 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6899 | pipeline_layout_ci.setLayoutCount = 1; |
| 6900 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6901 | |
| 6902 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6903 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6904 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6905 | ASSERT_VK_SUCCESS(err); |
| 6906 | |
| 6907 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6908 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6909 | vp_state_ci.viewportCount = 1; |
| 6910 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6911 | vp_state_ci.scissorCount = 1; |
| 6912 | vp_state_ci.pScissors = |
| 6913 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6914 | |
| 6915 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6916 | // Set scissor as dynamic to avoid that error |
| 6917 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6918 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6919 | dyn_state_ci.dynamicStateCount = 1; |
| 6920 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6921 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6922 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6923 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6924 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6925 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6926 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6927 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6928 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6929 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6930 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6931 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6932 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6933 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6934 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6935 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6936 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6937 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6938 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6939 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6940 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6941 | |
| 6942 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6943 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6944 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6945 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6946 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6947 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6948 | rs_ci.pNext = nullptr; |
| 6949 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6950 | VkPipelineColorBlendAttachmentState att = {}; |
| 6951 | att.blendEnable = VK_FALSE; |
| 6952 | att.colorWriteMask = 0xf; |
| 6953 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6954 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6955 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6956 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6957 | cb_ci.attachmentCount = 1; |
| 6958 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6959 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6960 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6961 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6962 | gp_ci.stageCount = 2; |
| 6963 | gp_ci.pStages = shaderStages; |
| 6964 | gp_ci.pVertexInputState = &vi_ci; |
| 6965 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6966 | gp_ci.pViewportState = &vp_state_ci; |
| 6967 | gp_ci.pRasterizationState = &rs_ci; |
| 6968 | gp_ci.pColorBlendState = &cb_ci; |
| 6969 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6970 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6971 | gp_ci.layout = pipeline_layout; |
| 6972 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6973 | |
| 6974 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6975 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6976 | |
| 6977 | VkPipeline pipeline; |
| 6978 | VkPipelineCache pipelineCache; |
| 6979 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6980 | err = |
| 6981 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6982 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6983 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6984 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6985 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6986 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6987 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6988 | // 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] | 6989 | // First need to successfully create the PSO from above by setting |
| 6990 | // pViewports |
| 6991 | m_errorMonitor->SetDesiredFailureMsg( |
| 6992 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6993 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6994 | "scissorCount is 1. These counts must match."); |
| 6995 | |
| 6996 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6997 | vp_state_ci.pViewports = &vp; |
| 6998 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6999 | &gp_ci, NULL, &pipeline); |
| 7000 | ASSERT_VK_SUCCESS(err); |
| 7001 | BeginCommandBuffer(); |
| 7002 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7003 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7004 | VkRect2D scissors[2] = {}; // don't care about data |
| 7005 | // Count of 2 doesn't match PSO count of 1 |
| 7006 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 7007 | Draw(1, 0, 0, 0); |
| 7008 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7009 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7010 | |
| 7011 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7012 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7013 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7014 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7015 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7016 | } |
| 7017 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 7018 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 7019 | // viewportCount |
| 7020 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 7021 | VkResult err; |
| 7022 | |
| 7023 | m_errorMonitor->SetDesiredFailureMsg( |
| 7024 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7025 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 7026 | |
| 7027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7029 | |
| 7030 | VkDescriptorPoolSize ds_type_count = {}; |
| 7031 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7032 | ds_type_count.descriptorCount = 1; |
| 7033 | |
| 7034 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7035 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7036 | ds_pool_ci.maxSets = 1; |
| 7037 | ds_pool_ci.poolSizeCount = 1; |
| 7038 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7039 | |
| 7040 | VkDescriptorPool ds_pool; |
| 7041 | err = |
| 7042 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7043 | ASSERT_VK_SUCCESS(err); |
| 7044 | |
| 7045 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7046 | dsl_binding.binding = 0; |
| 7047 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7048 | dsl_binding.descriptorCount = 1; |
| 7049 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7050 | |
| 7051 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7052 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7053 | ds_layout_ci.bindingCount = 1; |
| 7054 | ds_layout_ci.pBindings = &dsl_binding; |
| 7055 | |
| 7056 | VkDescriptorSetLayout ds_layout; |
| 7057 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7058 | &ds_layout); |
| 7059 | ASSERT_VK_SUCCESS(err); |
| 7060 | |
| 7061 | VkDescriptorSet descriptorSet; |
| 7062 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7063 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7064 | alloc_info.descriptorSetCount = 1; |
| 7065 | alloc_info.descriptorPool = ds_pool; |
| 7066 | alloc_info.pSetLayouts = &ds_layout; |
| 7067 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7068 | &descriptorSet); |
| 7069 | ASSERT_VK_SUCCESS(err); |
| 7070 | |
| 7071 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7072 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7073 | pipeline_layout_ci.setLayoutCount = 1; |
| 7074 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7075 | |
| 7076 | VkPipelineLayout pipeline_layout; |
| 7077 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7078 | &pipeline_layout); |
| 7079 | ASSERT_VK_SUCCESS(err); |
| 7080 | |
| 7081 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7082 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7083 | vp_state_ci.scissorCount = 1; |
| 7084 | vp_state_ci.pScissors = |
| 7085 | NULL; // Null scissor w/ count of 1 should cause error |
| 7086 | vp_state_ci.viewportCount = 1; |
| 7087 | vp_state_ci.pViewports = |
| 7088 | NULL; // vp is dynamic (below) so this won't cause error |
| 7089 | |
| 7090 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 7091 | // Set scissor as dynamic to avoid that error |
| 7092 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7093 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7094 | dyn_state_ci.dynamicStateCount = 1; |
| 7095 | dyn_state_ci.pDynamicStates = &vp_state; |
| 7096 | |
| 7097 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7098 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7099 | |
| 7100 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7101 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7102 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7103 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7104 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7105 | // but add it to be able to run on more devices |
| 7106 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7107 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7108 | |
| 7109 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7110 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7111 | vi_ci.pNext = nullptr; |
| 7112 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7113 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7114 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7115 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7116 | |
| 7117 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7118 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7119 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7120 | |
| 7121 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7122 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7123 | rs_ci.pNext = nullptr; |
| 7124 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7125 | VkPipelineColorBlendAttachmentState att = {}; |
| 7126 | att.blendEnable = VK_FALSE; |
| 7127 | att.colorWriteMask = 0xf; |
| 7128 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7129 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7130 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7131 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7132 | cb_ci.attachmentCount = 1; |
| 7133 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7134 | |
| 7135 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7136 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7137 | gp_ci.stageCount = 2; |
| 7138 | gp_ci.pStages = shaderStages; |
| 7139 | gp_ci.pVertexInputState = &vi_ci; |
| 7140 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7141 | gp_ci.pViewportState = &vp_state_ci; |
| 7142 | gp_ci.pRasterizationState = &rs_ci; |
| 7143 | gp_ci.pColorBlendState = &cb_ci; |
| 7144 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7145 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7146 | gp_ci.layout = pipeline_layout; |
| 7147 | gp_ci.renderPass = renderPass(); |
| 7148 | |
| 7149 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7150 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7151 | |
| 7152 | VkPipeline pipeline; |
| 7153 | VkPipelineCache pipelineCache; |
| 7154 | |
| 7155 | err = |
| 7156 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7157 | ASSERT_VK_SUCCESS(err); |
| 7158 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7159 | &gp_ci, NULL, &pipeline); |
| 7160 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7161 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7162 | |
| 7163 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 7164 | // First need to successfully create the PSO from above by setting |
| 7165 | // pViewports |
| 7166 | m_errorMonitor->SetDesiredFailureMsg( |
| 7167 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7168 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 7169 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7170 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7171 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 7172 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7173 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7174 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7175 | ASSERT_VK_SUCCESS(err); |
| 7176 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7177 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7178 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7179 | VkViewport viewports[2] = {}; // don't care about data |
| 7180 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 7181 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7182 | Draw(1, 0, 0, 0); |
| 7183 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7184 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7185 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7186 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7187 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7188 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7189 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7190 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7191 | } |
| 7192 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7193 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 7194 | VkResult err; |
| 7195 | |
| 7196 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7197 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7198 | |
| 7199 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7200 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7201 | |
| 7202 | VkDescriptorPoolSize ds_type_count = {}; |
| 7203 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7204 | ds_type_count.descriptorCount = 1; |
| 7205 | |
| 7206 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7207 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7208 | ds_pool_ci.maxSets = 1; |
| 7209 | ds_pool_ci.poolSizeCount = 1; |
| 7210 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7211 | |
| 7212 | VkDescriptorPool ds_pool; |
| 7213 | err = |
| 7214 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7215 | ASSERT_VK_SUCCESS(err); |
| 7216 | |
| 7217 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7218 | dsl_binding.binding = 0; |
| 7219 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7220 | dsl_binding.descriptorCount = 1; |
| 7221 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7222 | |
| 7223 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7224 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7225 | ds_layout_ci.bindingCount = 1; |
| 7226 | ds_layout_ci.pBindings = &dsl_binding; |
| 7227 | |
| 7228 | VkDescriptorSetLayout ds_layout; |
| 7229 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7230 | &ds_layout); |
| 7231 | ASSERT_VK_SUCCESS(err); |
| 7232 | |
| 7233 | VkDescriptorSet descriptorSet; |
| 7234 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7235 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7236 | alloc_info.descriptorSetCount = 1; |
| 7237 | alloc_info.descriptorPool = ds_pool; |
| 7238 | alloc_info.pSetLayouts = &ds_layout; |
| 7239 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7240 | &descriptorSet); |
| 7241 | ASSERT_VK_SUCCESS(err); |
| 7242 | |
| 7243 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7244 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7245 | pipeline_layout_ci.setLayoutCount = 1; |
| 7246 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7247 | |
| 7248 | VkPipelineLayout pipeline_layout; |
| 7249 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7250 | &pipeline_layout); |
| 7251 | ASSERT_VK_SUCCESS(err); |
| 7252 | |
| 7253 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 7254 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 7255 | vp_state_ci.scissorCount = 1; |
| 7256 | vp_state_ci.pScissors = NULL; |
| 7257 | vp_state_ci.viewportCount = 1; |
| 7258 | vp_state_ci.pViewports = NULL; |
| 7259 | |
| 7260 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 7261 | VK_DYNAMIC_STATE_SCISSOR, |
| 7262 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 7263 | // Set scissor as dynamic to avoid that error |
| 7264 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 7265 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 7266 | dyn_state_ci.dynamicStateCount = 2; |
| 7267 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 7268 | |
| 7269 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 7270 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 7271 | |
| 7272 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7273 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7274 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7275 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 7276 | this); // TODO - We shouldn't need a fragment shader |
| 7277 | // but add it to be able to run on more devices |
| 7278 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 7279 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 7280 | |
| 7281 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 7282 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 7283 | vi_ci.pNext = nullptr; |
| 7284 | vi_ci.vertexBindingDescriptionCount = 0; |
| 7285 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 7286 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 7287 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 7288 | |
| 7289 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 7290 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 7291 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 7292 | |
| 7293 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 7294 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 7295 | rs_ci.pNext = nullptr; |
| 7296 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7297 | // Check too low (line width of -1.0f). |
| 7298 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7299 | |
| 7300 | VkPipelineColorBlendAttachmentState att = {}; |
| 7301 | att.blendEnable = VK_FALSE; |
| 7302 | att.colorWriteMask = 0xf; |
| 7303 | |
| 7304 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 7305 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 7306 | cb_ci.pNext = nullptr; |
| 7307 | cb_ci.attachmentCount = 1; |
| 7308 | cb_ci.pAttachments = &att; |
| 7309 | |
| 7310 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 7311 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 7312 | gp_ci.stageCount = 2; |
| 7313 | gp_ci.pStages = shaderStages; |
| 7314 | gp_ci.pVertexInputState = &vi_ci; |
| 7315 | gp_ci.pInputAssemblyState = &ia_ci; |
| 7316 | gp_ci.pViewportState = &vp_state_ci; |
| 7317 | gp_ci.pRasterizationState = &rs_ci; |
| 7318 | gp_ci.pColorBlendState = &cb_ci; |
| 7319 | gp_ci.pDynamicState = &dyn_state_ci; |
| 7320 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 7321 | gp_ci.layout = pipeline_layout; |
| 7322 | gp_ci.renderPass = renderPass(); |
| 7323 | |
| 7324 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 7325 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 7326 | |
| 7327 | VkPipeline pipeline; |
| 7328 | VkPipelineCache pipelineCache; |
| 7329 | |
| 7330 | err = |
| 7331 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7332 | ASSERT_VK_SUCCESS(err); |
| 7333 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7334 | &gp_ci, NULL, &pipeline); |
| 7335 | |
| 7336 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7337 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7338 | |
| 7339 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7340 | "Attempt to set lineWidth to 65536"); |
| 7341 | |
| 7342 | // Check too high (line width of 65536.0f). |
| 7343 | rs_ci.lineWidth = 65536.0f; |
| 7344 | |
| 7345 | err = |
| 7346 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7347 | ASSERT_VK_SUCCESS(err); |
| 7348 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7349 | &gp_ci, NULL, &pipeline); |
| 7350 | |
| 7351 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7352 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7353 | |
| 7354 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7355 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7356 | |
| 7357 | dyn_state_ci.dynamicStateCount = 3; |
| 7358 | |
| 7359 | rs_ci.lineWidth = 1.0f; |
| 7360 | |
| 7361 | err = |
| 7362 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 7363 | ASSERT_VK_SUCCESS(err); |
| 7364 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 7365 | &gp_ci, NULL, &pipeline); |
| 7366 | BeginCommandBuffer(); |
| 7367 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7368 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7369 | |
| 7370 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7371 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7372 | m_errorMonitor->VerifyFound(); |
| 7373 | |
| 7374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7375 | "Attempt to set lineWidth to 65536"); |
| 7376 | |
| 7377 | // Check too high with dynamic setting. |
| 7378 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 7379 | m_errorMonitor->VerifyFound(); |
| 7380 | EndCommandBuffer(); |
| 7381 | |
| 7382 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7383 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7384 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7385 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7386 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7387 | } |
| 7388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7389 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7390 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7391 | m_errorMonitor->SetDesiredFailureMsg( |
| 7392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7393 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7394 | |
| 7395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7396 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7397 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7398 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7399 | // Don't care about RenderPass handle b/c error should be flagged before |
| 7400 | // that |
| 7401 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 7402 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7403 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7404 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7405 | } |
| 7406 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7407 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7408 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7409 | m_errorMonitor->SetDesiredFailureMsg( |
| 7410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7411 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7412 | |
| 7413 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7414 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7415 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7416 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7417 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 7418 | // proper error |
Chris Forbes | 38ae7c4 | 2016-06-21 20:51:44 +1200 | [diff] [blame] | 7419 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7420 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7422 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7423 | } |
| 7424 | |
Chris Forbes | 2eeabe3 | 2016-06-21 20:52:34 +1200 | [diff] [blame] | 7425 | TEST_F(VkLayerTest, RenderPassSecondaryCommandBuffersMultipleTimes) { |
| 7426 | m_errorMonitor->ExpectSuccess(); |
| 7427 | |
| 7428 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7429 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7430 | |
| 7431 | BeginCommandBuffer(); // framework implicitly begins the renderpass. |
| 7432 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); // end implicit. |
| 7433 | |
| 7434 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 7435 | VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 7436 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7437 | m_errorMonitor->VerifyNotFound(); |
| 7438 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
| 7439 | VK_SUBPASS_CONTENTS_INLINE); |
| 7440 | m_errorMonitor->VerifyNotFound(); |
| 7441 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7442 | m_errorMonitor->VerifyNotFound(); |
| 7443 | |
| 7444 | m_commandBuffer->EndCommandBuffer(); |
| 7445 | m_errorMonitor->VerifyNotFound(); |
| 7446 | } |
| 7447 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7448 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 7449 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 7450 | "the number of renderPass attachments that use loadOp" |
| 7451 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 7452 | |
| 7453 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7454 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7455 | |
| 7456 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 7457 | VkAttachmentReference attach = {}; |
| 7458 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7459 | VkSubpassDescription subpass = {}; |
| 7460 | subpass.inputAttachmentCount = 1; |
| 7461 | subpass.pInputAttachments = &attach; |
| 7462 | VkRenderPassCreateInfo rpci = {}; |
| 7463 | rpci.subpassCount = 1; |
| 7464 | rpci.pSubpasses = &subpass; |
| 7465 | rpci.attachmentCount = 1; |
| 7466 | VkAttachmentDescription attach_desc = {}; |
| 7467 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7468 | // Set loadOp to CLEAR |
| 7469 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 7470 | rpci.pAttachments = &attach_desc; |
| 7471 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 7472 | VkRenderPass rp; |
| 7473 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7474 | |
| 7475 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 7476 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 7477 | hinfo.renderPass = VK_NULL_HANDLE; |
| 7478 | hinfo.subpass = 0; |
| 7479 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 7480 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 7481 | hinfo.queryFlags = 0; |
| 7482 | hinfo.pipelineStatistics = 0; |
| 7483 | VkCommandBufferBeginInfo info = {}; |
| 7484 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 7485 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 7486 | info.pInheritanceInfo = &hinfo; |
| 7487 | |
| 7488 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 7489 | VkRenderPassBeginInfo rp_begin = {}; |
| 7490 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 7491 | rp_begin.pNext = NULL; |
| 7492 | rp_begin.renderPass = renderPass(); |
| 7493 | rp_begin.framebuffer = framebuffer(); |
| 7494 | rp_begin.clearValueCount = 0; // Should be 1 |
| 7495 | |
| 7496 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7497 | " has a clearValueCount of 0 but the " |
| 7498 | "actual number of attachments in " |
| 7499 | "renderPass "); |
| 7500 | |
| 7501 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 7502 | VK_SUBPASS_CONTENTS_INLINE); |
| 7503 | |
| 7504 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 7505 | |
| 7506 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7507 | } |
| 7508 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 7509 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 7510 | |
| 7511 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 7512 | |
| 7513 | m_errorMonitor->SetDesiredFailureMsg( |
| 7514 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7515 | "It is invalid to issue this call inside an active render pass"); |
| 7516 | |
| 7517 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7518 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7519 | |
| 7520 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 7521 | BeginCommandBuffer(); |
| 7522 | |
| 7523 | // Call directly into vkEndCommandBuffer instead of the |
| 7524 | // the framework's EndCommandBuffer, which inserts a |
| 7525 | // vkEndRenderPass |
| 7526 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 7527 | |
| 7528 | m_errorMonitor->VerifyFound(); |
| 7529 | |
| 7530 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 7531 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 7532 | } |
| 7533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7534 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7535 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7536 | m_errorMonitor->SetDesiredFailureMsg( |
| 7537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7538 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7539 | |
| 7540 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7541 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7542 | |
| 7543 | // Renderpass is started here |
| 7544 | BeginCommandBuffer(); |
| 7545 | |
| 7546 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7547 | vk_testing::Buffer dstBuffer; |
| 7548 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7549 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7550 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7551 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7552 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7553 | } |
| 7554 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7555 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7556 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7557 | m_errorMonitor->SetDesiredFailureMsg( |
| 7558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7559 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7560 | |
| 7561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7562 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7563 | |
| 7564 | // Renderpass is started here |
| 7565 | BeginCommandBuffer(); |
| 7566 | |
| 7567 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7568 | vk_testing::Buffer dstBuffer; |
| 7569 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7571 | VkDeviceSize dstOffset = 0; |
| 7572 | VkDeviceSize dataSize = 1024; |
| 7573 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7574 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7575 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 7576 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7577 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7578 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7579 | } |
| 7580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7581 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7582 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7583 | m_errorMonitor->SetDesiredFailureMsg( |
| 7584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7585 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7586 | |
| 7587 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7588 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7589 | |
| 7590 | // Renderpass is started here |
| 7591 | BeginCommandBuffer(); |
| 7592 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 7593 | VkClearColorValue clear_color; |
| 7594 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7595 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7596 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7597 | const int32_t tex_width = 32; |
| 7598 | const int32_t tex_height = 32; |
| 7599 | VkImageCreateInfo image_create_info = {}; |
| 7600 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7601 | image_create_info.pNext = NULL; |
| 7602 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7603 | image_create_info.format = tex_format; |
| 7604 | image_create_info.extent.width = tex_width; |
| 7605 | image_create_info.extent.height = tex_height; |
| 7606 | image_create_info.extent.depth = 1; |
| 7607 | image_create_info.mipLevels = 1; |
| 7608 | image_create_info.arrayLayers = 1; |
| 7609 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7610 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7611 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7612 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7613 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7614 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7615 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7617 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7618 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7619 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7620 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7621 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7623 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7624 | } |
| 7625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7626 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7627 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7628 | m_errorMonitor->SetDesiredFailureMsg( |
| 7629 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7630 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7631 | |
| 7632 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7633 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7634 | |
| 7635 | // Renderpass is started here |
| 7636 | BeginCommandBuffer(); |
| 7637 | |
| 7638 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 7639 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7640 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 7641 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7642 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 7643 | image_create_info.extent.width = 64; |
| 7644 | image_create_info.extent.height = 64; |
| 7645 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7646 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7647 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7648 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7649 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7650 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7652 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7653 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7655 | vkCmdClearDepthStencilImage( |
| 7656 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7657 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 7658 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7659 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7660 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7661 | } |
| 7662 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7663 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7664 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7665 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7666 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7667 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7668 | "vkCmdClearAttachments: This call " |
| 7669 | "must be issued inside an active " |
| 7670 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7671 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7673 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7674 | |
| 7675 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7676 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7677 | ASSERT_VK_SUCCESS(err); |
| 7678 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7679 | VkClearAttachment color_attachment; |
| 7680 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7681 | color_attachment.clearValue.color.float32[0] = 0; |
| 7682 | color_attachment.clearValue.color.float32[1] = 0; |
| 7683 | color_attachment.clearValue.color.float32[2] = 0; |
| 7684 | color_attachment.clearValue.color.float32[3] = 0; |
| 7685 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7686 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 7687 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7688 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7689 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7690 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7691 | } |
| 7692 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 7693 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 7694 | // Try to add a buffer memory barrier with no buffer. |
| 7695 | m_errorMonitor->SetDesiredFailureMsg( |
| 7696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7697 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 7698 | |
| 7699 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7700 | BeginCommandBuffer(); |
| 7701 | |
| 7702 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7703 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7704 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7705 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7706 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7707 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7708 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 7709 | buf_barrier.offset = 0; |
| 7710 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7711 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7712 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 7713 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 7714 | |
| 7715 | m_errorMonitor->VerifyFound(); |
| 7716 | } |
| 7717 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 7718 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 7719 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 7720 | |
| 7721 | m_errorMonitor->SetDesiredFailureMsg( |
| 7722 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 7723 | |
| 7724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7725 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7726 | |
| 7727 | VkMemoryBarrier mem_barrier = {}; |
| 7728 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 7729 | mem_barrier.pNext = NULL; |
| 7730 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7731 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7732 | BeginCommandBuffer(); |
| 7733 | // BeginCommandBuffer() starts a render pass |
| 7734 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7735 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7736 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 7737 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 7738 | m_errorMonitor->VerifyFound(); |
| 7739 | |
| 7740 | m_errorMonitor->SetDesiredFailureMsg( |
| 7741 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7742 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 7743 | VkImageObj image(m_device); |
| 7744 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 7745 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 7746 | ASSERT_TRUE(image.initialized()); |
| 7747 | VkImageMemoryBarrier img_barrier = {}; |
| 7748 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 7749 | img_barrier.pNext = NULL; |
| 7750 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7751 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7752 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7753 | // New layout can't be UNDEFINED |
| 7754 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 7755 | img_barrier.image = image.handle(); |
| 7756 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7757 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7758 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7759 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7760 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7761 | img_barrier.subresourceRange.layerCount = 1; |
| 7762 | img_barrier.subresourceRange.levelCount = 1; |
| 7763 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7764 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7765 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7766 | nullptr, 1, &img_barrier); |
| 7767 | m_errorMonitor->VerifyFound(); |
| 7768 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7769 | |
| 7770 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7771 | "Subresource must have the sum of the " |
| 7772 | "baseArrayLayer"); |
| 7773 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 7774 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 7775 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7776 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7777 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7778 | nullptr, 1, &img_barrier); |
| 7779 | m_errorMonitor->VerifyFound(); |
| 7780 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7781 | |
| 7782 | m_errorMonitor->SetDesiredFailureMsg( |
| 7783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7784 | "Subresource must have the sum of the baseMipLevel"); |
| 7785 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 7786 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 7787 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7788 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7789 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7790 | nullptr, 1, &img_barrier); |
| 7791 | m_errorMonitor->VerifyFound(); |
| 7792 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7793 | |
| 7794 | m_errorMonitor->SetDesiredFailureMsg( |
| 7795 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7796 | "Buffer Barriers cannot be used during a render pass"); |
| 7797 | vk_testing::Buffer buffer; |
| 7798 | buffer.init(*m_device, 256); |
| 7799 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7800 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7801 | buf_barrier.pNext = NULL; |
| 7802 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7803 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7804 | buf_barrier.buffer = buffer.handle(); |
| 7805 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7806 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7807 | buf_barrier.offset = 0; |
| 7808 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7809 | // Can't send buffer barrier during a render pass |
| 7810 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7811 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7812 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7813 | &buf_barrier, 0, nullptr); |
| 7814 | m_errorMonitor->VerifyFound(); |
| 7815 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7816 | |
| 7817 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7818 | "which is not less than total size"); |
| 7819 | buf_barrier.offset = 257; |
| 7820 | // Offset greater than total size |
| 7821 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7822 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7823 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7824 | &buf_barrier, 0, nullptr); |
| 7825 | m_errorMonitor->VerifyFound(); |
| 7826 | buf_barrier.offset = 0; |
| 7827 | |
| 7828 | m_errorMonitor->SetDesiredFailureMsg( |
| 7829 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 7830 | buf_barrier.size = 257; |
| 7831 | // Size greater than total size |
| 7832 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7833 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7834 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7835 | &buf_barrier, 0, nullptr); |
| 7836 | m_errorMonitor->VerifyFound(); |
| 7837 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7838 | |
| 7839 | m_errorMonitor->SetDesiredFailureMsg( |
| 7840 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7841 | "Image is a depth and stencil format and thus must " |
| 7842 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7843 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7844 | VkDepthStencilObj ds_image(m_device); |
| 7845 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7846 | ASSERT_TRUE(ds_image.initialized()); |
| 7847 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7848 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7849 | img_barrier.image = ds_image.handle(); |
| 7850 | // Leave aspectMask at COLOR on purpose |
| 7851 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7852 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7853 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7854 | nullptr, 1, &img_barrier); |
| 7855 | m_errorMonitor->VerifyFound(); |
| 7856 | } |
| 7857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7858 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7859 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7860 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7862 | m_errorMonitor->SetDesiredFailureMsg( |
| 7863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7864 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7865 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7866 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7867 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7868 | uint32_t qfi = 0; |
| 7869 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7870 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7871 | buffCI.size = 1024; |
| 7872 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7873 | buffCI.queueFamilyIndexCount = 1; |
| 7874 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7875 | |
| 7876 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7877 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7878 | ASSERT_VK_SUCCESS(err); |
| 7879 | |
| 7880 | BeginCommandBuffer(); |
| 7881 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7882 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7883 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7884 | // 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] | 7885 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7886 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7887 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7888 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7889 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7890 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7891 | } |
| 7892 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7893 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7894 | // Create an out-of-range queueFamilyIndex |
| 7895 | m_errorMonitor->SetDesiredFailureMsg( |
| 7896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7897 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7898 | "of the indices specified when the device was created, via the " |
| 7899 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7900 | |
| 7901 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7902 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7903 | VkBufferCreateInfo buffCI = {}; |
| 7904 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7905 | buffCI.size = 1024; |
| 7906 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7907 | buffCI.queueFamilyIndexCount = 1; |
| 7908 | // Introduce failure by specifying invalid queue_family_index |
| 7909 | uint32_t qfi = 777; |
| 7910 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7911 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7912 | |
| 7913 | VkBuffer ib; |
| 7914 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7916 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7917 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7918 | } |
| 7919 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7920 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7921 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7922 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7923 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7924 | m_errorMonitor->SetDesiredFailureMsg( |
| 7925 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7926 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7927 | |
| 7928 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7929 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7930 | |
| 7931 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7932 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7933 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7934 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7935 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7936 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7937 | } |
| 7938 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7939 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7940 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7941 | "that do not have correct usage bits sets."); |
| 7942 | VkResult err; |
| 7943 | |
| 7944 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7945 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7946 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7947 | ds_type_count[i].type = VkDescriptorType(i); |
| 7948 | ds_type_count[i].descriptorCount = 1; |
| 7949 | } |
| 7950 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7951 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7952 | ds_pool_ci.pNext = NULL; |
| 7953 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7954 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7955 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7956 | |
| 7957 | VkDescriptorPool ds_pool; |
| 7958 | err = |
| 7959 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7960 | ASSERT_VK_SUCCESS(err); |
| 7961 | |
| 7962 | // Create 10 layouts where each has a single descriptor of different type |
| 7963 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7964 | {}; |
| 7965 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7966 | dsl_binding[i].binding = 0; |
| 7967 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7968 | dsl_binding[i].descriptorCount = 1; |
| 7969 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7970 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7971 | } |
| 7972 | |
| 7973 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7974 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7975 | ds_layout_ci.pNext = NULL; |
| 7976 | ds_layout_ci.bindingCount = 1; |
| 7977 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7978 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7979 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7980 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7981 | NULL, ds_layouts + i); |
| 7982 | ASSERT_VK_SUCCESS(err); |
| 7983 | } |
| 7984 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7985 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7986 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7987 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7988 | alloc_info.descriptorPool = ds_pool; |
| 7989 | alloc_info.pSetLayouts = ds_layouts; |
| 7990 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7991 | descriptor_sets); |
| 7992 | ASSERT_VK_SUCCESS(err); |
| 7993 | |
| 7994 | // Create a buffer & bufferView to be used for invalid updates |
| 7995 | VkBufferCreateInfo buff_ci = {}; |
| 7996 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7997 | // This usage is not valid for any descriptor type |
| 7998 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7999 | buff_ci.size = 256; |
| 8000 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8001 | VkBuffer buffer; |
| 8002 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 8003 | ASSERT_VK_SUCCESS(err); |
| 8004 | |
| 8005 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 8006 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 8007 | buff_view_ci.buffer = buffer; |
| 8008 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 8009 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 8010 | VkBufferView buff_view; |
| 8011 | err = |
| 8012 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 8013 | ASSERT_VK_SUCCESS(err); |
| 8014 | |
| 8015 | // Create an image to be used for invalid updates |
| 8016 | VkImageCreateInfo image_ci = {}; |
| 8017 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8018 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8019 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8020 | image_ci.extent.width = 64; |
| 8021 | image_ci.extent.height = 64; |
| 8022 | image_ci.extent.depth = 1; |
| 8023 | image_ci.mipLevels = 1; |
| 8024 | image_ci.arrayLayers = 1; |
| 8025 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8026 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8027 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8028 | // This usage is not valid for any descriptor type |
| 8029 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8030 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8031 | VkImage image; |
| 8032 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8033 | ASSERT_VK_SUCCESS(err); |
| 8034 | // Bind memory to image |
| 8035 | VkMemoryRequirements mem_reqs; |
| 8036 | VkDeviceMemory image_mem; |
| 8037 | bool pass; |
| 8038 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8039 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8040 | mem_alloc.pNext = NULL; |
| 8041 | mem_alloc.allocationSize = 0; |
| 8042 | mem_alloc.memoryTypeIndex = 0; |
| 8043 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8044 | mem_alloc.allocationSize = mem_reqs.size; |
| 8045 | pass = |
| 8046 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8047 | ASSERT_TRUE(pass); |
| 8048 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8049 | ASSERT_VK_SUCCESS(err); |
| 8050 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8051 | ASSERT_VK_SUCCESS(err); |
| 8052 | // Now create view for image |
| 8053 | VkImageViewCreateInfo image_view_ci = {}; |
| 8054 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8055 | image_view_ci.image = image; |
| 8056 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8057 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8058 | image_view_ci.subresourceRange.layerCount = 1; |
| 8059 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8060 | image_view_ci.subresourceRange.levelCount = 1; |
| 8061 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8062 | VkImageView image_view; |
| 8063 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8064 | &image_view); |
| 8065 | ASSERT_VK_SUCCESS(err); |
| 8066 | |
| 8067 | VkDescriptorBufferInfo buff_info = {}; |
| 8068 | buff_info.buffer = buffer; |
| 8069 | VkDescriptorImageInfo img_info = {}; |
| 8070 | img_info.imageView = image_view; |
| 8071 | VkWriteDescriptorSet descriptor_write = {}; |
| 8072 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8073 | descriptor_write.dstBinding = 0; |
| 8074 | descriptor_write.descriptorCount = 1; |
| 8075 | descriptor_write.pTexelBufferView = &buff_view; |
| 8076 | descriptor_write.pBufferInfo = &buff_info; |
| 8077 | descriptor_write.pImageInfo = &img_info; |
| 8078 | |
| 8079 | // These error messages align with VkDescriptorType struct |
| 8080 | const char *error_msgs[] = { |
| 8081 | "", // placeholder, no error for SAMPLER descriptor |
| 8082 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8083 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 8084 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 8085 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 8086 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 8087 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8088 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8089 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 8090 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 8091 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 8092 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 8093 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 8094 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 8095 | descriptor_write.dstSet = descriptor_sets[i]; |
| 8096 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8097 | error_msgs[i]); |
| 8098 | |
| 8099 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 8100 | NULL); |
| 8101 | |
| 8102 | m_errorMonitor->VerifyFound(); |
| 8103 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 8104 | } |
| 8105 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 8106 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8107 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 8108 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8109 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 8110 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 8111 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 8112 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 8113 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8114 | } |
| 8115 | |
Tobin Ehlis | 2fc296b | 2016-06-15 14:05:27 -0600 | [diff] [blame] | 8116 | TEST_F(VkLayerTest, DSAspectBitsErrors) { |
| 8117 | // TODO : Initially only catching case where DEPTH & STENCIL aspect bits |
| 8118 | // are set, but could expand this test to hit more cases. |
| 8119 | TEST_DESCRIPTION("Attempt to update descriptor sets for images " |
| 8120 | "that do not have correct aspect bits sets."); |
| 8121 | VkResult err; |
| 8122 | |
| 8123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8124 | VkDescriptorPoolSize ds_type_count = {}; |
| 8125 | ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8126 | ds_type_count.descriptorCount = 1; |
| 8127 | |
| 8128 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8129 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8130 | ds_pool_ci.pNext = NULL; |
| 8131 | ds_pool_ci.maxSets = 5; |
| 8132 | ds_pool_ci.poolSizeCount = 1; |
| 8133 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8134 | |
| 8135 | VkDescriptorPool ds_pool; |
| 8136 | err = |
| 8137 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8138 | ASSERT_VK_SUCCESS(err); |
| 8139 | |
| 8140 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8141 | dsl_binding.binding = 0; |
| 8142 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8143 | dsl_binding.descriptorCount = 1; |
| 8144 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8145 | dsl_binding.pImmutableSamplers = NULL; |
| 8146 | |
| 8147 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8148 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8149 | ds_layout_ci.pNext = NULL; |
| 8150 | ds_layout_ci.bindingCount = 1; |
| 8151 | ds_layout_ci.pBindings = &dsl_binding; |
| 8152 | VkDescriptorSetLayout ds_layout; |
| 8153 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8154 | &ds_layout); |
| 8155 | ASSERT_VK_SUCCESS(err); |
| 8156 | |
| 8157 | VkDescriptorSet descriptor_set = {}; |
| 8158 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8159 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8160 | alloc_info.descriptorSetCount = 1; |
| 8161 | alloc_info.descriptorPool = ds_pool; |
| 8162 | alloc_info.pSetLayouts = &ds_layout; |
| 8163 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8164 | &descriptor_set); |
| 8165 | ASSERT_VK_SUCCESS(err); |
| 8166 | |
| 8167 | // Create an image to be used for invalid updates |
| 8168 | VkImageCreateInfo image_ci = {}; |
| 8169 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8170 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 8171 | image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8172 | image_ci.extent.width = 64; |
| 8173 | image_ci.extent.height = 64; |
| 8174 | image_ci.extent.depth = 1; |
| 8175 | image_ci.mipLevels = 1; |
| 8176 | image_ci.arrayLayers = 1; |
| 8177 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8178 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 8179 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 8180 | image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8181 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 8182 | VkImage image; |
| 8183 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 8184 | ASSERT_VK_SUCCESS(err); |
| 8185 | // Bind memory to image |
| 8186 | VkMemoryRequirements mem_reqs; |
| 8187 | VkDeviceMemory image_mem; |
| 8188 | bool pass; |
| 8189 | VkMemoryAllocateInfo mem_alloc = {}; |
| 8190 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8191 | mem_alloc.pNext = NULL; |
| 8192 | mem_alloc.allocationSize = 0; |
| 8193 | mem_alloc.memoryTypeIndex = 0; |
| 8194 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 8195 | mem_alloc.allocationSize = mem_reqs.size; |
| 8196 | pass = |
| 8197 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 8198 | ASSERT_TRUE(pass); |
| 8199 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 8200 | ASSERT_VK_SUCCESS(err); |
| 8201 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 8202 | ASSERT_VK_SUCCESS(err); |
| 8203 | // Now create view for image |
| 8204 | VkImageViewCreateInfo image_view_ci = {}; |
| 8205 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8206 | image_view_ci.image = image; |
| 8207 | image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8208 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8209 | image_view_ci.subresourceRange.layerCount = 1; |
| 8210 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 8211 | image_view_ci.subresourceRange.levelCount = 1; |
| 8212 | // Setting both depth & stencil aspect bits is illegal for descriptor |
| 8213 | image_view_ci.subresourceRange.aspectMask = |
| 8214 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 8215 | |
| 8216 | VkImageView image_view; |
| 8217 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 8218 | &image_view); |
| 8219 | ASSERT_VK_SUCCESS(err); |
| 8220 | |
| 8221 | VkDescriptorImageInfo img_info = {}; |
| 8222 | img_info.imageView = image_view; |
| 8223 | VkWriteDescriptorSet descriptor_write = {}; |
| 8224 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 8225 | descriptor_write.dstBinding = 0; |
| 8226 | descriptor_write.descriptorCount = 1; |
| 8227 | descriptor_write.pTexelBufferView = NULL; |
| 8228 | descriptor_write.pBufferInfo = NULL; |
| 8229 | descriptor_write.pImageInfo = &img_info; |
| 8230 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 8231 | descriptor_write.dstSet = descriptor_set; |
| 8232 | const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT " |
| 8233 | "or VK_IMAGE_ASPECT_STENCIL_BIT "; |
| 8234 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8235 | error_msg); |
| 8236 | |
| 8237 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8238 | |
| 8239 | m_errorMonitor->VerifyFound(); |
| 8240 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8241 | vkDestroyImage(m_device->device(), image, NULL); |
| 8242 | vkFreeMemory(m_device->device(), image_mem, NULL); |
| 8243 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 8244 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); |
| 8245 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8246 | } |
| 8247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8248 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8249 | // 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] | 8250 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8252 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8254 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 8255 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8256 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8258 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8259 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8261 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8262 | |
| 8263 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8264 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8265 | ds_pool_ci.pNext = NULL; |
| 8266 | ds_pool_ci.maxSets = 1; |
| 8267 | ds_pool_ci.poolSizeCount = 1; |
| 8268 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8269 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8270 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8271 | err = |
| 8272 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8273 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8274 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8275 | dsl_binding.binding = 0; |
| 8276 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8277 | dsl_binding.descriptorCount = 1; |
| 8278 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8279 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8280 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8281 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8282 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8283 | ds_layout_ci.pNext = NULL; |
| 8284 | ds_layout_ci.bindingCount = 1; |
| 8285 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8286 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8287 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8288 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8289 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8290 | ASSERT_VK_SUCCESS(err); |
| 8291 | |
| 8292 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8293 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8294 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8295 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8296 | alloc_info.descriptorPool = ds_pool; |
| 8297 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8298 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8299 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8300 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8301 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 8302 | VkSamplerCreateInfo sampler_ci = {}; |
| 8303 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8304 | sampler_ci.pNext = NULL; |
| 8305 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8306 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8307 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8308 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8309 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8310 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8311 | sampler_ci.mipLodBias = 1.0; |
| 8312 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8313 | sampler_ci.maxAnisotropy = 1; |
| 8314 | sampler_ci.compareEnable = VK_FALSE; |
| 8315 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8316 | sampler_ci.minLod = 1.0; |
| 8317 | sampler_ci.maxLod = 1.0; |
| 8318 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8319 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 8320 | VkSampler sampler; |
| 8321 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 8322 | ASSERT_VK_SUCCESS(err); |
| 8323 | |
| 8324 | VkDescriptorImageInfo info = {}; |
| 8325 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8326 | |
| 8327 | VkWriteDescriptorSet descriptor_write; |
| 8328 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8329 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8330 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8331 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8332 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8333 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8334 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8335 | |
| 8336 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8338 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8339 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8340 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8341 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8342 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8343 | } |
| 8344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8346 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8347 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8351 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 8352 | "starting at binding offset of 0 combined with update array element " |
| 8353 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8354 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8355 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8356 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8357 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8358 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8359 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8360 | |
| 8361 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8363 | ds_pool_ci.pNext = NULL; |
| 8364 | ds_pool_ci.maxSets = 1; |
| 8365 | ds_pool_ci.poolSizeCount = 1; |
| 8366 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8367 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8368 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8369 | err = |
| 8370 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8371 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8372 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8373 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8374 | dsl_binding.binding = 0; |
| 8375 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8376 | dsl_binding.descriptorCount = 1; |
| 8377 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8378 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8379 | |
| 8380 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8381 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8382 | ds_layout_ci.pNext = NULL; |
| 8383 | ds_layout_ci.bindingCount = 1; |
| 8384 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8385 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8386 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8387 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8388 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8389 | ASSERT_VK_SUCCESS(err); |
| 8390 | |
| 8391 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8392 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8393 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8394 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8395 | alloc_info.descriptorPool = ds_pool; |
| 8396 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8397 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8398 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8399 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8400 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 8401 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 8402 | VkDescriptorBufferInfo buff_info = {}; |
| 8403 | buff_info.buffer = |
| 8404 | VkBuffer(0); // Don't care about buffer handle for this test |
| 8405 | buff_info.offset = 0; |
| 8406 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8407 | |
| 8408 | VkWriteDescriptorSet descriptor_write; |
| 8409 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8410 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8411 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8412 | descriptor_write.dstArrayElement = |
| 8413 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8414 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8415 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8416 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8417 | |
| 8418 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8419 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8420 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8421 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8422 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8423 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8424 | } |
| 8425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8426 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 8427 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 8428 | // index 2 |
| 8429 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8430 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8431 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8432 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8433 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8435 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8436 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8437 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8438 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8439 | |
| 8440 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8441 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8442 | ds_pool_ci.pNext = NULL; |
| 8443 | ds_pool_ci.maxSets = 1; |
| 8444 | ds_pool_ci.poolSizeCount = 1; |
| 8445 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8446 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8447 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8448 | err = |
| 8449 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8450 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8451 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8452 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8453 | dsl_binding.binding = 0; |
| 8454 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8455 | dsl_binding.descriptorCount = 1; |
| 8456 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8457 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8458 | |
| 8459 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8460 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8461 | ds_layout_ci.pNext = NULL; |
| 8462 | ds_layout_ci.bindingCount = 1; |
| 8463 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8464 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8465 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8466 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8467 | ASSERT_VK_SUCCESS(err); |
| 8468 | |
| 8469 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8470 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8471 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8472 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8473 | alloc_info.descriptorPool = ds_pool; |
| 8474 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8475 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8476 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8477 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8478 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8479 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8480 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8481 | sampler_ci.pNext = NULL; |
| 8482 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8483 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8484 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8485 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8486 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8487 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8488 | sampler_ci.mipLodBias = 1.0; |
| 8489 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8490 | sampler_ci.maxAnisotropy = 1; |
| 8491 | sampler_ci.compareEnable = VK_FALSE; |
| 8492 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8493 | sampler_ci.minLod = 1.0; |
| 8494 | sampler_ci.maxLod = 1.0; |
| 8495 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8496 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8497 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8498 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8499 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8500 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8501 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8502 | VkDescriptorImageInfo info = {}; |
| 8503 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8504 | |
| 8505 | VkWriteDescriptorSet descriptor_write; |
| 8506 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8507 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8508 | descriptor_write.dstSet = descriptorSet; |
| 8509 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8510 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8511 | // 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] | 8512 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8513 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8514 | |
| 8515 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8516 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8517 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8518 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8519 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8520 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8521 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8522 | } |
| 8523 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8524 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 8525 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 8526 | // types |
| 8527 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8528 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8529 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 8530 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8531 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8532 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8533 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8534 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8535 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8536 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8537 | |
| 8538 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8539 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8540 | ds_pool_ci.pNext = NULL; |
| 8541 | ds_pool_ci.maxSets = 1; |
| 8542 | ds_pool_ci.poolSizeCount = 1; |
| 8543 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8544 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8545 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8546 | err = |
| 8547 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8548 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8549 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8550 | dsl_binding.binding = 0; |
| 8551 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8552 | dsl_binding.descriptorCount = 1; |
| 8553 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8554 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8555 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8556 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8557 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8558 | ds_layout_ci.pNext = NULL; |
| 8559 | ds_layout_ci.bindingCount = 1; |
| 8560 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8561 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8562 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8563 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8564 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8565 | ASSERT_VK_SUCCESS(err); |
| 8566 | |
| 8567 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8568 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8569 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8570 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8571 | alloc_info.descriptorPool = ds_pool; |
| 8572 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8573 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8574 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8575 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8576 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8577 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8578 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8579 | sampler_ci.pNext = NULL; |
| 8580 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8581 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8582 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8583 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8584 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8585 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8586 | sampler_ci.mipLodBias = 1.0; |
| 8587 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8588 | sampler_ci.maxAnisotropy = 1; |
| 8589 | sampler_ci.compareEnable = VK_FALSE; |
| 8590 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8591 | sampler_ci.minLod = 1.0; |
| 8592 | sampler_ci.maxLod = 1.0; |
| 8593 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8594 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8595 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8596 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8597 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8598 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8599 | VkDescriptorImageInfo info = {}; |
| 8600 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8601 | |
| 8602 | VkWriteDescriptorSet descriptor_write; |
| 8603 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8604 | descriptor_write.sType = |
| 8605 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8606 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8607 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8608 | // 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] | 8609 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8610 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8611 | |
| 8612 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8614 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8615 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8616 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8617 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8618 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8619 | } |
| 8620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8621 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8622 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8623 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8625 | m_errorMonitor->SetDesiredFailureMsg( |
| 8626 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8627 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8628 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8629 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8630 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 8631 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8632 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8633 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8634 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8635 | |
| 8636 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8637 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8638 | ds_pool_ci.pNext = NULL; |
| 8639 | ds_pool_ci.maxSets = 1; |
| 8640 | ds_pool_ci.poolSizeCount = 1; |
| 8641 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8642 | |
| 8643 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8644 | err = |
| 8645 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8646 | ASSERT_VK_SUCCESS(err); |
| 8647 | |
| 8648 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8649 | dsl_binding.binding = 0; |
| 8650 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8651 | dsl_binding.descriptorCount = 1; |
| 8652 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8653 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8654 | |
| 8655 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8656 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8657 | ds_layout_ci.pNext = NULL; |
| 8658 | ds_layout_ci.bindingCount = 1; |
| 8659 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8660 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8661 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8662 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8663 | ASSERT_VK_SUCCESS(err); |
| 8664 | |
| 8665 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8666 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8667 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8668 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8669 | alloc_info.descriptorPool = ds_pool; |
| 8670 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8671 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8672 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8673 | ASSERT_VK_SUCCESS(err); |
| 8674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8675 | VkSampler sampler = |
| 8676 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8677 | |
| 8678 | VkDescriptorImageInfo descriptor_info; |
| 8679 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8680 | descriptor_info.sampler = sampler; |
| 8681 | |
| 8682 | VkWriteDescriptorSet descriptor_write; |
| 8683 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8684 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8685 | descriptor_write.dstSet = descriptorSet; |
| 8686 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8687 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8688 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8689 | descriptor_write.pImageInfo = &descriptor_info; |
| 8690 | |
| 8691 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8692 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8693 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8694 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8695 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8696 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8697 | } |
| 8698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8699 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 8700 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 8701 | // imageView |
| 8702 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8703 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8704 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8705 | "Attempted write update to combined " |
| 8706 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 8707 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8708 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8709 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8710 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8711 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8712 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8713 | |
| 8714 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8715 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8716 | ds_pool_ci.pNext = NULL; |
| 8717 | ds_pool_ci.maxSets = 1; |
| 8718 | ds_pool_ci.poolSizeCount = 1; |
| 8719 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8720 | |
| 8721 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8722 | err = |
| 8723 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8724 | ASSERT_VK_SUCCESS(err); |
| 8725 | |
| 8726 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8727 | dsl_binding.binding = 0; |
| 8728 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8729 | dsl_binding.descriptorCount = 1; |
| 8730 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8731 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8732 | |
| 8733 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8734 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8735 | ds_layout_ci.pNext = NULL; |
| 8736 | ds_layout_ci.bindingCount = 1; |
| 8737 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8738 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8739 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8740 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8741 | ASSERT_VK_SUCCESS(err); |
| 8742 | |
| 8743 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8744 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8745 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8746 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8747 | alloc_info.descriptorPool = ds_pool; |
| 8748 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8749 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8750 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8751 | ASSERT_VK_SUCCESS(err); |
| 8752 | |
| 8753 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8754 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8755 | sampler_ci.pNext = NULL; |
| 8756 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8757 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8758 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8759 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8760 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8761 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8762 | sampler_ci.mipLodBias = 1.0; |
| 8763 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8764 | sampler_ci.maxAnisotropy = 1; |
| 8765 | sampler_ci.compareEnable = VK_FALSE; |
| 8766 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8767 | sampler_ci.minLod = 1.0; |
| 8768 | sampler_ci.maxLod = 1.0; |
| 8769 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8770 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8771 | |
| 8772 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8773 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8774 | ASSERT_VK_SUCCESS(err); |
| 8775 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8776 | VkImageView view = |
| 8777 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8778 | |
| 8779 | VkDescriptorImageInfo descriptor_info; |
| 8780 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8781 | descriptor_info.sampler = sampler; |
| 8782 | descriptor_info.imageView = view; |
| 8783 | |
| 8784 | VkWriteDescriptorSet descriptor_write; |
| 8785 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8786 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8787 | descriptor_write.dstSet = descriptorSet; |
| 8788 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8789 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8790 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8791 | descriptor_write.pImageInfo = &descriptor_info; |
| 8792 | |
| 8793 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8794 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8795 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8796 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8797 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8798 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8799 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8800 | } |
| 8801 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8802 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 8803 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 8804 | // into the other |
| 8805 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8806 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8807 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8808 | " binding #1 with type " |
| 8809 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 8810 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8811 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8813 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8814 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8815 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8816 | ds_type_count[0].descriptorCount = 1; |
| 8817 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8818 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8819 | |
| 8820 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8821 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8822 | ds_pool_ci.pNext = NULL; |
| 8823 | ds_pool_ci.maxSets = 1; |
| 8824 | ds_pool_ci.poolSizeCount = 2; |
| 8825 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8826 | |
| 8827 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8828 | err = |
| 8829 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8830 | ASSERT_VK_SUCCESS(err); |
| 8831 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8832 | dsl_binding[0].binding = 0; |
| 8833 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8834 | dsl_binding[0].descriptorCount = 1; |
| 8835 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 8836 | dsl_binding[0].pImmutableSamplers = NULL; |
| 8837 | dsl_binding[1].binding = 1; |
| 8838 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8839 | dsl_binding[1].descriptorCount = 1; |
| 8840 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 8841 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8842 | |
| 8843 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8844 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8845 | ds_layout_ci.pNext = NULL; |
| 8846 | ds_layout_ci.bindingCount = 2; |
| 8847 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8848 | |
| 8849 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8850 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8851 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8852 | ASSERT_VK_SUCCESS(err); |
| 8853 | |
| 8854 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8855 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8856 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8857 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8858 | alloc_info.descriptorPool = ds_pool; |
| 8859 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8860 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8861 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8862 | ASSERT_VK_SUCCESS(err); |
| 8863 | |
| 8864 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8865 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8866 | sampler_ci.pNext = NULL; |
| 8867 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8868 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8869 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8870 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8871 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8872 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8873 | sampler_ci.mipLodBias = 1.0; |
| 8874 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8875 | sampler_ci.maxAnisotropy = 1; |
| 8876 | sampler_ci.compareEnable = VK_FALSE; |
| 8877 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8878 | sampler_ci.minLod = 1.0; |
| 8879 | sampler_ci.maxLod = 1.0; |
| 8880 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8881 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8882 | |
| 8883 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8884 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8885 | ASSERT_VK_SUCCESS(err); |
| 8886 | |
| 8887 | VkDescriptorImageInfo info = {}; |
| 8888 | info.sampler = sampler; |
| 8889 | |
| 8890 | VkWriteDescriptorSet descriptor_write; |
| 8891 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 8892 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8893 | descriptor_write.dstSet = descriptorSet; |
| 8894 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8895 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8896 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8897 | descriptor_write.pImageInfo = &info; |
| 8898 | // This write update should succeed |
| 8899 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8900 | // Now perform a copy update that fails due to type mismatch |
| 8901 | VkCopyDescriptorSet copy_ds_update; |
| 8902 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8903 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8904 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8905 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8906 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8907 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8908 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8909 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8910 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8911 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8912 | // 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] | 8913 | m_errorMonitor->SetDesiredFailureMsg( |
| 8914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8915 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8916 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8917 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8918 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8919 | copy_ds_update.srcBinding = |
| 8920 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8921 | copy_ds_update.dstSet = descriptorSet; |
| 8922 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8923 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8924 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8925 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8926 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8927 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8928 | // 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] | 8929 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 8931 | "update array offset of 0 and update of " |
| 8932 | "5 descriptors oversteps total number " |
| 8933 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8934 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8935 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8936 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8937 | copy_ds_update.srcSet = descriptorSet; |
| 8938 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8939 | copy_ds_update.dstSet = descriptorSet; |
| 8940 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8941 | copy_ds_update.descriptorCount = |
| 8942 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8943 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8944 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8945 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8946 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8947 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8948 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8949 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8950 | } |
| 8951 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8952 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 8953 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 8954 | // sampleCount |
| 8955 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8956 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8957 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8958 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8959 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8960 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8961 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8962 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8963 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8964 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8965 | |
| 8966 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8967 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8968 | ds_pool_ci.pNext = NULL; |
| 8969 | ds_pool_ci.maxSets = 1; |
| 8970 | ds_pool_ci.poolSizeCount = 1; |
| 8971 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8972 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8973 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8974 | err = |
| 8975 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8976 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8977 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8978 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8979 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8980 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8981 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8982 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8983 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8984 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8985 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8986 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8987 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8988 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8989 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8990 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8991 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8992 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8993 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8994 | ASSERT_VK_SUCCESS(err); |
| 8995 | |
| 8996 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8997 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8998 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8999 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9000 | alloc_info.descriptorPool = ds_pool; |
| 9001 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9002 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9003 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9004 | ASSERT_VK_SUCCESS(err); |
| 9005 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9006 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9007 | pipe_ms_state_ci.sType = |
| 9008 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9009 | pipe_ms_state_ci.pNext = NULL; |
| 9010 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9011 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9012 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9013 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9014 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9015 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9016 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9017 | pipeline_layout_ci.pNext = NULL; |
| 9018 | pipeline_layout_ci.setLayoutCount = 1; |
| 9019 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9020 | |
| 9021 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9022 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9023 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9024 | ASSERT_VK_SUCCESS(err); |
| 9025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9026 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9027 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9028 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9029 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9030 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9031 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9032 | VkPipelineObj pipe(m_device); |
| 9033 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9034 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9035 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9036 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9037 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9038 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9039 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9040 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9041 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9042 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9043 | // Render triangle (the error should trigger on the attempt to draw). |
| 9044 | Draw(3, 1, 0, 0); |
| 9045 | |
| 9046 | // Finalize recording of the command buffer |
| 9047 | EndCommandBuffer(); |
| 9048 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9049 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9050 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9051 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9052 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9053 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9054 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9055 | |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9056 | TEST_F(VkLayerTest, RenderPassIncompatible) { |
| 9057 | TEST_DESCRIPTION("Hit RenderPass incompatible cases. " |
| 9058 | "Initial case is drawing with an active renderpass that's " |
| 9059 | "not compatible with the bound PSO's creation renderpass"); |
| 9060 | VkResult err; |
| 9061 | |
| 9062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9063 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9064 | |
| 9065 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9066 | dsl_binding.binding = 0; |
| 9067 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9068 | dsl_binding.descriptorCount = 1; |
| 9069 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9070 | dsl_binding.pImmutableSamplers = NULL; |
| 9071 | |
| 9072 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9073 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9074 | ds_layout_ci.pNext = NULL; |
| 9075 | ds_layout_ci.bindingCount = 1; |
| 9076 | ds_layout_ci.pBindings = &dsl_binding; |
| 9077 | |
| 9078 | VkDescriptorSetLayout ds_layout; |
| 9079 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9080 | &ds_layout); |
| 9081 | ASSERT_VK_SUCCESS(err); |
| 9082 | |
| 9083 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9084 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9085 | pipeline_layout_ci.pNext = NULL; |
| 9086 | pipeline_layout_ci.setLayoutCount = 1; |
| 9087 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9088 | |
| 9089 | VkPipelineLayout pipeline_layout; |
| 9090 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9091 | &pipeline_layout); |
| 9092 | ASSERT_VK_SUCCESS(err); |
| 9093 | |
| 9094 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9095 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9096 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9097 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 9098 | this); // We shouldn't need a fragment shader |
| 9099 | // but add it to be able to run on more devices |
| 9100 | // Create a renderpass that will be incompatible with default renderpass |
| 9101 | VkAttachmentReference attach = {}; |
| 9102 | attach.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 9103 | VkAttachmentReference color_att = {}; |
| 9104 | color_att.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9105 | VkSubpassDescription subpass = {}; |
| 9106 | subpass.inputAttachmentCount = 1; |
| 9107 | subpass.pInputAttachments = &attach; |
| 9108 | subpass.colorAttachmentCount = 1; |
| 9109 | subpass.pColorAttachments = &color_att; |
| 9110 | VkRenderPassCreateInfo rpci = {}; |
| 9111 | rpci.subpassCount = 1; |
| 9112 | rpci.pSubpasses = &subpass; |
| 9113 | rpci.attachmentCount = 1; |
| 9114 | VkAttachmentDescription attach_desc = {}; |
| 9115 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Cody Northrop | bd16af1 | 2016-06-21 09:25:48 -0600 | [diff] [blame] | 9116 | // Format incompatible with PSO RP color attach format B8G8R8A8_UNORM |
| 9117 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 9118 | rpci.pAttachments = &attach_desc; |
| 9119 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 9120 | VkRenderPass rp; |
| 9121 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9122 | VkPipelineObj pipe(m_device); |
| 9123 | pipe.AddShader(&vs); |
| 9124 | pipe.AddShader(&fs); |
| 9125 | pipe.AddColorAttachment(); |
| 9126 | VkViewport view_port = {}; |
| 9127 | m_viewports.push_back(view_port); |
| 9128 | pipe.SetViewport(m_viewports); |
| 9129 | VkRect2D rect = {}; |
| 9130 | m_scissors.push_back(rect); |
| 9131 | pipe.SetScissor(m_scissors); |
| 9132 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9133 | |
| 9134 | VkCommandBufferInheritanceInfo cbii = {}; |
| 9135 | cbii.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 9136 | cbii.renderPass = rp; |
| 9137 | cbii.subpass = 0; |
| 9138 | VkCommandBufferBeginInfo cbbi = {}; |
| 9139 | cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 9140 | cbbi.pInheritanceInfo = &cbii; |
| 9141 | vkBeginCommandBuffer(m_commandBuffer->handle(), &cbbi); |
| 9142 | VkRenderPassBeginInfo rpbi = {}; |
| 9143 | rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 9144 | rpbi.framebuffer = m_framebuffer; |
| 9145 | rpbi.renderPass = rp; |
| 9146 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rpbi, |
| 9147 | VK_SUBPASS_CONTENTS_INLINE); |
| 9148 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9149 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9150 | |
| 9151 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9152 | " is incompatible w/ gfx pipeline "); |
| 9153 | // Render triangle (the error should trigger on the attempt to draw). |
| 9154 | Draw(3, 1, 0, 0); |
| 9155 | |
| 9156 | // Finalize recording of the command buffer |
| 9157 | EndCommandBuffer(); |
| 9158 | |
| 9159 | m_errorMonitor->VerifyFound(); |
| 9160 | |
| 9161 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9162 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9163 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 9164 | } |
| 9165 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9166 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 9167 | // Create Pipeline where the number of blend attachments doesn't match the |
| 9168 | // number of color attachments. In this case, we don't add any color |
| 9169 | // blend attachments even though we have a color attachment. |
| 9170 | VkResult err; |
| 9171 | |
| 9172 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9173 | "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] | 9174 | |
| 9175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9176 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9177 | VkDescriptorPoolSize ds_type_count = {}; |
| 9178 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9179 | ds_type_count.descriptorCount = 1; |
| 9180 | |
| 9181 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 9182 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9183 | ds_pool_ci.pNext = NULL; |
| 9184 | ds_pool_ci.maxSets = 1; |
| 9185 | ds_pool_ci.poolSizeCount = 1; |
| 9186 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 9187 | |
| 9188 | VkDescriptorPool ds_pool; |
| 9189 | err = |
| 9190 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 9191 | ASSERT_VK_SUCCESS(err); |
| 9192 | |
| 9193 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 9194 | dsl_binding.binding = 0; |
| 9195 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9196 | dsl_binding.descriptorCount = 1; |
| 9197 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9198 | dsl_binding.pImmutableSamplers = NULL; |
| 9199 | |
| 9200 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 9201 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9202 | ds_layout_ci.pNext = NULL; |
| 9203 | ds_layout_ci.bindingCount = 1; |
| 9204 | ds_layout_ci.pBindings = &dsl_binding; |
| 9205 | |
| 9206 | VkDescriptorSetLayout ds_layout; |
| 9207 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9208 | &ds_layout); |
| 9209 | ASSERT_VK_SUCCESS(err); |
| 9210 | |
| 9211 | VkDescriptorSet descriptorSet; |
| 9212 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 9213 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 9214 | alloc_info.descriptorSetCount = 1; |
| 9215 | alloc_info.descriptorPool = ds_pool; |
| 9216 | alloc_info.pSetLayouts = &ds_layout; |
| 9217 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9218 | &descriptorSet); |
| 9219 | ASSERT_VK_SUCCESS(err); |
| 9220 | |
| 9221 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 9222 | pipe_ms_state_ci.sType = |
| 9223 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9224 | pipe_ms_state_ci.pNext = NULL; |
| 9225 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 9226 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9227 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9228 | pipe_ms_state_ci.pSampleMask = NULL; |
| 9229 | |
| 9230 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 9231 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9232 | pipeline_layout_ci.pNext = NULL; |
| 9233 | pipeline_layout_ci.setLayoutCount = 1; |
| 9234 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9235 | |
| 9236 | VkPipelineLayout pipeline_layout; |
| 9237 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9238 | &pipeline_layout); |
| 9239 | ASSERT_VK_SUCCESS(err); |
| 9240 | |
| 9241 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9242 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9243 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9244 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9245 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9246 | // but add it to be able to run on more devices |
| 9247 | VkPipelineObj pipe(m_device); |
| 9248 | pipe.AddShader(&vs); |
| 9249 | pipe.AddShader(&fs); |
| 9250 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9251 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 9252 | |
| 9253 | BeginCommandBuffer(); |
| 9254 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9255 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 9256 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9257 | // Render triangle (the error should trigger on the attempt to draw). |
| 9258 | Draw(3, 1, 0, 0); |
| 9259 | |
| 9260 | // Finalize recording of the command buffer |
| 9261 | EndCommandBuffer(); |
| 9262 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9263 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9264 | |
| 9265 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9266 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9267 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 9268 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 9269 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 9270 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 9271 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " |
| 9272 | "structure passed to vkCmdClearAttachments"); |
| 9273 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9274 | "vkCmdClearAttachments() attachment index 1 not found in attachment " |
| 9275 | "reference array of active subpass 0"); |
| 9276 | |
| 9277 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); |
| 9278 | m_errorMonitor->VerifyFound(); |
| 9279 | } |
| 9280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9281 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 9282 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 9283 | // to issuing a Draw |
| 9284 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9285 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9286 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 9287 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9288 | "vkCmdClearAttachments() issued on CB object "); |
| 9289 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9291 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9292 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9293 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9294 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9295 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9296 | |
| 9297 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9298 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9299 | ds_pool_ci.pNext = NULL; |
| 9300 | ds_pool_ci.maxSets = 1; |
| 9301 | ds_pool_ci.poolSizeCount = 1; |
| 9302 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9303 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9304 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9305 | err = |
| 9306 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9307 | ASSERT_VK_SUCCESS(err); |
| 9308 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9309 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9310 | dsl_binding.binding = 0; |
| 9311 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9312 | dsl_binding.descriptorCount = 1; |
| 9313 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9314 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9315 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9316 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9317 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9318 | ds_layout_ci.pNext = NULL; |
| 9319 | ds_layout_ci.bindingCount = 1; |
| 9320 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9321 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9322 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9323 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9324 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9325 | ASSERT_VK_SUCCESS(err); |
| 9326 | |
| 9327 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9328 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9329 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9330 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9331 | alloc_info.descriptorPool = ds_pool; |
| 9332 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9333 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9334 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9335 | ASSERT_VK_SUCCESS(err); |
| 9336 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9337 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9338 | pipe_ms_state_ci.sType = |
| 9339 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9340 | pipe_ms_state_ci.pNext = NULL; |
| 9341 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 9342 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9343 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9344 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9345 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9346 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9347 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9348 | pipeline_layout_ci.pNext = NULL; |
| 9349 | pipeline_layout_ci.setLayoutCount = 1; |
| 9350 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9351 | |
| 9352 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9353 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9354 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9355 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9357 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9358 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9359 | // 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] | 9360 | // on more devices |
| 9361 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9362 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9363 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9364 | VkPipelineObj pipe(m_device); |
| 9365 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9366 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9367 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 9368 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9369 | |
| 9370 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9372 | // Main thing we care about for this test is that the VkImage obj we're |
| 9373 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9374 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9375 | VkClearAttachment color_attachment; |
| 9376 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9377 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 9378 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 9379 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 9380 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 9381 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9382 | VkClearRect clear_rect = { |
| 9383 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9385 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 9386 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9387 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9388 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9389 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9390 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9391 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9392 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 9393 | } |
| 9394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9395 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 9396 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9397 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9398 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9399 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 9400 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9401 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9402 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9403 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9405 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9406 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9407 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9408 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9409 | |
| 9410 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9411 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9412 | ds_pool_ci.pNext = NULL; |
| 9413 | ds_pool_ci.maxSets = 1; |
| 9414 | ds_pool_ci.poolSizeCount = 1; |
| 9415 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9416 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 9417 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9418 | err = |
| 9419 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9420 | ASSERT_VK_SUCCESS(err); |
| 9421 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9422 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9423 | dsl_binding.binding = 0; |
| 9424 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 9425 | dsl_binding.descriptorCount = 1; |
| 9426 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9427 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9428 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9429 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9430 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9431 | ds_layout_ci.pNext = NULL; |
| 9432 | ds_layout_ci.bindingCount = 1; |
| 9433 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9434 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9435 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9436 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9437 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9438 | ASSERT_VK_SUCCESS(err); |
| 9439 | |
| 9440 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9441 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9442 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9443 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9444 | alloc_info.descriptorPool = ds_pool; |
| 9445 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9446 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9447 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9448 | ASSERT_VK_SUCCESS(err); |
| 9449 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9450 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9451 | pipe_ms_state_ci.sType = |
| 9452 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 9453 | pipe_ms_state_ci.pNext = NULL; |
| 9454 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 9455 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 9456 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 9457 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9458 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9459 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9460 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 9461 | pipeline_layout_ci.pNext = NULL; |
| 9462 | pipeline_layout_ci.setLayoutCount = 1; |
| 9463 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 9464 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9465 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9466 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 9467 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9468 | ASSERT_VK_SUCCESS(err); |
| 9469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9470 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 9471 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9472 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 9473 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9474 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9475 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9476 | VkPipelineObj pipe(m_device); |
| 9477 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 9478 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9479 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9480 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9481 | pipe.SetViewport(m_viewports); |
| 9482 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 9483 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9484 | |
| 9485 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9486 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 9487 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 9488 | // Don't care about actual data, just need to get to draw to flag error |
| 9489 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9490 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 9491 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 9492 | 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] | 9493 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9494 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9495 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9496 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9497 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 9498 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9499 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 9500 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 9501 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 9502 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 9503 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 9504 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 9505 | "images in the wrong layout when they're copied or transitioned."); |
| 9506 | // 3 in ValidateCmdBufImageLayouts |
| 9507 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 9508 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 9509 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 9510 | m_errorMonitor->SetDesiredFailureMsg( |
| 9511 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9512 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 9513 | |
| 9514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9515 | // Create src & dst images to use for copy operations |
| 9516 | VkImage src_image; |
| 9517 | VkImage dst_image; |
| 9518 | |
| 9519 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9520 | const int32_t tex_width = 32; |
| 9521 | const int32_t tex_height = 32; |
| 9522 | |
| 9523 | VkImageCreateInfo image_create_info = {}; |
| 9524 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9525 | image_create_info.pNext = NULL; |
| 9526 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9527 | image_create_info.format = tex_format; |
| 9528 | image_create_info.extent.width = tex_width; |
| 9529 | image_create_info.extent.height = tex_height; |
| 9530 | image_create_info.extent.depth = 1; |
| 9531 | image_create_info.mipLevels = 1; |
| 9532 | image_create_info.arrayLayers = 4; |
| 9533 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9534 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9535 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9536 | image_create_info.flags = 0; |
| 9537 | |
| 9538 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 9539 | ASSERT_VK_SUCCESS(err); |
| 9540 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 9541 | ASSERT_VK_SUCCESS(err); |
| 9542 | |
| 9543 | BeginCommandBuffer(); |
| 9544 | VkImageCopy copyRegion; |
| 9545 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9546 | copyRegion.srcSubresource.mipLevel = 0; |
| 9547 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 9548 | copyRegion.srcSubresource.layerCount = 1; |
| 9549 | copyRegion.srcOffset.x = 0; |
| 9550 | copyRegion.srcOffset.y = 0; |
| 9551 | copyRegion.srcOffset.z = 0; |
| 9552 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9553 | copyRegion.dstSubresource.mipLevel = 0; |
| 9554 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9555 | copyRegion.dstSubresource.layerCount = 1; |
| 9556 | copyRegion.dstOffset.x = 0; |
| 9557 | copyRegion.dstOffset.y = 0; |
| 9558 | copyRegion.dstOffset.z = 0; |
| 9559 | copyRegion.extent.width = 1; |
| 9560 | copyRegion.extent.height = 1; |
| 9561 | copyRegion.extent.depth = 1; |
| 9562 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9563 | m_errorMonitor->VerifyFound(); |
| 9564 | // Now cause error due to src image layout changing |
| 9565 | m_errorMonitor->SetDesiredFailureMsg( |
| 9566 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9567 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 9568 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9569 | m_errorMonitor->VerifyFound(); |
| 9570 | // Final src error is due to bad layout type |
| 9571 | m_errorMonitor->SetDesiredFailureMsg( |
| 9572 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9573 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 9574 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9575 | m_errorMonitor->VerifyFound(); |
| 9576 | // Now verify same checks for dst |
| 9577 | m_errorMonitor->SetDesiredFailureMsg( |
| 9578 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9579 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 9580 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9581 | m_errorMonitor->VerifyFound(); |
| 9582 | // Now cause error due to src image layout changing |
| 9583 | m_errorMonitor->SetDesiredFailureMsg( |
| 9584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9585 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 9586 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 9587 | m_errorMonitor->VerifyFound(); |
| 9588 | m_errorMonitor->SetDesiredFailureMsg( |
| 9589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9590 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 9591 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 9592 | m_errorMonitor->VerifyFound(); |
| 9593 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 9594 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 9595 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9596 | image_barrier[0].image = src_image; |
| 9597 | image_barrier[0].subresourceRange.layerCount = 2; |
| 9598 | image_barrier[0].subresourceRange.levelCount = 2; |
| 9599 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9600 | m_errorMonitor->SetDesiredFailureMsg( |
| 9601 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9602 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 9603 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 9604 | m_errorMonitor->VerifyFound(); |
| 9605 | |
| 9606 | // Finally some layout errors at RenderPass create time |
| 9607 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 9608 | VkAttachmentReference attach = {}; |
| 9609 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 9610 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9611 | VkSubpassDescription subpass = {}; |
| 9612 | subpass.inputAttachmentCount = 1; |
| 9613 | subpass.pInputAttachments = &attach; |
| 9614 | VkRenderPassCreateInfo rpci = {}; |
| 9615 | rpci.subpassCount = 1; |
| 9616 | rpci.pSubpasses = &subpass; |
| 9617 | rpci.attachmentCount = 1; |
| 9618 | VkAttachmentDescription attach_desc = {}; |
| 9619 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 9620 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 9621 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 9622 | VkRenderPass rp; |
| 9623 | m_errorMonitor->SetDesiredFailureMsg( |
| 9624 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9625 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 9626 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9627 | m_errorMonitor->VerifyFound(); |
| 9628 | // error w/ non-general layout |
| 9629 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9630 | |
| 9631 | m_errorMonitor->SetDesiredFailureMsg( |
| 9632 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9633 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 9634 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9635 | m_errorMonitor->VerifyFound(); |
| 9636 | subpass.inputAttachmentCount = 0; |
| 9637 | subpass.colorAttachmentCount = 1; |
| 9638 | subpass.pColorAttachments = &attach; |
| 9639 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9640 | // perf warning for GENERAL layout on color attachment |
| 9641 | m_errorMonitor->SetDesiredFailureMsg( |
| 9642 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9643 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 9644 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9645 | m_errorMonitor->VerifyFound(); |
| 9646 | // error w/ non-color opt or GENERAL layout for color attachment |
| 9647 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9648 | m_errorMonitor->SetDesiredFailureMsg( |
| 9649 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9650 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9651 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9652 | m_errorMonitor->VerifyFound(); |
| 9653 | subpass.colorAttachmentCount = 0; |
| 9654 | subpass.pDepthStencilAttachment = &attach; |
| 9655 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9656 | // perf warning for GENERAL layout on DS attachment |
| 9657 | m_errorMonitor->SetDesiredFailureMsg( |
| 9658 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9659 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 9660 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9661 | m_errorMonitor->VerifyFound(); |
| 9662 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 9663 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9664 | m_errorMonitor->SetDesiredFailureMsg( |
| 9665 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9666 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9667 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9668 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 9669 | // For this error we need a valid renderpass so create default one |
| 9670 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9671 | attach.attachment = 0; |
| 9672 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9673 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9674 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 9675 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 9676 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 9677 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 9678 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 9679 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9680 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9681 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9682 | " with invalid first layout " |
| 9683 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 9684 | "ONLY_OPTIMAL"); |
| 9685 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9686 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 9687 | |
| 9688 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 9689 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 9690 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9691 | #endif // DRAW_STATE_TESTS |
| 9692 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 9693 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9694 | #if GTEST_IS_THREADSAFE |
| 9695 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9696 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9697 | VkEvent event; |
| 9698 | bool bailout; |
| 9699 | }; |
| 9700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9701 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 9702 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9703 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9704 | for (int i = 0; i < 10000; i++) { |
| 9705 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 9706 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9707 | if (data->bailout) { |
| 9708 | break; |
| 9709 | } |
| 9710 | } |
| 9711 | return NULL; |
| 9712 | } |
| 9713 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9714 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9715 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9716 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9717 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9718 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9719 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9721 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 9722 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9723 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9724 | // Calls AllocateCommandBuffers |
| 9725 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9726 | |
| 9727 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9728 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9729 | |
| 9730 | VkEventCreateInfo event_info; |
| 9731 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9732 | VkResult err; |
| 9733 | |
| 9734 | memset(&event_info, 0, sizeof(event_info)); |
| 9735 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 9736 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9737 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9738 | ASSERT_VK_SUCCESS(err); |
| 9739 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9740 | err = vkResetEvent(device(), event); |
| 9741 | ASSERT_VK_SUCCESS(err); |
| 9742 | |
| 9743 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9744 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9745 | data.event = event; |
| 9746 | data.bailout = false; |
| 9747 | m_errorMonitor->SetBailout(&data.bailout); |
| 9748 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9749 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9750 | // Add many entries to command buffer from this thread at the same time. |
| 9751 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9752 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9753 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9754 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9755 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 9756 | m_errorMonitor->SetBailout(NULL); |
| 9757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9758 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9759 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9760 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9761 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9762 | #endif // GTEST_IS_THREADSAFE |
| 9763 | #endif // THREADING_TESTS |
| 9764 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9765 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9766 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9767 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9768 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9769 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9772 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9773 | VkShaderModule module; |
| 9774 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9775 | struct icd_spv_header spv; |
| 9776 | |
| 9777 | spv.magic = ICD_SPV_MAGIC; |
| 9778 | spv.version = ICD_SPV_VERSION; |
| 9779 | spv.gen_magic = 0; |
| 9780 | |
| 9781 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9782 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9783 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9784 | moduleCreateInfo.codeSize = 4; |
| 9785 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9786 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9787 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9788 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9789 | } |
| 9790 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9791 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9792 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9793 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9794 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9795 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9796 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9797 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9798 | VkShaderModule module; |
| 9799 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9800 | struct icd_spv_header spv; |
| 9801 | |
| 9802 | spv.magic = ~ICD_SPV_MAGIC; |
| 9803 | spv.version = ICD_SPV_VERSION; |
| 9804 | spv.gen_magic = 0; |
| 9805 | |
| 9806 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9807 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9808 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9809 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9810 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9811 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9812 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9813 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9814 | } |
| 9815 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9816 | #if 0 |
| 9817 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9818 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9819 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9820 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9821 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9822 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9823 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9824 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9825 | VkShaderModule module; |
| 9826 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9827 | struct icd_spv_header spv; |
| 9828 | |
| 9829 | spv.magic = ICD_SPV_MAGIC; |
| 9830 | spv.version = ~ICD_SPV_VERSION; |
| 9831 | spv.gen_magic = 0; |
| 9832 | |
| 9833 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9834 | moduleCreateInfo.pNext = NULL; |
| 9835 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9836 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9837 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9838 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9839 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9840 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9841 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9842 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9843 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9845 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9847 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9848 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9850 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9851 | |
| 9852 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9853 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9854 | "\n" |
| 9855 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9856 | "out gl_PerVertex {\n" |
| 9857 | " vec4 gl_Position;\n" |
| 9858 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9859 | "void main(){\n" |
| 9860 | " gl_Position = vec4(1);\n" |
| 9861 | " x = 0;\n" |
| 9862 | "}\n"; |
| 9863 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9864 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9865 | "\n" |
| 9866 | "layout(location=0) out vec4 color;\n" |
| 9867 | "void main(){\n" |
| 9868 | " color = vec4(1);\n" |
| 9869 | "}\n"; |
| 9870 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9871 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9872 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9873 | |
| 9874 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9875 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9876 | pipe.AddShader(&vs); |
| 9877 | pipe.AddShader(&fs); |
| 9878 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9879 | VkDescriptorSetObj descriptorSet(m_device); |
| 9880 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9881 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9882 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9883 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9884 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9885 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9886 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9888 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9890 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9891 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9892 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9893 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9894 | |
| 9895 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9896 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9897 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9898 | "out gl_PerVertex {\n" |
| 9899 | " vec4 gl_Position;\n" |
| 9900 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9901 | "void main(){\n" |
| 9902 | " gl_Position = vec4(1);\n" |
| 9903 | "}\n"; |
| 9904 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9905 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9906 | "\n" |
| 9907 | "layout(location=0) in float x;\n" |
| 9908 | "layout(location=0) out vec4 color;\n" |
| 9909 | "void main(){\n" |
| 9910 | " color = vec4(x);\n" |
| 9911 | "}\n"; |
| 9912 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9913 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9914 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9915 | |
| 9916 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9917 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9918 | pipe.AddShader(&vs); |
| 9919 | pipe.AddShader(&fs); |
| 9920 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9921 | VkDescriptorSetObj descriptorSet(m_device); |
| 9922 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9923 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9924 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9925 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9926 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9927 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9928 | } |
| 9929 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9930 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9931 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9932 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9933 | |
| 9934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9935 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9936 | |
| 9937 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9938 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9939 | "\n" |
| 9940 | "out gl_PerVertex {\n" |
| 9941 | " vec4 gl_Position;\n" |
| 9942 | "};\n" |
| 9943 | "void main(){\n" |
| 9944 | " gl_Position = vec4(1);\n" |
| 9945 | "}\n"; |
| 9946 | char const *fsSource = |
| 9947 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9948 | "\n" |
| 9949 | "in block { layout(location=0) float x; } ins;\n" |
| 9950 | "layout(location=0) out vec4 color;\n" |
| 9951 | "void main(){\n" |
| 9952 | " color = vec4(ins.x);\n" |
| 9953 | "}\n"; |
| 9954 | |
| 9955 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9956 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9957 | |
| 9958 | VkPipelineObj pipe(m_device); |
| 9959 | pipe.AddColorAttachment(); |
| 9960 | pipe.AddShader(&vs); |
| 9961 | pipe.AddShader(&fs); |
| 9962 | |
| 9963 | VkDescriptorSetObj descriptorSet(m_device); |
| 9964 | descriptorSet.AppendDummy(); |
| 9965 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9966 | |
| 9967 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9968 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9969 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9970 | } |
| 9971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9972 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9973 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9974 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9975 | "output arr[2] of float32' vs 'ptr to " |
| 9976 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9977 | |
| 9978 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9979 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9980 | |
| 9981 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9982 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9983 | "\n" |
| 9984 | "layout(location=0) out float x[2];\n" |
| 9985 | "out gl_PerVertex {\n" |
| 9986 | " vec4 gl_Position;\n" |
| 9987 | "};\n" |
| 9988 | "void main(){\n" |
| 9989 | " x[0] = 0; x[1] = 0;\n" |
| 9990 | " gl_Position = vec4(1);\n" |
| 9991 | "}\n"; |
| 9992 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9993 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9994 | "\n" |
| 9995 | "layout(location=0) in float x[3];\n" |
| 9996 | "layout(location=0) out vec4 color;\n" |
| 9997 | "void main(){\n" |
| 9998 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 9999 | "}\n"; |
| 10000 | |
| 10001 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10002 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10003 | |
| 10004 | VkPipelineObj pipe(m_device); |
| 10005 | pipe.AddColorAttachment(); |
| 10006 | pipe.AddShader(&vs); |
| 10007 | pipe.AddShader(&fs); |
| 10008 | |
| 10009 | VkDescriptorSetObj descriptorSet(m_device); |
| 10010 | descriptorSet.AppendDummy(); |
| 10011 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10012 | |
| 10013 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10014 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10015 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 10016 | } |
| 10017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10018 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10020 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10021 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10022 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10023 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10024 | |
| 10025 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10026 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10027 | "\n" |
| 10028 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10029 | "out gl_PerVertex {\n" |
| 10030 | " vec4 gl_Position;\n" |
| 10031 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10032 | "void main(){\n" |
| 10033 | " x = 0;\n" |
| 10034 | " gl_Position = vec4(1);\n" |
| 10035 | "}\n"; |
| 10036 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10037 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10038 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10039 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10040 | "layout(location=0) out vec4 color;\n" |
| 10041 | "void main(){\n" |
| 10042 | " color = vec4(x);\n" |
| 10043 | "}\n"; |
| 10044 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10045 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10046 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10047 | |
| 10048 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10049 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10050 | pipe.AddShader(&vs); |
| 10051 | pipe.AddShader(&fs); |
| 10052 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10053 | VkDescriptorSetObj descriptorSet(m_device); |
| 10054 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10055 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10056 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10057 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10058 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10059 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 10060 | } |
| 10061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10062 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10063 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10064 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10065 | |
| 10066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10067 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10068 | |
| 10069 | char const *vsSource = |
| 10070 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10071 | "\n" |
| 10072 | "out block { layout(location=0) int x; } outs;\n" |
| 10073 | "out gl_PerVertex {\n" |
| 10074 | " vec4 gl_Position;\n" |
| 10075 | "};\n" |
| 10076 | "void main(){\n" |
| 10077 | " outs.x = 0;\n" |
| 10078 | " gl_Position = vec4(1);\n" |
| 10079 | "}\n"; |
| 10080 | char const *fsSource = |
| 10081 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10082 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10083 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10084 | "layout(location=0) out vec4 color;\n" |
| 10085 | "void main(){\n" |
| 10086 | " color = vec4(ins.x);\n" |
| 10087 | "}\n"; |
| 10088 | |
| 10089 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10090 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10091 | |
| 10092 | VkPipelineObj pipe(m_device); |
| 10093 | pipe.AddColorAttachment(); |
| 10094 | pipe.AddShader(&vs); |
| 10095 | pipe.AddShader(&fs); |
| 10096 | |
| 10097 | VkDescriptorSetObj descriptorSet(m_device); |
| 10098 | descriptorSet.AppendDummy(); |
| 10099 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10100 | |
| 10101 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10102 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10103 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10104 | } |
| 10105 | |
| 10106 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 10107 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10108 | "location 0.0 which is not written by vertex shader"); |
| 10109 | |
| 10110 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10111 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10112 | |
| 10113 | char const *vsSource = |
| 10114 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10115 | "\n" |
| 10116 | "out block { layout(location=1) float x; } outs;\n" |
| 10117 | "out gl_PerVertex {\n" |
| 10118 | " vec4 gl_Position;\n" |
| 10119 | "};\n" |
| 10120 | "void main(){\n" |
| 10121 | " outs.x = 0;\n" |
| 10122 | " gl_Position = vec4(1);\n" |
| 10123 | "}\n"; |
| 10124 | char const *fsSource = |
| 10125 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10126 | "\n" |
| 10127 | "in block { layout(location=0) float x; } ins;\n" |
| 10128 | "layout(location=0) out vec4 color;\n" |
| 10129 | "void main(){\n" |
| 10130 | " color = vec4(ins.x);\n" |
| 10131 | "}\n"; |
| 10132 | |
| 10133 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10134 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10135 | |
| 10136 | VkPipelineObj pipe(m_device); |
| 10137 | pipe.AddColorAttachment(); |
| 10138 | pipe.AddShader(&vs); |
| 10139 | pipe.AddShader(&fs); |
| 10140 | |
| 10141 | VkDescriptorSetObj descriptorSet(m_device); |
| 10142 | descriptorSet.AppendDummy(); |
| 10143 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10144 | |
| 10145 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10147 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10148 | } |
| 10149 | |
| 10150 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 10151 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10152 | "location 0.1 which is not written by vertex shader"); |
| 10153 | |
| 10154 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10155 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10156 | |
| 10157 | char const *vsSource = |
| 10158 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10159 | "\n" |
| 10160 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 10161 | "out gl_PerVertex {\n" |
| 10162 | " vec4 gl_Position;\n" |
| 10163 | "};\n" |
| 10164 | "void main(){\n" |
| 10165 | " outs.x = 0;\n" |
| 10166 | " gl_Position = vec4(1);\n" |
| 10167 | "}\n"; |
| 10168 | char const *fsSource = |
| 10169 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 10170 | "\n" |
| 10171 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 10172 | "layout(location=0) out vec4 color;\n" |
| 10173 | "void main(){\n" |
| 10174 | " color = vec4(ins.x);\n" |
| 10175 | "}\n"; |
| 10176 | |
| 10177 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10178 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10179 | |
| 10180 | VkPipelineObj pipe(m_device); |
| 10181 | pipe.AddColorAttachment(); |
| 10182 | pipe.AddShader(&vs); |
| 10183 | pipe.AddShader(&fs); |
| 10184 | |
| 10185 | VkDescriptorSetObj descriptorSet(m_device); |
| 10186 | descriptorSet.AppendDummy(); |
| 10187 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10188 | |
| 10189 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10190 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10191 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 10192 | } |
| 10193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10194 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10195 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10196 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10197 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10198 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10199 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10200 | |
| 10201 | VkVertexInputBindingDescription input_binding; |
| 10202 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10203 | |
| 10204 | VkVertexInputAttributeDescription input_attrib; |
| 10205 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10206 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10207 | |
| 10208 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10209 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10210 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10211 | "out gl_PerVertex {\n" |
| 10212 | " vec4 gl_Position;\n" |
| 10213 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10214 | "void main(){\n" |
| 10215 | " gl_Position = vec4(1);\n" |
| 10216 | "}\n"; |
| 10217 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10218 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10219 | "\n" |
| 10220 | "layout(location=0) out vec4 color;\n" |
| 10221 | "void main(){\n" |
| 10222 | " color = vec4(1);\n" |
| 10223 | "}\n"; |
| 10224 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10225 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10226 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10227 | |
| 10228 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10229 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10230 | pipe.AddShader(&vs); |
| 10231 | pipe.AddShader(&fs); |
| 10232 | |
| 10233 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10234 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10235 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10236 | VkDescriptorSetObj descriptorSet(m_device); |
| 10237 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10238 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10239 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10240 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10241 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10242 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 10243 | } |
| 10244 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10245 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10246 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10247 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10248 | |
| 10249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10250 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10251 | |
| 10252 | VkVertexInputBindingDescription input_binding; |
| 10253 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10254 | |
| 10255 | VkVertexInputAttributeDescription input_attrib; |
| 10256 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10257 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10258 | |
| 10259 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10260 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10261 | "\n" |
| 10262 | "layout(location=1) in float x;\n" |
| 10263 | "out gl_PerVertex {\n" |
| 10264 | " vec4 gl_Position;\n" |
| 10265 | "};\n" |
| 10266 | "void main(){\n" |
| 10267 | " gl_Position = vec4(x);\n" |
| 10268 | "}\n"; |
| 10269 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10270 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10271 | "\n" |
| 10272 | "layout(location=0) out vec4 color;\n" |
| 10273 | "void main(){\n" |
| 10274 | " color = vec4(1);\n" |
| 10275 | "}\n"; |
| 10276 | |
| 10277 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10278 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10279 | |
| 10280 | VkPipelineObj pipe(m_device); |
| 10281 | pipe.AddColorAttachment(); |
| 10282 | pipe.AddShader(&vs); |
| 10283 | pipe.AddShader(&fs); |
| 10284 | |
| 10285 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10286 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10287 | |
| 10288 | VkDescriptorSetObj descriptorSet(m_device); |
| 10289 | descriptorSet.AppendDummy(); |
| 10290 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10291 | |
| 10292 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10293 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10294 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 10295 | } |
| 10296 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10297 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 10298 | m_errorMonitor->SetDesiredFailureMsg( |
| 10299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10300 | "VS consumes input at location 0 but not provided"); |
| 10301 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10303 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10304 | |
| 10305 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10306 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10307 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10308 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10309 | "out gl_PerVertex {\n" |
| 10310 | " vec4 gl_Position;\n" |
| 10311 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10312 | "void main(){\n" |
| 10313 | " gl_Position = x;\n" |
| 10314 | "}\n"; |
| 10315 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10316 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10317 | "\n" |
| 10318 | "layout(location=0) out vec4 color;\n" |
| 10319 | "void main(){\n" |
| 10320 | " color = vec4(1);\n" |
| 10321 | "}\n"; |
| 10322 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10323 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10324 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10325 | |
| 10326 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10327 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10328 | pipe.AddShader(&vs); |
| 10329 | pipe.AddShader(&fs); |
| 10330 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10331 | VkDescriptorSetObj descriptorSet(m_device); |
| 10332 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10333 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10334 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10335 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10337 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 10338 | } |
| 10339 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10340 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 10341 | m_errorMonitor->SetDesiredFailureMsg( |
| 10342 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10343 | "location 0 does not match VS input type"); |
| 10344 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10345 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10346 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10347 | |
| 10348 | VkVertexInputBindingDescription input_binding; |
| 10349 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10350 | |
| 10351 | VkVertexInputAttributeDescription input_attrib; |
| 10352 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10353 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10354 | |
| 10355 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10356 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10357 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10358 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10359 | "out gl_PerVertex {\n" |
| 10360 | " vec4 gl_Position;\n" |
| 10361 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10362 | "void main(){\n" |
| 10363 | " gl_Position = vec4(x);\n" |
| 10364 | "}\n"; |
| 10365 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10366 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10367 | "\n" |
| 10368 | "layout(location=0) out vec4 color;\n" |
| 10369 | "void main(){\n" |
| 10370 | " color = vec4(1);\n" |
| 10371 | "}\n"; |
| 10372 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10373 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10374 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10375 | |
| 10376 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10377 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10378 | pipe.AddShader(&vs); |
| 10379 | pipe.AddShader(&fs); |
| 10380 | |
| 10381 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10382 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10383 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10384 | VkDescriptorSetObj descriptorSet(m_device); |
| 10385 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10386 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10387 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10388 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10389 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10390 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 10391 | } |
| 10392 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 10393 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 10394 | m_errorMonitor->SetDesiredFailureMsg( |
| 10395 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10396 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 10397 | |
| 10398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10399 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10400 | |
| 10401 | char const *vsSource = |
| 10402 | "#version 450\n" |
| 10403 | "\n" |
| 10404 | "out gl_PerVertex {\n" |
| 10405 | " vec4 gl_Position;\n" |
| 10406 | "};\n" |
| 10407 | "void main(){\n" |
| 10408 | " gl_Position = vec4(1);\n" |
| 10409 | "}\n"; |
| 10410 | char const *fsSource = |
| 10411 | "#version 450\n" |
| 10412 | "\n" |
| 10413 | "layout(location=0) out vec4 color;\n" |
| 10414 | "void main(){\n" |
| 10415 | " color = vec4(1);\n" |
| 10416 | "}\n"; |
| 10417 | |
| 10418 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10419 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10420 | |
| 10421 | VkPipelineObj pipe(m_device); |
| 10422 | pipe.AddColorAttachment(); |
| 10423 | pipe.AddShader(&vs); |
| 10424 | pipe.AddShader(&vs); |
| 10425 | pipe.AddShader(&fs); |
| 10426 | |
| 10427 | VkDescriptorSetObj descriptorSet(m_device); |
| 10428 | descriptorSet.AppendDummy(); |
| 10429 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10430 | |
| 10431 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10432 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10433 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 10434 | } |
| 10435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10436 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10437 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10438 | |
| 10439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10440 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10441 | |
| 10442 | VkVertexInputBindingDescription input_binding; |
| 10443 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10444 | |
| 10445 | VkVertexInputAttributeDescription input_attribs[2]; |
| 10446 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 10447 | |
| 10448 | for (int i = 0; i < 2; i++) { |
| 10449 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 10450 | input_attribs[i].location = i; |
| 10451 | } |
| 10452 | |
| 10453 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10454 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10455 | "\n" |
| 10456 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10457 | "out gl_PerVertex {\n" |
| 10458 | " vec4 gl_Position;\n" |
| 10459 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10460 | "void main(){\n" |
| 10461 | " gl_Position = x[0] + x[1];\n" |
| 10462 | "}\n"; |
| 10463 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10464 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10465 | "\n" |
| 10466 | "layout(location=0) out vec4 color;\n" |
| 10467 | "void main(){\n" |
| 10468 | " color = vec4(1);\n" |
| 10469 | "}\n"; |
| 10470 | |
| 10471 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10472 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10473 | |
| 10474 | VkPipelineObj pipe(m_device); |
| 10475 | pipe.AddColorAttachment(); |
| 10476 | pipe.AddShader(&vs); |
| 10477 | pipe.AddShader(&fs); |
| 10478 | |
| 10479 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10480 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 10481 | |
| 10482 | VkDescriptorSetObj descriptorSet(m_device); |
| 10483 | descriptorSet.AppendDummy(); |
| 10484 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10485 | |
| 10486 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10487 | |
| 10488 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10489 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10490 | } |
| 10491 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10492 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 10493 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10494 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10495 | |
| 10496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10497 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10498 | |
| 10499 | VkVertexInputBindingDescription input_binding; |
| 10500 | memset(&input_binding, 0, sizeof(input_binding)); |
| 10501 | |
| 10502 | VkVertexInputAttributeDescription input_attribs[2]; |
| 10503 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 10504 | |
| 10505 | for (int i = 0; i < 2; i++) { |
| 10506 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 10507 | input_attribs[i].location = i; |
| 10508 | } |
| 10509 | |
| 10510 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10511 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10512 | "\n" |
| 10513 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10514 | "out gl_PerVertex {\n" |
| 10515 | " vec4 gl_Position;\n" |
| 10516 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10517 | "void main(){\n" |
| 10518 | " gl_Position = x[0] + x[1];\n" |
| 10519 | "}\n"; |
| 10520 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10521 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10522 | "\n" |
| 10523 | "layout(location=0) out vec4 color;\n" |
| 10524 | "void main(){\n" |
| 10525 | " color = vec4(1);\n" |
| 10526 | "}\n"; |
| 10527 | |
| 10528 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10529 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10530 | |
| 10531 | VkPipelineObj pipe(m_device); |
| 10532 | pipe.AddColorAttachment(); |
| 10533 | pipe.AddShader(&vs); |
| 10534 | pipe.AddShader(&fs); |
| 10535 | |
| 10536 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 10537 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 10538 | |
| 10539 | VkDescriptorSetObj descriptorSet(m_device); |
| 10540 | descriptorSet.AppendDummy(); |
| 10541 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10542 | |
| 10543 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10544 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10545 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10546 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 10547 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10548 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 10549 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10550 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10551 | |
| 10552 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10553 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10554 | |
| 10555 | char const *vsSource = |
| 10556 | "#version 450\n" |
| 10557 | "out gl_PerVertex {\n" |
| 10558 | " vec4 gl_Position;\n" |
| 10559 | "};\n" |
| 10560 | "void main(){\n" |
| 10561 | " gl_Position = vec4(0);\n" |
| 10562 | "}\n"; |
| 10563 | char const *fsSource = |
| 10564 | "#version 450\n" |
| 10565 | "\n" |
| 10566 | "layout(location=0) out vec4 color;\n" |
| 10567 | "void main(){\n" |
| 10568 | " color = vec4(1);\n" |
| 10569 | "}\n"; |
| 10570 | |
| 10571 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10572 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10573 | |
| 10574 | VkPipelineObj pipe(m_device); |
| 10575 | pipe.AddColorAttachment(); |
| 10576 | pipe.AddShader(&vs); |
| 10577 | pipe.AddShader(&fs); |
| 10578 | |
| 10579 | VkDescriptorSetObj descriptorSet(m_device); |
| 10580 | descriptorSet.AppendDummy(); |
| 10581 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10582 | |
| 10583 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10584 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10585 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10586 | } |
| 10587 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 10588 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 10589 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10590 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 10591 | |
| 10592 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 10593 | |
| 10594 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10595 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10596 | |
| 10597 | char const *vsSource = |
| 10598 | "#version 450\n" |
| 10599 | "out gl_PerVertex {\n" |
| 10600 | " vec4 gl_Position;\n" |
| 10601 | "};\n" |
| 10602 | "layout(location=0) out vec3 x;\n" |
| 10603 | "layout(location=1) out ivec3 y;\n" |
| 10604 | "layout(location=2) out vec3 z;\n" |
| 10605 | "void main(){\n" |
| 10606 | " gl_Position = vec4(0);\n" |
| 10607 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 10608 | "}\n"; |
| 10609 | char const *fsSource = |
| 10610 | "#version 450\n" |
| 10611 | "\n" |
| 10612 | "layout(location=0) out vec4 color;\n" |
| 10613 | "layout(location=0) in float x;\n" |
| 10614 | "layout(location=1) flat in int y;\n" |
| 10615 | "layout(location=2) in vec2 z;\n" |
| 10616 | "void main(){\n" |
| 10617 | " color = vec4(1 + x + y + z.x);\n" |
| 10618 | "}\n"; |
| 10619 | |
| 10620 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10621 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10622 | |
| 10623 | VkPipelineObj pipe(m_device); |
| 10624 | pipe.AddColorAttachment(); |
| 10625 | pipe.AddShader(&vs); |
| 10626 | pipe.AddShader(&fs); |
| 10627 | |
| 10628 | VkDescriptorSetObj descriptorSet(m_device); |
| 10629 | descriptorSet.AppendDummy(); |
| 10630 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10631 | |
| 10632 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10633 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10634 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 10635 | } |
| 10636 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10637 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 10638 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10639 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10640 | |
| 10641 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10642 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10643 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10644 | if (!m_device->phy().features().tessellationShader) { |
| 10645 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10646 | return; |
| 10647 | } |
| 10648 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10649 | char const *vsSource = |
| 10650 | "#version 450\n" |
| 10651 | "void main(){}\n"; |
| 10652 | char const *tcsSource = |
| 10653 | "#version 450\n" |
| 10654 | "layout(location=0) out int x[];\n" |
| 10655 | "layout(vertices=3) out;\n" |
| 10656 | "void main(){\n" |
| 10657 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10658 | " gl_TessLevelInner[0] = 1;\n" |
| 10659 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10660 | "}\n"; |
| 10661 | char const *tesSource = |
| 10662 | "#version 450\n" |
| 10663 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10664 | "layout(location=0) in int x[];\n" |
| 10665 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10666 | "void main(){\n" |
| 10667 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10668 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 10669 | "}\n"; |
| 10670 | char const *fsSource = |
| 10671 | "#version 450\n" |
| 10672 | "layout(location=0) out vec4 color;\n" |
| 10673 | "void main(){\n" |
| 10674 | " color = vec4(1);\n" |
| 10675 | "}\n"; |
| 10676 | |
| 10677 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10678 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10679 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10680 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10681 | |
| 10682 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10683 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10684 | nullptr, |
| 10685 | 0, |
| 10686 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10687 | VK_FALSE}; |
| 10688 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10689 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10690 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10691 | nullptr, |
| 10692 | 0, |
| 10693 | 3}; |
| 10694 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10695 | VkPipelineObj pipe(m_device); |
| 10696 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10697 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10698 | pipe.AddColorAttachment(); |
| 10699 | pipe.AddShader(&vs); |
| 10700 | pipe.AddShader(&tcs); |
| 10701 | pipe.AddShader(&tes); |
| 10702 | pipe.AddShader(&fs); |
| 10703 | |
| 10704 | VkDescriptorSetObj descriptorSet(m_device); |
| 10705 | descriptorSet.AppendDummy(); |
| 10706 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10707 | |
| 10708 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10709 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10710 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10711 | } |
| 10712 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 10713 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 10714 | { |
| 10715 | m_errorMonitor->ExpectSuccess(); |
| 10716 | |
| 10717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10719 | |
| 10720 | if (!m_device->phy().features().geometryShader) { |
| 10721 | printf("Device does not support geometry shaders; skipped.\n"); |
| 10722 | return; |
| 10723 | } |
| 10724 | |
| 10725 | char const *vsSource = |
| 10726 | "#version 450\n" |
| 10727 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 10728 | "void main(){\n" |
| 10729 | " vs_out.x = vec4(1);\n" |
| 10730 | "}\n"; |
| 10731 | char const *gsSource = |
| 10732 | "#version 450\n" |
| 10733 | "layout(triangles) in;\n" |
| 10734 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 10735 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 10736 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10737 | "void main() {\n" |
| 10738 | " gl_Position = gs_in[0].x;\n" |
| 10739 | " EmitVertex();\n" |
| 10740 | "}\n"; |
| 10741 | char const *fsSource = |
| 10742 | "#version 450\n" |
| 10743 | "layout(location=0) out vec4 color;\n" |
| 10744 | "void main(){\n" |
| 10745 | " color = vec4(1);\n" |
| 10746 | "}\n"; |
| 10747 | |
| 10748 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10749 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 10750 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10751 | |
| 10752 | VkPipelineObj pipe(m_device); |
| 10753 | pipe.AddColorAttachment(); |
| 10754 | pipe.AddShader(&vs); |
| 10755 | pipe.AddShader(&gs); |
| 10756 | pipe.AddShader(&fs); |
| 10757 | |
| 10758 | VkDescriptorSetObj descriptorSet(m_device); |
| 10759 | descriptorSet.AppendDummy(); |
| 10760 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10761 | |
| 10762 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10763 | |
| 10764 | m_errorMonitor->VerifyNotFound(); |
| 10765 | } |
| 10766 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10767 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 10768 | { |
| 10769 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10770 | "is per-vertex in tessellation control shader stage " |
| 10771 | "but per-patch in tessellation evaluation shader stage"); |
| 10772 | |
| 10773 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10774 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10775 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10776 | if (!m_device->phy().features().tessellationShader) { |
| 10777 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10778 | return; |
| 10779 | } |
| 10780 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10781 | char const *vsSource = |
| 10782 | "#version 450\n" |
| 10783 | "void main(){}\n"; |
| 10784 | char const *tcsSource = |
| 10785 | "#version 450\n" |
| 10786 | "layout(location=0) out int x[];\n" |
| 10787 | "layout(vertices=3) out;\n" |
| 10788 | "void main(){\n" |
| 10789 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10790 | " gl_TessLevelInner[0] = 1;\n" |
| 10791 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10792 | "}\n"; |
| 10793 | char const *tesSource = |
| 10794 | "#version 450\n" |
| 10795 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10796 | "layout(location=0) patch in int x;\n" |
| 10797 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10798 | "void main(){\n" |
| 10799 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10800 | " gl_Position.w = x;\n" |
| 10801 | "}\n"; |
| 10802 | char const *fsSource = |
| 10803 | "#version 450\n" |
| 10804 | "layout(location=0) out vec4 color;\n" |
| 10805 | "void main(){\n" |
| 10806 | " color = vec4(1);\n" |
| 10807 | "}\n"; |
| 10808 | |
| 10809 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10810 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10811 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10812 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10813 | |
| 10814 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10815 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10816 | nullptr, |
| 10817 | 0, |
| 10818 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10819 | VK_FALSE}; |
| 10820 | |
| 10821 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10822 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10823 | nullptr, |
| 10824 | 0, |
| 10825 | 3}; |
| 10826 | |
| 10827 | VkPipelineObj pipe(m_device); |
| 10828 | pipe.SetInputAssembly(&iasci); |
| 10829 | pipe.SetTessellation(&tsci); |
| 10830 | pipe.AddColorAttachment(); |
| 10831 | pipe.AddShader(&vs); |
| 10832 | pipe.AddShader(&tcs); |
| 10833 | pipe.AddShader(&tes); |
| 10834 | pipe.AddShader(&fs); |
| 10835 | |
| 10836 | VkDescriptorSetObj descriptorSet(m_device); |
| 10837 | descriptorSet.AppendDummy(); |
| 10838 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10839 | |
| 10840 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10841 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10842 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10843 | } |
| 10844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10845 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 10846 | m_errorMonitor->SetDesiredFailureMsg( |
| 10847 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10848 | "Duplicate vertex input binding descriptions for binding 0"); |
| 10849 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10851 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10852 | |
| 10853 | /* Two binding descriptions for binding 0 */ |
| 10854 | VkVertexInputBindingDescription input_bindings[2]; |
| 10855 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10856 | |
| 10857 | VkVertexInputAttributeDescription input_attrib; |
| 10858 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10859 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10860 | |
| 10861 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10862 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10863 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10864 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10865 | "out gl_PerVertex {\n" |
| 10866 | " vec4 gl_Position;\n" |
| 10867 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10868 | "void main(){\n" |
| 10869 | " gl_Position = vec4(x);\n" |
| 10870 | "}\n"; |
| 10871 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10872 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10873 | "\n" |
| 10874 | "layout(location=0) out vec4 color;\n" |
| 10875 | "void main(){\n" |
| 10876 | " color = vec4(1);\n" |
| 10877 | "}\n"; |
| 10878 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10879 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10880 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10881 | |
| 10882 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10883 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10884 | pipe.AddShader(&vs); |
| 10885 | pipe.AddShader(&fs); |
| 10886 | |
| 10887 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 10888 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10889 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10890 | VkDescriptorSetObj descriptorSet(m_device); |
| 10891 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10892 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10893 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10894 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10895 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10896 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10897 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 10898 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 10899 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 10900 | m_errorMonitor->ExpectSuccess(); |
| 10901 | |
| 10902 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10903 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10904 | |
| 10905 | if (!m_device->phy().features().tessellationShader) { |
| 10906 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 10907 | return; |
| 10908 | } |
| 10909 | |
| 10910 | VkVertexInputBindingDescription input_bindings[1]; |
| 10911 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10912 | |
| 10913 | VkVertexInputAttributeDescription input_attribs[4]; |
| 10914 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 10915 | input_attribs[0].location = 0; |
| 10916 | input_attribs[0].offset = 0; |
| 10917 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10918 | input_attribs[1].location = 2; |
| 10919 | input_attribs[1].offset = 32; |
| 10920 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10921 | input_attribs[2].location = 4; |
| 10922 | input_attribs[2].offset = 64; |
| 10923 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10924 | input_attribs[3].location = 6; |
| 10925 | input_attribs[3].offset = 96; |
| 10926 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10927 | |
| 10928 | char const *vsSource = |
| 10929 | "#version 450\n" |
| 10930 | "\n" |
| 10931 | "layout(location=0) in dmat4 x;\n" |
| 10932 | "out gl_PerVertex {\n" |
| 10933 | " vec4 gl_Position;\n" |
| 10934 | "};\n" |
| 10935 | "void main(){\n" |
| 10936 | " gl_Position = vec4(x[0][0]);\n" |
| 10937 | "}\n"; |
| 10938 | char const *fsSource = |
| 10939 | "#version 450\n" |
| 10940 | "\n" |
| 10941 | "layout(location=0) out vec4 color;\n" |
| 10942 | "void main(){\n" |
| 10943 | " color = vec4(1);\n" |
| 10944 | "}\n"; |
| 10945 | |
| 10946 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10947 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10948 | |
| 10949 | VkPipelineObj pipe(m_device); |
| 10950 | pipe.AddColorAttachment(); |
| 10951 | pipe.AddShader(&vs); |
| 10952 | pipe.AddShader(&fs); |
| 10953 | |
| 10954 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 10955 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 10956 | |
| 10957 | VkDescriptorSetObj descriptorSet(m_device); |
| 10958 | descriptorSet.AppendDummy(); |
| 10959 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10960 | |
| 10961 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10962 | |
| 10963 | m_errorMonitor->VerifyNotFound(); |
| 10964 | } |
| 10965 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10966 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10967 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10968 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10969 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10970 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10971 | |
| 10972 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10973 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10974 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10975 | "out gl_PerVertex {\n" |
| 10976 | " vec4 gl_Position;\n" |
| 10977 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10978 | "void main(){\n" |
| 10979 | " gl_Position = vec4(1);\n" |
| 10980 | "}\n"; |
| 10981 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10982 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10983 | "\n" |
| 10984 | "void main(){\n" |
| 10985 | "}\n"; |
| 10986 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10989 | |
| 10990 | VkPipelineObj pipe(m_device); |
| 10991 | pipe.AddShader(&vs); |
| 10992 | pipe.AddShader(&fs); |
| 10993 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10994 | /* set up CB 0, not written */ |
| 10995 | pipe.AddColorAttachment(); |
| 10996 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10997 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10998 | VkDescriptorSetObj descriptorSet(m_device); |
| 10999 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11000 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11001 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11002 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11003 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11004 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 11005 | } |
| 11006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11007 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11008 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11009 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11010 | "FS writes to output location 1 with no matching attachment"); |
| 11011 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11013 | |
| 11014 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11015 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11016 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11017 | "out gl_PerVertex {\n" |
| 11018 | " vec4 gl_Position;\n" |
| 11019 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11020 | "void main(){\n" |
| 11021 | " gl_Position = vec4(1);\n" |
| 11022 | "}\n"; |
| 11023 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11024 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11025 | "\n" |
| 11026 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11027 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11028 | "void main(){\n" |
| 11029 | " x = vec4(1);\n" |
| 11030 | " y = vec4(1);\n" |
| 11031 | "}\n"; |
| 11032 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11033 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11034 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11035 | |
| 11036 | VkPipelineObj pipe(m_device); |
| 11037 | pipe.AddShader(&vs); |
| 11038 | pipe.AddShader(&fs); |
| 11039 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11040 | /* set up CB 0, not written */ |
| 11041 | pipe.AddColorAttachment(); |
| 11042 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11043 | /* FS writes CB 1, but we don't configure it */ |
| 11044 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11045 | VkDescriptorSetObj descriptorSet(m_device); |
| 11046 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11047 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11048 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11049 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11050 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11051 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 11052 | } |
| 11053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11054 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11055 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11056 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11057 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11058 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11059 | |
| 11060 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11061 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11062 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11063 | "out gl_PerVertex {\n" |
| 11064 | " vec4 gl_Position;\n" |
| 11065 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11066 | "void main(){\n" |
| 11067 | " gl_Position = vec4(1);\n" |
| 11068 | "}\n"; |
| 11069 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11070 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11071 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11072 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11073 | "void main(){\n" |
| 11074 | " x = ivec4(1);\n" |
| 11075 | "}\n"; |
| 11076 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11077 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11078 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11079 | |
| 11080 | VkPipelineObj pipe(m_device); |
| 11081 | pipe.AddShader(&vs); |
| 11082 | pipe.AddShader(&fs); |
| 11083 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11084 | /* set up CB 0; type is UNORM by default */ |
| 11085 | pipe.AddColorAttachment(); |
| 11086 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11087 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11088 | VkDescriptorSetObj descriptorSet(m_device); |
| 11089 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11090 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11091 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11092 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11094 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11095 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 11096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11097 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11098 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11099 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11100 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11102 | |
| 11103 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11104 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11105 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11106 | "out gl_PerVertex {\n" |
| 11107 | " vec4 gl_Position;\n" |
| 11108 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11109 | "void main(){\n" |
| 11110 | " gl_Position = vec4(1);\n" |
| 11111 | "}\n"; |
| 11112 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11113 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11114 | "\n" |
| 11115 | "layout(location=0) out vec4 x;\n" |
| 11116 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 11117 | "void main(){\n" |
| 11118 | " x = vec4(bar.y);\n" |
| 11119 | "}\n"; |
| 11120 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11121 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11122 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11123 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11124 | VkPipelineObj pipe(m_device); |
| 11125 | pipe.AddShader(&vs); |
| 11126 | pipe.AddShader(&fs); |
| 11127 | |
| 11128 | /* set up CB 0; type is UNORM by default */ |
| 11129 | pipe.AddColorAttachment(); |
| 11130 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11131 | |
| 11132 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11133 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11134 | |
| 11135 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11136 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11137 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 11138 | } |
| 11139 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11140 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 11141 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11142 | "not declared in layout"); |
| 11143 | |
| 11144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11145 | |
| 11146 | char const *vsSource = |
| 11147 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11148 | "\n" |
| 11149 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 11150 | "out gl_PerVertex {\n" |
| 11151 | " vec4 gl_Position;\n" |
| 11152 | "};\n" |
| 11153 | "void main(){\n" |
| 11154 | " gl_Position = vec4(consts.x);\n" |
| 11155 | "}\n"; |
| 11156 | char const *fsSource = |
| 11157 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11158 | "\n" |
| 11159 | "layout(location=0) out vec4 x;\n" |
| 11160 | "void main(){\n" |
| 11161 | " x = vec4(1);\n" |
| 11162 | "}\n"; |
| 11163 | |
| 11164 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 11165 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 11166 | |
| 11167 | VkPipelineObj pipe(m_device); |
| 11168 | pipe.AddShader(&vs); |
| 11169 | pipe.AddShader(&fs); |
| 11170 | |
| 11171 | /* set up CB 0; type is UNORM by default */ |
| 11172 | pipe.AddColorAttachment(); |
| 11173 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11174 | |
| 11175 | VkDescriptorSetObj descriptorSet(m_device); |
| 11176 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11177 | |
| 11178 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 11179 | |
| 11180 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11181 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 11182 | } |
| 11183 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 11184 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 11185 | m_errorMonitor->SetDesiredFailureMsg( |
| 11186 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11187 | "Shader uses descriptor slot 0.0"); |
| 11188 | |
| 11189 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11190 | |
| 11191 | char const *csSource = |
| 11192 | "#version 450\n" |
| 11193 | "\n" |
| 11194 | "layout(local_size_x=1) in;\n" |
| 11195 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11196 | "void main(){\n" |
| 11197 | " x = vec4(1);\n" |
| 11198 | "}\n"; |
| 11199 | |
| 11200 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11201 | |
| 11202 | VkDescriptorSetObj descriptorSet(m_device); |
| 11203 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11204 | |
| 11205 | VkComputePipelineCreateInfo cpci = { |
| 11206 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11207 | nullptr, 0, { |
| 11208 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11209 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11210 | cs.handle(), "main", nullptr |
| 11211 | }, |
| 11212 | descriptorSet.GetPipelineLayout(), |
| 11213 | VK_NULL_HANDLE, -1 |
| 11214 | }; |
| 11215 | |
| 11216 | VkPipeline pipe; |
| 11217 | VkResult err = vkCreateComputePipelines( |
| 11218 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11219 | |
| 11220 | m_errorMonitor->VerifyFound(); |
| 11221 | |
| 11222 | if (err == VK_SUCCESS) { |
| 11223 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11224 | } |
| 11225 | } |
| 11226 | |
| 11227 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 11228 | m_errorMonitor->ExpectSuccess(); |
| 11229 | |
| 11230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11231 | |
| 11232 | char const *csSource = |
| 11233 | "#version 450\n" |
| 11234 | "\n" |
| 11235 | "layout(local_size_x=1) in;\n" |
| 11236 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 11237 | "void main(){\n" |
| 11238 | " // x is not used.\n" |
| 11239 | "}\n"; |
| 11240 | |
| 11241 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 11242 | |
| 11243 | VkDescriptorSetObj descriptorSet(m_device); |
| 11244 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 11245 | |
| 11246 | VkComputePipelineCreateInfo cpci = { |
| 11247 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 11248 | nullptr, 0, { |
| 11249 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 11250 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 11251 | cs.handle(), "main", nullptr |
| 11252 | }, |
| 11253 | descriptorSet.GetPipelineLayout(), |
| 11254 | VK_NULL_HANDLE, -1 |
| 11255 | }; |
| 11256 | |
| 11257 | VkPipeline pipe; |
| 11258 | VkResult err = vkCreateComputePipelines( |
| 11259 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 11260 | |
| 11261 | m_errorMonitor->VerifyNotFound(); |
| 11262 | |
| 11263 | if (err == VK_SUCCESS) { |
| 11264 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 11265 | } |
| 11266 | } |
| 11267 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11268 | #endif // SHADER_CHECKER_TESTS |
| 11269 | |
| 11270 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11271 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11272 | m_errorMonitor->SetDesiredFailureMsg( |
| 11273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11274 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11275 | |
| 11276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11277 | |
| 11278 | // Create an image |
| 11279 | VkImage image; |
| 11280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11281 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11282 | const int32_t tex_width = 32; |
| 11283 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11284 | |
| 11285 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11286 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11287 | image_create_info.pNext = NULL; |
| 11288 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11289 | image_create_info.format = tex_format; |
| 11290 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11291 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11292 | image_create_info.extent.depth = 1; |
| 11293 | image_create_info.mipLevels = 1; |
| 11294 | image_create_info.arrayLayers = 1; |
| 11295 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11296 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11297 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11298 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11299 | |
| 11300 | // Introduce error by sending down a bogus width extent |
| 11301 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11302 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11303 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11304 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11305 | } |
| 11306 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 11307 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 11308 | m_errorMonitor->SetDesiredFailureMsg( |
| 11309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11310 | "CreateImage extents is 0 for at least one required dimension"); |
| 11311 | |
| 11312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11313 | |
| 11314 | // Create an image |
| 11315 | VkImage image; |
| 11316 | |
| 11317 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11318 | const int32_t tex_width = 32; |
| 11319 | const int32_t tex_height = 32; |
| 11320 | |
| 11321 | VkImageCreateInfo image_create_info = {}; |
| 11322 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11323 | image_create_info.pNext = NULL; |
| 11324 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11325 | image_create_info.format = tex_format; |
| 11326 | image_create_info.extent.width = tex_width; |
| 11327 | image_create_info.extent.height = tex_height; |
| 11328 | image_create_info.extent.depth = 1; |
| 11329 | image_create_info.mipLevels = 1; |
| 11330 | image_create_info.arrayLayers = 1; |
| 11331 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11332 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11333 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11334 | image_create_info.flags = 0; |
| 11335 | |
| 11336 | // Introduce error by sending down a bogus width extent |
| 11337 | image_create_info.extent.width = 0; |
| 11338 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 11339 | |
| 11340 | m_errorMonitor->VerifyFound(); |
| 11341 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11342 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 11343 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11344 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11345 | TEST_F(VkLayerTest, InvalidImageView) { |
| 11346 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11347 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11348 | m_errorMonitor->SetDesiredFailureMsg( |
| 11349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11350 | "vkCreateImageView called with baseMipLevel 10 "); |
| 11351 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11352 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11353 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11354 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11355 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11357 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11358 | const int32_t tex_width = 32; |
| 11359 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11360 | |
| 11361 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11362 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11363 | image_create_info.pNext = NULL; |
| 11364 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11365 | image_create_info.format = tex_format; |
| 11366 | image_create_info.extent.width = tex_width; |
| 11367 | image_create_info.extent.height = tex_height; |
| 11368 | image_create_info.extent.depth = 1; |
| 11369 | image_create_info.mipLevels = 1; |
| 11370 | image_create_info.arrayLayers = 1; |
| 11371 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11372 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11373 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11374 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11375 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11376 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11377 | ASSERT_VK_SUCCESS(err); |
| 11378 | |
| 11379 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11380 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11381 | image_view_create_info.image = image; |
| 11382 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11383 | image_view_create_info.format = tex_format; |
| 11384 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11385 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 11386 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11387 | image_view_create_info.subresourceRange.aspectMask = |
| 11388 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11389 | |
| 11390 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11391 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11392 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11394 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 11395 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11396 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11397 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11398 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 11399 | TEST_DESCRIPTION( |
| 11400 | "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] | 11401 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11402 | "vkCreateImageView: Color image " |
| 11403 | "formats must have ONLY the " |
| 11404 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11405 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11406 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11407 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11408 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 11409 | VkImageObj image(m_device); |
| 11410 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 11411 | VK_IMAGE_TILING_LINEAR, 0); |
| 11412 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11413 | |
| 11414 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11415 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 11416 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11417 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11418 | image_view_create_info.format = tex_format; |
| 11419 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11420 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11421 | // Cause an error by setting an invalid image aspect |
| 11422 | image_view_create_info.subresourceRange.aspectMask = |
| 11423 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11424 | |
| 11425 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 11426 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11427 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11428 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 11429 | } |
| 11430 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11431 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11432 | VkResult err; |
| 11433 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11434 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11435 | m_errorMonitor->SetDesiredFailureMsg( |
| 11436 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11437 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11438 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11439 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11440 | |
| 11441 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11442 | VkImage srcImage; |
| 11443 | VkImage dstImage; |
| 11444 | VkDeviceMemory srcMem; |
| 11445 | VkDeviceMemory destMem; |
| 11446 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11447 | |
| 11448 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11449 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11450 | image_create_info.pNext = NULL; |
| 11451 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11452 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11453 | image_create_info.extent.width = 32; |
| 11454 | image_create_info.extent.height = 32; |
| 11455 | image_create_info.extent.depth = 1; |
| 11456 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11457 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11458 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11459 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11460 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11461 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11463 | err = |
| 11464 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11465 | ASSERT_VK_SUCCESS(err); |
| 11466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11467 | err = |
| 11468 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11469 | ASSERT_VK_SUCCESS(err); |
| 11470 | |
| 11471 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11472 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11473 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11474 | memAlloc.pNext = NULL; |
| 11475 | memAlloc.allocationSize = 0; |
| 11476 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11477 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11478 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11479 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11480 | pass = |
| 11481 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11482 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11483 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11484 | ASSERT_VK_SUCCESS(err); |
| 11485 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11486 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11487 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11488 | pass = |
| 11489 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11490 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11491 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11492 | ASSERT_VK_SUCCESS(err); |
| 11493 | |
| 11494 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11495 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11496 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11497 | ASSERT_VK_SUCCESS(err); |
| 11498 | |
| 11499 | BeginCommandBuffer(); |
| 11500 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11501 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11502 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11503 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11504 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11505 | copyRegion.srcOffset.x = 0; |
| 11506 | copyRegion.srcOffset.y = 0; |
| 11507 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11508 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11509 | copyRegion.dstSubresource.mipLevel = 0; |
| 11510 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11511 | // Introduce failure by forcing the dst layerCount to differ from src |
| 11512 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11513 | copyRegion.dstOffset.x = 0; |
| 11514 | copyRegion.dstOffset.y = 0; |
| 11515 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11516 | copyRegion.extent.width = 1; |
| 11517 | copyRegion.extent.height = 1; |
| 11518 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11519 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11520 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11521 | EndCommandBuffer(); |
| 11522 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11523 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11524 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11525 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11526 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11527 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11528 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11529 | } |
| 11530 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11531 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 11532 | |
| 11533 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 11534 | |
| 11535 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11536 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11537 | VkImageObj image(m_device); |
| 11538 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 11539 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 11540 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 11541 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 11542 | ASSERT_TRUE(image.initialized()); |
| 11543 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 11544 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 11545 | VkImageCreateInfo image_create_info; |
| 11546 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11547 | image_create_info.pNext = NULL; |
| 11548 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11549 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 11550 | image_create_info.extent.width = 32; |
| 11551 | image_create_info.extent.height = 32; |
| 11552 | image_create_info.extent.depth = 1; |
| 11553 | image_create_info.mipLevels = 1; |
| 11554 | image_create_info.arrayLayers = 1; |
| 11555 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11556 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11557 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11558 | image_create_info.flags = 0; |
| 11559 | |
| 11560 | m_errorMonitor->SetDesiredFailureMsg( |
| 11561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11562 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 11563 | |
| 11564 | VkImage localImage; |
| 11565 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 11566 | m_errorMonitor->VerifyFound(); |
| 11567 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11568 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 11569 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11570 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 11571 | VkFormat format = static_cast<VkFormat>(f); |
| 11572 | VkFormatProperties fProps = m_device->format_properties(format); |
| 11573 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 11574 | fProps.optimalTilingFeatures == 0) { |
| 11575 | unsupported = format; |
| 11576 | break; |
| 11577 | } |
| 11578 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 11579 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11580 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11581 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11582 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 11583 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11584 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 11585 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 11586 | m_errorMonitor->VerifyFound(); |
| 11587 | } |
| 11588 | } |
| 11589 | |
| 11590 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 11591 | VkResult ret; |
| 11592 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 11593 | |
| 11594 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11595 | |
| 11596 | VkImageObj image(m_device); |
| 11597 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 11598 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 11599 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 11600 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 11601 | ASSERT_TRUE(image.initialized()); |
| 11602 | |
| 11603 | VkImageView imgView; |
| 11604 | VkImageViewCreateInfo imgViewInfo = {}; |
| 11605 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 11606 | imgViewInfo.image = image.handle(); |
| 11607 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11608 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11609 | imgViewInfo.subresourceRange.layerCount = 1; |
| 11610 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 11611 | imgViewInfo.subresourceRange.levelCount = 1; |
| 11612 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11613 | |
| 11614 | m_errorMonitor->SetDesiredFailureMsg( |
| 11615 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11616 | "vkCreateImageView called with baseMipLevel"); |
| 11617 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 11618 | // VIEW_CREATE_ERROR |
| 11619 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 11620 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11621 | m_errorMonitor->VerifyFound(); |
| 11622 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 11623 | |
| 11624 | m_errorMonitor->SetDesiredFailureMsg( |
| 11625 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11626 | "vkCreateImageView called with baseArrayLayer"); |
| 11627 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 11628 | // VIEW_CREATE_ERROR |
| 11629 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 11630 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11631 | m_errorMonitor->VerifyFound(); |
| 11632 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 11633 | |
| 11634 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11635 | "vkCreateImageView called with 0 in " |
| 11636 | "pCreateInfo->subresourceRange." |
| 11637 | "levelCount"); |
| 11638 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11639 | imgViewInfo.subresourceRange.levelCount = 0; |
| 11640 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11641 | m_errorMonitor->VerifyFound(); |
| 11642 | imgViewInfo.subresourceRange.levelCount = 1; |
| 11643 | |
| 11644 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11645 | "vkCreateImageView called with 0 in " |
| 11646 | "pCreateInfo->subresourceRange." |
| 11647 | "layerCount"); |
| 11648 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11649 | imgViewInfo.subresourceRange.layerCount = 0; |
| 11650 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11651 | m_errorMonitor->VerifyFound(); |
| 11652 | imgViewInfo.subresourceRange.layerCount = 1; |
| 11653 | |
| 11654 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11655 | "but both must be color formats"); |
| 11656 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 11657 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11658 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11659 | m_errorMonitor->VerifyFound(); |
| 11660 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11661 | |
| 11662 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11663 | "Formats MUST be IDENTICAL unless " |
| 11664 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 11665 | "was set on image creation."); |
| 11666 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 11667 | // VIEW_CREATE_ERROR |
| 11668 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 11669 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11670 | m_errorMonitor->VerifyFound(); |
| 11671 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11672 | |
| 11673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11674 | "can support ImageViews with " |
| 11675 | "differing formats but they must be " |
| 11676 | "in the same compatibility class."); |
| 11677 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 11678 | // VIEW_CREATE_ERROR |
| 11679 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 11680 | VkImage mutImage; |
| 11681 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 11682 | assert( |
| 11683 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 11684 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 11685 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 11686 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11687 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 11688 | ASSERT_VK_SUCCESS(ret); |
| 11689 | imgViewInfo.image = mutImage; |
| 11690 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11691 | m_errorMonitor->VerifyFound(); |
| 11692 | imgViewInfo.image = image.handle(); |
| 11693 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 11694 | } |
| 11695 | |
| 11696 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 11697 | |
| 11698 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 11699 | |
| 11700 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11701 | |
| 11702 | VkImageObj image(m_device); |
| 11703 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 11704 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 11705 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 11706 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 11707 | ASSERT_TRUE(image.initialized()); |
| 11708 | |
| 11709 | m_errorMonitor->SetDesiredFailureMsg( |
| 11710 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11711 | "number of layers in image subresource is zero"); |
| 11712 | vk_testing::Buffer buffer; |
| 11713 | VkMemoryPropertyFlags reqs = 0; |
| 11714 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 11715 | VkBufferImageCopy region = {}; |
| 11716 | region.bufferRowLength = 128; |
| 11717 | region.bufferImageHeight = 128; |
| 11718 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11719 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 11720 | region.imageSubresource.layerCount = 0; |
| 11721 | region.imageExtent.height = 4; |
| 11722 | region.imageExtent.width = 4; |
| 11723 | region.imageExtent.depth = 1; |
| 11724 | m_commandBuffer->BeginCommandBuffer(); |
| 11725 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11726 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11727 | 1, ®ion); |
| 11728 | m_errorMonitor->VerifyFound(); |
| 11729 | region.imageSubresource.layerCount = 1; |
| 11730 | |
| 11731 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11732 | "aspectMasks for each region must " |
| 11733 | "specify only COLOR or DEPTH or " |
| 11734 | "STENCIL"); |
| 11735 | // Expect MISMATCHED_IMAGE_ASPECT |
| 11736 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 11737 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11738 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11739 | 1, ®ion); |
| 11740 | m_errorMonitor->VerifyFound(); |
| 11741 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11742 | |
| 11743 | m_errorMonitor->SetDesiredFailureMsg( |
| 11744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11745 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 11746 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 11747 | // Expect INVALID_FILTER |
| 11748 | VkImageObj intImage1(m_device); |
| 11749 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 11750 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11751 | 0); |
| 11752 | VkImageObj intImage2(m_device); |
| 11753 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 11754 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11755 | 0); |
| 11756 | VkImageBlit blitRegion = {}; |
| 11757 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11758 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 11759 | blitRegion.srcSubresource.layerCount = 1; |
| 11760 | blitRegion.srcSubresource.mipLevel = 0; |
| 11761 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11762 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 11763 | blitRegion.dstSubresource.layerCount = 1; |
| 11764 | blitRegion.dstSubresource.mipLevel = 0; |
| 11765 | |
| 11766 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 11767 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 11768 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 11769 | m_errorMonitor->VerifyFound(); |
| 11770 | |
| 11771 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11772 | "called with 0 in ppMemoryBarriers"); |
| 11773 | VkImageMemoryBarrier img_barrier; |
| 11774 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 11775 | img_barrier.pNext = NULL; |
| 11776 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 11777 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 11778 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11779 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11780 | img_barrier.image = image.handle(); |
| 11781 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11782 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11783 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11784 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 11785 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 11786 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 11787 | img_barrier.subresourceRange.layerCount = 0; |
| 11788 | img_barrier.subresourceRange.levelCount = 1; |
| 11789 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 11790 | VK_PIPELINE_STAGE_HOST_BIT, |
| 11791 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 11792 | nullptr, 1, &img_barrier); |
| 11793 | m_errorMonitor->VerifyFound(); |
| 11794 | img_barrier.subresourceRange.layerCount = 1; |
| 11795 | } |
| 11796 | |
| 11797 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 11798 | |
| 11799 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 11800 | |
| 11801 | m_errorMonitor->SetDesiredFailureMsg( |
| 11802 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11803 | "CreateImage extents exceed allowable limits for format"); |
| 11804 | VkImageCreateInfo image_create_info = {}; |
| 11805 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11806 | image_create_info.pNext = NULL; |
| 11807 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11808 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11809 | image_create_info.extent.width = 32; |
| 11810 | image_create_info.extent.height = 32; |
| 11811 | image_create_info.extent.depth = 1; |
| 11812 | image_create_info.mipLevels = 1; |
| 11813 | image_create_info.arrayLayers = 1; |
| 11814 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11815 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11816 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11817 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11818 | image_create_info.flags = 0; |
| 11819 | |
| 11820 | VkImage nullImg; |
| 11821 | VkImageFormatProperties imgFmtProps; |
| 11822 | vkGetPhysicalDeviceImageFormatProperties( |
| 11823 | gpu(), image_create_info.format, image_create_info.imageType, |
| 11824 | image_create_info.tiling, image_create_info.usage, |
| 11825 | image_create_info.flags, &imgFmtProps); |
| 11826 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 11827 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11828 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11829 | m_errorMonitor->VerifyFound(); |
| 11830 | image_create_info.extent.depth = 1; |
| 11831 | |
| 11832 | m_errorMonitor->SetDesiredFailureMsg( |
| 11833 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11834 | "exceeds allowable maximum supported by format of"); |
| 11835 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 11836 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11837 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11838 | m_errorMonitor->VerifyFound(); |
| 11839 | image_create_info.mipLevels = 1; |
| 11840 | |
| 11841 | m_errorMonitor->SetDesiredFailureMsg( |
| 11842 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11843 | "exceeds allowable maximum supported by format of"); |
| 11844 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 11845 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11846 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11847 | m_errorMonitor->VerifyFound(); |
| 11848 | image_create_info.arrayLayers = 1; |
| 11849 | |
| 11850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11851 | "is not supported by format"); |
| 11852 | int samples = imgFmtProps.sampleCounts >> 1; |
| 11853 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 11854 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11855 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11856 | m_errorMonitor->VerifyFound(); |
| 11857 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11858 | |
| 11859 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11860 | "pCreateInfo->initialLayout, must be " |
| 11861 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 11862 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 11863 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11864 | // Expect INVALID_LAYOUT |
| 11865 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11866 | m_errorMonitor->VerifyFound(); |
| 11867 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11868 | } |
| 11869 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11870 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11871 | VkResult err; |
| 11872 | bool pass; |
| 11873 | |
| 11874 | // Create color images with different format sizes and try to copy between them |
| 11875 | m_errorMonitor->SetDesiredFailureMsg( |
| 11876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11877 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 11878 | |
| 11879 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11880 | |
| 11881 | // Create two images of different types and try to copy between them |
| 11882 | VkImage srcImage; |
| 11883 | VkImage dstImage; |
| 11884 | VkDeviceMemory srcMem; |
| 11885 | VkDeviceMemory destMem; |
| 11886 | VkMemoryRequirements memReqs; |
| 11887 | |
| 11888 | VkImageCreateInfo image_create_info = {}; |
| 11889 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11890 | image_create_info.pNext = NULL; |
| 11891 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11892 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11893 | image_create_info.extent.width = 32; |
| 11894 | image_create_info.extent.height = 32; |
| 11895 | image_create_info.extent.depth = 1; |
| 11896 | image_create_info.mipLevels = 1; |
| 11897 | image_create_info.arrayLayers = 1; |
| 11898 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11899 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11900 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11901 | image_create_info.flags = 0; |
| 11902 | |
| 11903 | err = |
| 11904 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 11905 | ASSERT_VK_SUCCESS(err); |
| 11906 | |
| 11907 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11908 | // Introduce failure by creating second image with a different-sized format. |
| 11909 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 11910 | |
| 11911 | err = |
| 11912 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 11913 | ASSERT_VK_SUCCESS(err); |
| 11914 | |
| 11915 | // Allocate memory |
| 11916 | VkMemoryAllocateInfo memAlloc = {}; |
| 11917 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11918 | memAlloc.pNext = NULL; |
| 11919 | memAlloc.allocationSize = 0; |
| 11920 | memAlloc.memoryTypeIndex = 0; |
| 11921 | |
| 11922 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 11923 | memAlloc.allocationSize = memReqs.size; |
| 11924 | pass = |
| 11925 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11926 | ASSERT_TRUE(pass); |
| 11927 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 11928 | ASSERT_VK_SUCCESS(err); |
| 11929 | |
| 11930 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 11931 | memAlloc.allocationSize = memReqs.size; |
| 11932 | pass = |
| 11933 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11934 | ASSERT_TRUE(pass); |
| 11935 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 11936 | ASSERT_VK_SUCCESS(err); |
| 11937 | |
| 11938 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11939 | ASSERT_VK_SUCCESS(err); |
| 11940 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 11941 | ASSERT_VK_SUCCESS(err); |
| 11942 | |
| 11943 | BeginCommandBuffer(); |
| 11944 | VkImageCopy copyRegion; |
| 11945 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11946 | copyRegion.srcSubresource.mipLevel = 0; |
| 11947 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 11948 | copyRegion.srcSubresource.layerCount = 0; |
| 11949 | copyRegion.srcOffset.x = 0; |
| 11950 | copyRegion.srcOffset.y = 0; |
| 11951 | copyRegion.srcOffset.z = 0; |
| 11952 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11953 | copyRegion.dstSubresource.mipLevel = 0; |
| 11954 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11955 | copyRegion.dstSubresource.layerCount = 0; |
| 11956 | copyRegion.dstOffset.x = 0; |
| 11957 | copyRegion.dstOffset.y = 0; |
| 11958 | copyRegion.dstOffset.z = 0; |
| 11959 | copyRegion.extent.width = 1; |
| 11960 | copyRegion.extent.height = 1; |
| 11961 | copyRegion.extent.depth = 1; |
| 11962 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11963 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 11964 | EndCommandBuffer(); |
| 11965 | |
| 11966 | m_errorMonitor->VerifyFound(); |
| 11967 | |
| 11968 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 11969 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 11970 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11971 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11972 | } |
| 11973 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11974 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 11975 | VkResult err; |
| 11976 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11977 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11978 | // 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] | 11979 | m_errorMonitor->SetDesiredFailureMsg( |
| 11980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11981 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11982 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11984 | |
| 11985 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11986 | VkImage srcImage; |
| 11987 | VkImage dstImage; |
| 11988 | VkDeviceMemory srcMem; |
| 11989 | VkDeviceMemory destMem; |
| 11990 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -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 = VK_FORMAT_B8G8R8A8_UNORM; |
| 11997 | image_create_info.extent.width = 32; |
| 11998 | image_create_info.extent.height = 32; |
| 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_TRANSFER_SRC_BIT; |
| 12005 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12007 | err = |
| 12008 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12009 | ASSERT_VK_SUCCESS(err); |
| 12010 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 12011 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 12012 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12013 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12014 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 12015 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12016 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12018 | err = |
| 12019 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12020 | ASSERT_VK_SUCCESS(err); |
| 12021 | |
| 12022 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12023 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12024 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12025 | memAlloc.pNext = NULL; |
| 12026 | memAlloc.allocationSize = 0; |
| 12027 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12028 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12029 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12030 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12031 | pass = |
| 12032 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12033 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12034 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12035 | ASSERT_VK_SUCCESS(err); |
| 12036 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12037 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12038 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12039 | pass = |
| 12040 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12041 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12042 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12043 | ASSERT_VK_SUCCESS(err); |
| 12044 | |
| 12045 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12046 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12047 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12048 | ASSERT_VK_SUCCESS(err); |
| 12049 | |
| 12050 | BeginCommandBuffer(); |
| 12051 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12052 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12053 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12054 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12055 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12056 | copyRegion.srcOffset.x = 0; |
| 12057 | copyRegion.srcOffset.y = 0; |
| 12058 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12059 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12060 | copyRegion.dstSubresource.mipLevel = 0; |
| 12061 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 12062 | copyRegion.dstSubresource.layerCount = 0; |
| 12063 | copyRegion.dstOffset.x = 0; |
| 12064 | copyRegion.dstOffset.y = 0; |
| 12065 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12066 | copyRegion.extent.width = 1; |
| 12067 | copyRegion.extent.height = 1; |
| 12068 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12069 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12070 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12071 | EndCommandBuffer(); |
| 12072 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12073 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12074 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12075 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12076 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12077 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12078 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12079 | } |
| 12080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12081 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 12082 | VkResult err; |
| 12083 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12085 | m_errorMonitor->SetDesiredFailureMsg( |
| 12086 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12087 | "vkCmdResolveImage called with source sample count less than 2."); |
| 12088 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12090 | |
| 12091 | // 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] | 12092 | VkImage srcImage; |
| 12093 | VkImage dstImage; |
| 12094 | VkDeviceMemory srcMem; |
| 12095 | VkDeviceMemory destMem; |
| 12096 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12097 | |
| 12098 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12099 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12100 | image_create_info.pNext = NULL; |
| 12101 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12102 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12103 | image_create_info.extent.width = 32; |
| 12104 | image_create_info.extent.height = 1; |
| 12105 | image_create_info.extent.depth = 1; |
| 12106 | image_create_info.mipLevels = 1; |
| 12107 | image_create_info.arrayLayers = 1; |
| 12108 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12109 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12110 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 12111 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12113 | err = |
| 12114 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12115 | ASSERT_VK_SUCCESS(err); |
| 12116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12117 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12119 | err = |
| 12120 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12121 | ASSERT_VK_SUCCESS(err); |
| 12122 | |
| 12123 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12124 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12125 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12126 | memAlloc.pNext = NULL; |
| 12127 | memAlloc.allocationSize = 0; |
| 12128 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12129 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12130 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12131 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12132 | pass = |
| 12133 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12134 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12135 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12136 | ASSERT_VK_SUCCESS(err); |
| 12137 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12138 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12139 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12140 | pass = |
| 12141 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12142 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12143 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12144 | ASSERT_VK_SUCCESS(err); |
| 12145 | |
| 12146 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12147 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12148 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12149 | ASSERT_VK_SUCCESS(err); |
| 12150 | |
| 12151 | BeginCommandBuffer(); |
| 12152 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12153 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12154 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12155 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12156 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12157 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12158 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12159 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12160 | resolveRegion.srcOffset.x = 0; |
| 12161 | resolveRegion.srcOffset.y = 0; |
| 12162 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12163 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12164 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12165 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12166 | resolveRegion.dstSubresource.layerCount = 0; |
| 12167 | resolveRegion.dstOffset.x = 0; |
| 12168 | resolveRegion.dstOffset.y = 0; |
| 12169 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12170 | resolveRegion.extent.width = 1; |
| 12171 | resolveRegion.extent.height = 1; |
| 12172 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12173 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12174 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12175 | EndCommandBuffer(); |
| 12176 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12177 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12178 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12179 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12180 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12181 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12182 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12183 | } |
| 12184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12185 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 12186 | VkResult err; |
| 12187 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12189 | m_errorMonitor->SetDesiredFailureMsg( |
| 12190 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12191 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 12192 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12193 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12194 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12195 | // 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] | 12196 | VkImage srcImage; |
| 12197 | VkImage dstImage; |
| 12198 | VkDeviceMemory srcMem; |
| 12199 | VkDeviceMemory destMem; |
| 12200 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12201 | |
| 12202 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12203 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12204 | image_create_info.pNext = NULL; |
| 12205 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12206 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12207 | image_create_info.extent.width = 32; |
| 12208 | image_create_info.extent.height = 1; |
| 12209 | image_create_info.extent.depth = 1; |
| 12210 | image_create_info.mipLevels = 1; |
| 12211 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 12212 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12213 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12214 | // Note: Some implementations expect color attachment usage for any |
| 12215 | // multisample surface |
| 12216 | image_create_info.usage = |
| 12217 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12218 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12220 | err = |
| 12221 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12222 | ASSERT_VK_SUCCESS(err); |
| 12223 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12224 | // Note: Some implementations expect color attachment usage for any |
| 12225 | // multisample surface |
| 12226 | image_create_info.usage = |
| 12227 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12229 | err = |
| 12230 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12231 | ASSERT_VK_SUCCESS(err); |
| 12232 | |
| 12233 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12234 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12235 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12236 | memAlloc.pNext = NULL; |
| 12237 | memAlloc.allocationSize = 0; |
| 12238 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12239 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12240 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12241 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12242 | pass = |
| 12243 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12244 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12245 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12246 | ASSERT_VK_SUCCESS(err); |
| 12247 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12248 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12249 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12250 | pass = |
| 12251 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12252 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12253 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12254 | ASSERT_VK_SUCCESS(err); |
| 12255 | |
| 12256 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12257 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12258 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12259 | ASSERT_VK_SUCCESS(err); |
| 12260 | |
| 12261 | BeginCommandBuffer(); |
| 12262 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12263 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12264 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12265 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12266 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12267 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12268 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12269 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12270 | resolveRegion.srcOffset.x = 0; |
| 12271 | resolveRegion.srcOffset.y = 0; |
| 12272 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12273 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12274 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12275 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12276 | resolveRegion.dstSubresource.layerCount = 0; |
| 12277 | resolveRegion.dstOffset.x = 0; |
| 12278 | resolveRegion.dstOffset.y = 0; |
| 12279 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12280 | resolveRegion.extent.width = 1; |
| 12281 | resolveRegion.extent.height = 1; |
| 12282 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12283 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12284 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12285 | EndCommandBuffer(); |
| 12286 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12287 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12288 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12289 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12290 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12291 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12292 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12293 | } |
| 12294 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12295 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 12296 | VkResult err; |
| 12297 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12299 | m_errorMonitor->SetDesiredFailureMsg( |
| 12300 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12301 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 12302 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12303 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12304 | |
| 12305 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12306 | VkImage srcImage; |
| 12307 | VkImage dstImage; |
| 12308 | VkDeviceMemory srcMem; |
| 12309 | VkDeviceMemory destMem; |
| 12310 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12311 | |
| 12312 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12313 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12314 | image_create_info.pNext = NULL; |
| 12315 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12316 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12317 | image_create_info.extent.width = 32; |
| 12318 | image_create_info.extent.height = 1; |
| 12319 | image_create_info.extent.depth = 1; |
| 12320 | image_create_info.mipLevels = 1; |
| 12321 | image_create_info.arrayLayers = 1; |
| 12322 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 12323 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12324 | // Note: Some implementations expect color attachment usage for any |
| 12325 | // multisample surface |
| 12326 | image_create_info.usage = |
| 12327 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12328 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12329 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12330 | err = |
| 12331 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12332 | ASSERT_VK_SUCCESS(err); |
| 12333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12334 | // Set format to something other than source image |
| 12335 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 12336 | // Note: Some implementations expect color attachment usage for any |
| 12337 | // multisample surface |
| 12338 | image_create_info.usage = |
| 12339 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12340 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12342 | err = |
| 12343 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12344 | ASSERT_VK_SUCCESS(err); |
| 12345 | |
| 12346 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12347 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12348 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12349 | memAlloc.pNext = NULL; |
| 12350 | memAlloc.allocationSize = 0; |
| 12351 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12352 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12353 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12354 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12355 | pass = |
| 12356 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12357 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12358 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12359 | ASSERT_VK_SUCCESS(err); |
| 12360 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12361 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12362 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12363 | pass = |
| 12364 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12365 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12366 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12367 | ASSERT_VK_SUCCESS(err); |
| 12368 | |
| 12369 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12370 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12371 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12372 | ASSERT_VK_SUCCESS(err); |
| 12373 | |
| 12374 | BeginCommandBuffer(); |
| 12375 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12376 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12377 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12378 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12379 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12380 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12381 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12382 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12383 | resolveRegion.srcOffset.x = 0; |
| 12384 | resolveRegion.srcOffset.y = 0; |
| 12385 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12386 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12387 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12388 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12389 | resolveRegion.dstSubresource.layerCount = 0; |
| 12390 | resolveRegion.dstOffset.x = 0; |
| 12391 | resolveRegion.dstOffset.y = 0; |
| 12392 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12393 | resolveRegion.extent.width = 1; |
| 12394 | resolveRegion.extent.height = 1; |
| 12395 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12396 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12397 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12398 | EndCommandBuffer(); |
| 12399 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12400 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12401 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12402 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12403 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12404 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12405 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12406 | } |
| 12407 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12408 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 12409 | VkResult err; |
| 12410 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12411 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12412 | m_errorMonitor->SetDesiredFailureMsg( |
| 12413 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12414 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 12415 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12417 | |
| 12418 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12419 | VkImage srcImage; |
| 12420 | VkImage dstImage; |
| 12421 | VkDeviceMemory srcMem; |
| 12422 | VkDeviceMemory destMem; |
| 12423 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12424 | |
| 12425 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12426 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12427 | image_create_info.pNext = NULL; |
| 12428 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12429 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12430 | image_create_info.extent.width = 32; |
| 12431 | image_create_info.extent.height = 1; |
| 12432 | image_create_info.extent.depth = 1; |
| 12433 | image_create_info.mipLevels = 1; |
| 12434 | image_create_info.arrayLayers = 1; |
| 12435 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 12436 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12437 | // Note: Some implementations expect color attachment usage for any |
| 12438 | // multisample surface |
| 12439 | image_create_info.usage = |
| 12440 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12441 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12442 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12443 | err = |
| 12444 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12445 | ASSERT_VK_SUCCESS(err); |
| 12446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12447 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 12448 | // Note: Some implementations expect color attachment usage for any |
| 12449 | // multisample surface |
| 12450 | image_create_info.usage = |
| 12451 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12452 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12453 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12454 | err = |
| 12455 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12456 | ASSERT_VK_SUCCESS(err); |
| 12457 | |
| 12458 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12459 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12460 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 12461 | memAlloc.pNext = NULL; |
| 12462 | memAlloc.allocationSize = 0; |
| 12463 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12464 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 12465 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12466 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12467 | pass = |
| 12468 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12469 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12470 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12471 | ASSERT_VK_SUCCESS(err); |
| 12472 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12473 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12474 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12475 | pass = |
| 12476 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 12477 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12478 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12479 | ASSERT_VK_SUCCESS(err); |
| 12480 | |
| 12481 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 12482 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12483 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12484 | ASSERT_VK_SUCCESS(err); |
| 12485 | |
| 12486 | BeginCommandBuffer(); |
| 12487 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12488 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 12489 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12490 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12491 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12492 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 12493 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12494 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12495 | resolveRegion.srcOffset.x = 0; |
| 12496 | resolveRegion.srcOffset.y = 0; |
| 12497 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 12498 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12499 | resolveRegion.dstSubresource.mipLevel = 0; |
| 12500 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 12501 | resolveRegion.dstSubresource.layerCount = 0; |
| 12502 | resolveRegion.dstOffset.x = 0; |
| 12503 | resolveRegion.dstOffset.y = 0; |
| 12504 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12505 | resolveRegion.extent.width = 1; |
| 12506 | resolveRegion.extent.height = 1; |
| 12507 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12508 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 12509 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12510 | EndCommandBuffer(); |
| 12511 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12512 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12513 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12514 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12515 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12516 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 12517 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 12518 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12519 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12520 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12521 | // 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] | 12522 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 12523 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12524 | // The image format check comes 2nd in validation so we trigger it first, |
| 12525 | // 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] | 12526 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12528 | m_errorMonitor->SetDesiredFailureMsg( |
| 12529 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12530 | "Combination depth/stencil image formats can have only the "); |
| 12531 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12532 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12533 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 12534 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12535 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 12536 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12537 | |
| 12538 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12539 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 12540 | ds_pool_ci.pNext = NULL; |
| 12541 | ds_pool_ci.maxSets = 1; |
| 12542 | ds_pool_ci.poolSizeCount = 1; |
| 12543 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12544 | |
| 12545 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12546 | err = |
| 12547 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12548 | ASSERT_VK_SUCCESS(err); |
| 12549 | |
| 12550 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12551 | dsl_binding.binding = 0; |
| 12552 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 12553 | dsl_binding.descriptorCount = 1; |
| 12554 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 12555 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12556 | |
| 12557 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12558 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 12559 | ds_layout_ci.pNext = NULL; |
| 12560 | ds_layout_ci.bindingCount = 1; |
| 12561 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12562 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12563 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 12564 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12565 | ASSERT_VK_SUCCESS(err); |
| 12566 | |
| 12567 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12568 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 12569 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 12570 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12571 | alloc_info.descriptorPool = ds_pool; |
| 12572 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12573 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 12574 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12575 | ASSERT_VK_SUCCESS(err); |
| 12576 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12577 | VkImage image_bad; |
| 12578 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12579 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 12580 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12581 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12582 | const int32_t tex_width = 32; |
| 12583 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12584 | |
| 12585 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12586 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12587 | image_create_info.pNext = NULL; |
| 12588 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12589 | image_create_info.format = tex_format_bad; |
| 12590 | image_create_info.extent.width = tex_width; |
| 12591 | image_create_info.extent.height = tex_height; |
| 12592 | image_create_info.extent.depth = 1; |
| 12593 | image_create_info.mipLevels = 1; |
| 12594 | image_create_info.arrayLayers = 1; |
| 12595 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12596 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12597 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 12598 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 12599 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12601 | err = |
| 12602 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12603 | ASSERT_VK_SUCCESS(err); |
| 12604 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12605 | image_create_info.usage = |
| 12606 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 12607 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 12608 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12609 | ASSERT_VK_SUCCESS(err); |
| 12610 | |
| 12611 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12612 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12613 | image_view_create_info.image = image_bad; |
| 12614 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 12615 | image_view_create_info.format = tex_format_bad; |
| 12616 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 12617 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 12618 | image_view_create_info.subresourceRange.layerCount = 1; |
| 12619 | image_view_create_info.subresourceRange.levelCount = 1; |
| 12620 | image_view_create_info.subresourceRange.aspectMask = |
| 12621 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12622 | |
| 12623 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12624 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 12625 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12626 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12627 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12628 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12629 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 12630 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12631 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 12632 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12633 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12634 | |
| 12635 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 12636 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 12637 | "ClearDepthStencilImage with a color image."); |
| 12638 | |
| 12639 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12640 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 12641 | |
| 12642 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 12643 | BeginCommandBuffer(); |
| 12644 | m_commandBuffer->EndRenderPass(); |
| 12645 | |
| 12646 | // Color image |
| 12647 | VkClearColorValue clear_color; |
| 12648 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 12649 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 12650 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12651 | const int32_t img_width = 32; |
| 12652 | const int32_t img_height = 32; |
| 12653 | VkImageCreateInfo image_create_info = {}; |
| 12654 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12655 | image_create_info.pNext = NULL; |
| 12656 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12657 | image_create_info.format = color_format; |
| 12658 | image_create_info.extent.width = img_width; |
| 12659 | image_create_info.extent.height = img_height; |
| 12660 | image_create_info.extent.depth = 1; |
| 12661 | image_create_info.mipLevels = 1; |
| 12662 | image_create_info.arrayLayers = 1; |
| 12663 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12664 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12665 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 12666 | |
| 12667 | vk_testing::Image color_image; |
| 12668 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 12669 | reqs); |
| 12670 | |
| 12671 | const VkImageSubresourceRange color_range = |
| 12672 | vk_testing::Image::subresource_range(image_create_info, |
| 12673 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 12674 | |
| 12675 | // Depth/Stencil image |
| 12676 | VkClearDepthStencilValue clear_value = {0}; |
| 12677 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 12678 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 12679 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12680 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12681 | ds_image_create_info.extent.width = 64; |
| 12682 | ds_image_create_info.extent.height = 64; |
| 12683 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12684 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 12685 | |
| 12686 | vk_testing::Image ds_image; |
| 12687 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 12688 | reqs); |
| 12689 | |
| 12690 | const VkImageSubresourceRange ds_range = |
| 12691 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 12692 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 12693 | |
| 12694 | m_errorMonitor->SetDesiredFailureMsg( |
| 12695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12696 | "vkCmdClearColorImage called with depth/stencil image."); |
| 12697 | |
| 12698 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12699 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12700 | &color_range); |
| 12701 | |
| 12702 | m_errorMonitor->VerifyFound(); |
| 12703 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 12704 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12705 | "vkCmdClearColorImage called with " |
| 12706 | "image created without " |
| 12707 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 12708 | |
| 12709 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12710 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12711 | &color_range); |
| 12712 | |
| 12713 | m_errorMonitor->VerifyFound(); |
| 12714 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12715 | // Call CmdClearDepthStencilImage with color image |
| 12716 | m_errorMonitor->SetDesiredFailureMsg( |
| 12717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12718 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 12719 | |
| 12720 | vkCmdClearDepthStencilImage( |
| 12721 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 12722 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 12723 | &ds_range); |
| 12724 | |
| 12725 | m_errorMonitor->VerifyFound(); |
| 12726 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12727 | #endif // IMAGE_TESTS |
| 12728 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12729 | int main(int argc, char **argv) { |
| 12730 | int result; |
| 12731 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 12732 | #ifdef ANDROID |
| 12733 | int vulkanSupport = InitVulkan(); |
| 12734 | if (vulkanSupport == 0) |
| 12735 | return 1; |
| 12736 | #endif |
| 12737 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12738 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12739 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12740 | |
| 12741 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 12742 | |
| 12743 | result = RUN_ALL_TESTS(); |
| 12744 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12745 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12746 | return result; |
| 12747 | } |