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 Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (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] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 268 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | |
| 270 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_layer_names; |
| 272 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_extension_names; |
| 274 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 275 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 276 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Since CreateDbgMsgCallback is an instance level extension call |
| 279 | * any extension / layer that utilizes that feature also needs |
| 280 | * to be enabled at create instance time. |
| 281 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 282 | // Use Threading layer first to protect others from |
| 283 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
| 303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 308 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 309 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 311 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 317 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 319 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 323 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 324 | } |
| 325 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
| 329 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
| 331 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
| 336 | instance_extension_names, device_extension_names, |
| 337 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void TearDown() { |
| 341 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
| 346 | VkLayerTest() { |
| 347 | m_enableWSI = false; |
| 348 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * For render test all drawing happens in a single render pass |
| 358 | * on a single command buffer. |
| 359 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
| 376 | return result; |
| 377 | } |
| 378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 380 | const char *fragShaderText, |
| 381 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
| 383 | int i; |
| 384 | struct vktriangle_vs_uniform data; |
| 385 | |
| 386 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
| 388 | glm::mat4 Model = glm::mat4(1.0f); |
| 389 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
| 396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
| 403 | data.position[i][1] = tri_data[i].posY; |
| 404 | data.position[i][2] = tri_data[i].posZ; |
| 405 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
| 407 | data.color[i][1] = tri_data[i].g; |
| 408 | data.color[i][2] = tri_data[i].b; |
| 409 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 416 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 420 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
| 422 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
| 425 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 429 | ia_state.sType = |
| 430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 432 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
| 434 | if (failMask & BsoFailDepthBias) { |
| 435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 437 | rs_state.sType = |
| 438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 439 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
| 444 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
| 446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
| 448 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
| 450 | if (failMask & BsoFailScissor) { |
| 451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
| 453 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
| 455 | if (failMask & BsoFailBlend) { |
| 456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 459 | att_state.blendEnable = VK_TRUE; |
| 460 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
| 462 | if (failMask & BsoFailDepthBounds) { |
| 463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 464 | } |
| 465 | if (failMask & BsoFailStencilReadMask) { |
| 466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 467 | } |
| 468 | if (failMask & BsoFailStencilWriteMask) { |
| 469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 470 | } |
| 471 | if (failMask & BsoFailStencilReference) { |
| 472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 473 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
| 475 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 477 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
| 479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
| 484 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
| 487 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 493 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 494 | VkPipelineObj &pipelineobj, |
| 495 | VkDescriptorSetObj &descriptorSet, |
| 496 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 498 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 499 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 501 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 502 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 505 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 506 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 507 | // correctly |
| 508 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 509 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 510 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 511 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 512 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 513 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 514 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 515 | |
| 516 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 517 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 518 | ds_ci.pNext = NULL; |
| 519 | ds_ci.depthTestEnable = VK_FALSE; |
| 520 | ds_ci.depthWriteEnable = VK_TRUE; |
| 521 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 522 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 523 | if (failMask & BsoFailDepthBounds) { |
| 524 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 525 | ds_ci.maxDepthBounds = 0.0f; |
| 526 | ds_ci.minDepthBounds = 0.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 527 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 528 | ds_ci.stencilTestEnable = VK_TRUE; |
| 529 | ds_ci.front = stencil; |
| 530 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 531 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 532 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 533 | pipelineobj.SetViewport(m_viewports); |
| 534 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 535 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 536 | VkResult err = pipelineobj.CreateVKPipeline( |
| 537 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 538 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 539 | commandBuffer->BindPipeline(pipelineobj); |
| 540 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 541 | } |
| 542 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 543 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 544 | public: |
| 545 | protected: |
| 546 | VkWsiEnabledLayerTest() { |
| 547 | m_enableWSI = true; |
| 548 | } |
| 549 | }; |
| 550 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
| 553 | // ******************************************************************************************************************** |
| 554 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 555 | #if PARAMETER_VALIDATION_TESTS |
| 556 | TEST_F(VkLayerTest, RequiredParameter) { |
| 557 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 558 | "pointer, array, and array count parameters"); |
| 559 | |
| 560 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 561 | |
| 562 | m_errorMonitor->SetDesiredFailureMsg( |
| 563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 564 | "required parameter pFeatures specified as NULL"); |
| 565 | // Specify NULL for a pointer to a handle |
| 566 | // Expected to trigger an error with |
| 567 | // parameter_validation::validate_required_pointer |
| 568 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 569 | m_errorMonitor->VerifyFound(); |
| 570 | |
| 571 | m_errorMonitor->SetDesiredFailureMsg( |
| 572 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 573 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 574 | // Specify NULL for pointer to array count |
| 575 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 576 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 577 | m_errorMonitor->VerifyFound(); |
| 578 | |
| 579 | m_errorMonitor->SetDesiredFailureMsg( |
| 580 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 581 | "parameter viewportCount must be greater than 0"); |
| 582 | // Specify 0 for a required array count |
| 583 | // Expected to trigger an error with parameter_validation::validate_array |
| 584 | VkViewport view_port = {}; |
| 585 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 586 | m_errorMonitor->VerifyFound(); |
| 587 | |
| 588 | m_errorMonitor->SetDesiredFailureMsg( |
| 589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 590 | "required parameter pViewports specified as NULL"); |
| 591 | // Specify NULL for a required array |
| 592 | // Expected to trigger an error with parameter_validation::validate_array |
| 593 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 594 | m_errorMonitor->VerifyFound(); |
| 595 | |
| 596 | m_errorMonitor->SetDesiredFailureMsg( |
| 597 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 598 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 599 | // Specify VK_NULL_HANDLE for a required handle |
| 600 | // Expected to trigger an error with |
| 601 | // parameter_validation::validate_required_handle |
| 602 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 603 | m_errorMonitor->VerifyFound(); |
| 604 | |
| 605 | m_errorMonitor->SetDesiredFailureMsg( |
| 606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 607 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 608 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 609 | // Expected to trigger an error with |
| 610 | // parameter_validation::validate_required_handle_array |
| 611 | VkFence fence = VK_NULL_HANDLE; |
| 612 | vkResetFences(device(), 1, &fence); |
| 613 | m_errorMonitor->VerifyFound(); |
| 614 | |
| 615 | m_errorMonitor->SetDesiredFailureMsg( |
| 616 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 617 | "required parameter pAllocateInfo specified as NULL"); |
| 618 | // Specify NULL for a required struct pointer |
| 619 | // Expected to trigger an error with |
| 620 | // parameter_validation::validate_struct_type |
| 621 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 622 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 623 | m_errorMonitor->VerifyFound(); |
| 624 | |
| 625 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 626 | "value of faceMask must not be 0"); |
| 627 | // Specify 0 for a required VkFlags parameter |
| 628 | // Expected to trigger an error with parameter_validation::validate_flags |
| 629 | m_commandBuffer->SetStencilReference(0, 0); |
| 630 | m_errorMonitor->VerifyFound(); |
| 631 | |
| 632 | m_errorMonitor->SetDesiredFailureMsg( |
| 633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 634 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 635 | // Specify 0 for a required VkFlags array entry |
| 636 | // Expected to trigger an error with |
| 637 | // parameter_validation::validate_flags_array |
| 638 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 639 | VkPipelineStageFlags stageFlags = 0; |
| 640 | VkSubmitInfo submitInfo = {}; |
| 641 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 642 | submitInfo.waitSemaphoreCount = 1; |
| 643 | submitInfo.pWaitSemaphores = &semaphore; |
| 644 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 645 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 646 | m_errorMonitor->VerifyFound(); |
| 647 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 648 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 649 | TEST_F(VkLayerTest, ReservedParameter) { |
| 650 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 651 | |
| 652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 653 | |
| 654 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 655 | " must be 0"); |
| 656 | // Specify 0 for a reserved VkFlags parameter |
| 657 | // Expected to trigger an error with |
| 658 | // parameter_validation::validate_reserved_flags |
| 659 | VkEvent event_handle = VK_NULL_HANDLE; |
| 660 | VkEventCreateInfo event_info = {}; |
| 661 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 662 | event_info.flags = 1; |
| 663 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 664 | m_errorMonitor->VerifyFound(); |
| 665 | } |
| 666 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 667 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 668 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 669 | "structure's sType field"); |
| 670 | |
| 671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 672 | |
| 673 | m_errorMonitor->SetDesiredFailureMsg( |
| 674 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 675 | "parameter pAllocateInfo->sType must be"); |
| 676 | // Zero struct memory, effectively setting sType to |
| 677 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 678 | // Expected to trigger an error with |
| 679 | // parameter_validation::validate_struct_type |
| 680 | VkMemoryAllocateInfo alloc_info = {}; |
| 681 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 682 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 683 | m_errorMonitor->VerifyFound(); |
| 684 | |
| 685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "parameter pSubmits[0].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_array |
| 691 | VkSubmitInfo submit_info = {}; |
| 692 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 693 | m_errorMonitor->VerifyFound(); |
| 694 | } |
| 695 | |
| 696 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 697 | TEST_DESCRIPTION( |
| 698 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 699 | |
| 700 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 701 | |
| 702 | m_errorMonitor->SetDesiredFailureMsg( |
| 703 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 704 | "value of pAllocateInfo->pNext must be NULL"); |
| 705 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 706 | // NULL |
| 707 | // Expected to trigger an error with |
| 708 | // parameter_validation::validate_struct_pnext |
| 709 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 710 | // Zero-initialization will provide the correct sType |
| 711 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 712 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 713 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 714 | memory_alloc_info.pNext = &app_info; |
| 715 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 716 | m_errorMonitor->VerifyFound(); |
| 717 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 718 | m_errorMonitor->SetDesiredFailureMsg( |
| 719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 720 | " chain includes a structure with unexpected VkStructureType "); |
| 721 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 722 | // Expected to trigger an error with |
| 723 | // parameter_validation::validate_struct_pnext |
| 724 | VkDescriptorPoolSize ds_type_count = {}; |
| 725 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 726 | ds_type_count.descriptorCount = 1; |
| 727 | |
| 728 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 729 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 730 | ds_pool_ci.pNext = NULL; |
| 731 | ds_pool_ci.maxSets = 1; |
| 732 | ds_pool_ci.poolSizeCount = 1; |
| 733 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 734 | |
| 735 | VkDescriptorPool ds_pool; |
| 736 | VkResult err = |
| 737 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 738 | ASSERT_VK_SUCCESS(err); |
| 739 | |
| 740 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 741 | dsl_binding.binding = 0; |
| 742 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 743 | dsl_binding.descriptorCount = 1; |
| 744 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 745 | dsl_binding.pImmutableSamplers = NULL; |
| 746 | |
| 747 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 748 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 749 | ds_layout_ci.pNext = NULL; |
| 750 | ds_layout_ci.bindingCount = 1; |
| 751 | ds_layout_ci.pBindings = &dsl_binding; |
| 752 | |
| 753 | VkDescriptorSetLayout ds_layout; |
| 754 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 755 | &ds_layout); |
| 756 | ASSERT_VK_SUCCESS(err); |
| 757 | |
| 758 | VkDescriptorSet descriptorSet; |
| 759 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 760 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 761 | ds_alloc_info.descriptorSetCount = 1; |
| 762 | ds_alloc_info.descriptorPool = ds_pool; |
| 763 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 764 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 765 | &descriptorSet); |
| 766 | ASSERT_VK_SUCCESS(err); |
| 767 | |
| 768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 769 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 770 | pipeline_layout_ci.setLayoutCount = 1; |
| 771 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 772 | |
| 773 | VkPipelineLayout pipeline_layout; |
| 774 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 775 | &pipeline_layout); |
| 776 | ASSERT_VK_SUCCESS(err); |
| 777 | |
| 778 | VkViewport vp = {}; // Just need dummy vp to point to |
| 779 | VkRect2D sc = {}; // dummy scissor to point to |
| 780 | |
| 781 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 782 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 783 | vp_state_ci.scissorCount = 1; |
| 784 | vp_state_ci.pScissors = ≻ |
| 785 | vp_state_ci.viewportCount = 1; |
| 786 | vp_state_ci.pViewports = &vp; |
| 787 | |
| 788 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 789 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 790 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 791 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 792 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 793 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 794 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 795 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 796 | |
| 797 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 798 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 799 | gp_ci.pViewportState = &vp_state_ci; |
| 800 | gp_ci.pRasterizationState = &rs_state_ci; |
| 801 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 802 | gp_ci.layout = pipeline_layout; |
| 803 | gp_ci.renderPass = renderPass(); |
| 804 | |
| 805 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 806 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 807 | pc_ci.initialDataSize = 0; |
| 808 | pc_ci.pInitialData = 0; |
| 809 | |
| 810 | VkPipeline pipeline; |
| 811 | VkPipelineCache pipelineCache; |
| 812 | |
| 813 | err = |
| 814 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 815 | ASSERT_VK_SUCCESS(err); |
| 816 | |
| 817 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 818 | VkApplicationInfo invalid_pnext_struct = {}; |
| 819 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 820 | |
| 821 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 822 | &gp_ci, NULL, &pipeline); |
| 823 | m_errorMonitor->VerifyFound(); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 824 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 825 | |
| 826 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 827 | TEST_DESCRIPTION( |
| 828 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 829 | |
| 830 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 831 | |
| 832 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 833 | "does not fall within the begin..end " |
| 834 | "range of the core VkFormat " |
| 835 | "enumeration tokens"); |
| 836 | // Specify an invalid VkFormat value |
| 837 | // Expected to trigger an error with |
| 838 | // parameter_validation::validate_ranged_enum |
| 839 | VkFormatProperties format_properties; |
| 840 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 841 | &format_properties); |
| 842 | m_errorMonitor->VerifyFound(); |
| 843 | |
| 844 | m_errorMonitor->SetDesiredFailureMsg( |
| 845 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 846 | "contains flag bits that are not recognized members of"); |
| 847 | // Specify an invalid VkFlags bitmask value |
| 848 | // Expected to trigger an error with parameter_validation::validate_flags |
| 849 | VkImageFormatProperties image_format_properties; |
| 850 | vkGetPhysicalDeviceImageFormatProperties( |
| 851 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 852 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 853 | &image_format_properties); |
| 854 | m_errorMonitor->VerifyFound(); |
| 855 | |
| 856 | m_errorMonitor->SetDesiredFailureMsg( |
| 857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 858 | "contains flag bits that are not recognized members of"); |
| 859 | // Specify an invalid VkFlags array entry |
| 860 | // Expected to trigger an error with |
| 861 | // parameter_validation::validate_flags_array |
| 862 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 863 | VkPipelineStageFlags stage_flags = |
| 864 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 865 | VkSubmitInfo submit_info = {}; |
| 866 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 867 | submit_info.waitSemaphoreCount = 1; |
| 868 | submit_info.pWaitSemaphores = &semaphore; |
| 869 | submit_info.pWaitDstStageMask = &stage_flags; |
| 870 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 871 | m_errorMonitor->VerifyFound(); |
| 872 | |
| 873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 874 | "is neither VK_TRUE nor VK_FALSE"); |
| 875 | // Specify an invalid VkBool32 value |
| 876 | // Expected to trigger a warning with |
| 877 | // parameter_validation::validate_bool32 |
| 878 | VkSampler sampler = VK_NULL_HANDLE; |
| 879 | VkSamplerCreateInfo sampler_info = {}; |
| 880 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 881 | sampler_info.pNext = NULL; |
| 882 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 883 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 884 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 885 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 886 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 887 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 888 | sampler_info.mipLodBias = 1.0; |
| 889 | sampler_info.maxAnisotropy = 1; |
| 890 | sampler_info.compareEnable = VK_FALSE; |
| 891 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 892 | sampler_info.minLod = 1.0; |
| 893 | sampler_info.maxLod = 1.0; |
| 894 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 895 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 896 | // Not VK_TRUE or VK_FALSE |
| 897 | sampler_info.anisotropyEnable = 3; |
| 898 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 899 | m_errorMonitor->VerifyFound(); |
| 900 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 901 | |
| 902 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 903 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 904 | |
| 905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 906 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 907 | // Find an unsupported image format |
| 908 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 909 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 910 | VkFormat format = static_cast<VkFormat>(f); |
| 911 | VkFormatProperties fProps = m_device->format_properties(format); |
| 912 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 913 | fProps.optimalTilingFeatures == 0) { |
| 914 | unsupported = format; |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 920 | m_errorMonitor->SetDesiredFailureMsg( |
| 921 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 922 | "the requested format is not supported on this device"); |
| 923 | // Specify an unsupported VkFormat value to generate a |
| 924 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 925 | // Expected to trigger a warning from |
| 926 | // parameter_validation::validate_result |
| 927 | VkImageFormatProperties image_format_properties; |
| 928 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 929 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 930 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 931 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 932 | m_errorMonitor->VerifyFound(); |
| 933 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 934 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 935 | #endif // PARAMETER_VALIDATION_TESTS |
| 936 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 937 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 938 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 939 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 940 | { |
| 941 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 942 | VkFenceCreateInfo fenceInfo = {}; |
| 943 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 944 | fenceInfo.pNext = NULL; |
| 945 | fenceInfo.flags = 0; |
| 946 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 947 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 948 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 950 | |
| 951 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 952 | vk_testing::Buffer buffer; |
| 953 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 954 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 955 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 956 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 957 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 958 | |
| 959 | testFence.init(*m_device, fenceInfo); |
| 960 | |
| 961 | // Bypass framework since it does the waits automatically |
| 962 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 963 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 964 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 965 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 966 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 967 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 968 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 969 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 970 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 971 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 972 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 973 | |
| 974 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 975 | ASSERT_VK_SUCCESS( err ); |
| 976 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 977 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 978 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 979 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 980 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 981 | } |
| 982 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 983 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | { |
| 985 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 986 | VkFenceCreateInfo fenceInfo = {}; |
| 987 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 988 | fenceInfo.pNext = NULL; |
| 989 | fenceInfo.flags = 0; |
| 990 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 991 | 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] | 992 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 994 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 996 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 997 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 998 | 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] | 999 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1000 | |
| 1001 | testFence.init(*m_device, fenceInfo); |
| 1002 | |
| 1003 | // Bypass framework since it does the waits automatically |
| 1004 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1005 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1006 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1007 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1008 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1009 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1010 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1011 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1012 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1013 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1014 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1015 | |
| 1016 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1017 | ASSERT_VK_SUCCESS( err ); |
| 1018 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1019 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1020 | VkCommandBufferBeginInfo info = {}; |
| 1021 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1022 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1023 | info.renderPass = VK_NULL_HANDLE; |
| 1024 | info.subpass = 0; |
| 1025 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1026 | info.occlusionQueryEnable = VK_FALSE; |
| 1027 | info.queryFlags = 0; |
| 1028 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1029 | |
| 1030 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1031 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1033 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1034 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1035 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1036 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1037 | // This is a positive test. No failures are expected. |
| 1038 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1039 | VkResult err; |
| 1040 | bool pass; |
| 1041 | |
| 1042 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1043 | "the buffer, create an image, and bind the same memory to " |
| 1044 | "it"); |
| 1045 | |
| 1046 | m_errorMonitor->ExpectSuccess(); |
| 1047 | |
| 1048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1049 | |
| 1050 | VkBuffer buffer; |
| 1051 | VkImage image; |
| 1052 | VkDeviceMemory mem; |
| 1053 | VkMemoryRequirements mem_reqs; |
| 1054 | |
| 1055 | VkBufferCreateInfo buf_info = {}; |
| 1056 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1057 | buf_info.pNext = NULL; |
| 1058 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1059 | buf_info.size = 256; |
| 1060 | buf_info.queueFamilyIndexCount = 0; |
| 1061 | buf_info.pQueueFamilyIndices = NULL; |
| 1062 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1063 | buf_info.flags = 0; |
| 1064 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1065 | ASSERT_VK_SUCCESS(err); |
| 1066 | |
| 1067 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1068 | |
| 1069 | VkMemoryAllocateInfo alloc_info = {}; |
| 1070 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1071 | alloc_info.pNext = NULL; |
| 1072 | alloc_info.memoryTypeIndex = 0; |
| 1073 | |
| 1074 | // Ensure memory is big enough for both bindings |
| 1075 | alloc_info.allocationSize = 0x10000; |
| 1076 | |
| 1077 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1078 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1079 | if (!pass) { |
| 1080 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1081 | return; |
| 1082 | } |
| 1083 | |
| 1084 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1085 | ASSERT_VK_SUCCESS(err); |
| 1086 | |
| 1087 | uint8_t *pData; |
| 1088 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1089 | (void **)&pData); |
| 1090 | ASSERT_VK_SUCCESS(err); |
| 1091 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1092 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1093 | |
| 1094 | vkUnmapMemory(m_device->device(), mem); |
| 1095 | |
| 1096 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1097 | ASSERT_VK_SUCCESS(err); |
| 1098 | |
| 1099 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1100 | // memory. In fact, it was never used by the GPU. |
| 1101 | // Just be be sure, wait for idle. |
| 1102 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1103 | vkDeviceWaitIdle(m_device->device()); |
| 1104 | |
| 1105 | VkImageCreateInfo image_create_info = {}; |
| 1106 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1107 | image_create_info.pNext = NULL; |
| 1108 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1109 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1110 | image_create_info.extent.width = 64; |
| 1111 | image_create_info.extent.height = 64; |
| 1112 | image_create_info.extent.depth = 1; |
| 1113 | image_create_info.mipLevels = 1; |
| 1114 | image_create_info.arrayLayers = 1; |
| 1115 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1116 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1117 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1118 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1119 | image_create_info.queueFamilyIndexCount = 0; |
| 1120 | image_create_info.pQueueFamilyIndices = NULL; |
| 1121 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1122 | image_create_info.flags = 0; |
| 1123 | |
| 1124 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1125 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1126 | mem_alloc.pNext = NULL; |
| 1127 | mem_alloc.allocationSize = 0; |
| 1128 | mem_alloc.memoryTypeIndex = 0; |
| 1129 | |
| 1130 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1131 | * to be textures or it will be the staging image if they are not. |
| 1132 | */ |
| 1133 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1134 | ASSERT_VK_SUCCESS(err); |
| 1135 | |
| 1136 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1137 | |
| 1138 | mem_alloc.allocationSize = mem_reqs.size; |
| 1139 | |
| 1140 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1141 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1142 | if (!pass) { |
| 1143 | vkDestroyImage(m_device->device(), image, NULL); |
| 1144 | return; |
| 1145 | } |
| 1146 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1147 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1148 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1149 | ASSERT_VK_SUCCESS(err); |
| 1150 | |
| 1151 | m_errorMonitor->VerifyNotFound(); |
| 1152 | |
| 1153 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1154 | vkDestroyImage(m_device->device(), image, NULL); |
| 1155 | } |
| 1156 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1157 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1158 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1159 | "buffer and image to memory such that they will alias."); |
| 1160 | VkResult err; |
| 1161 | bool pass; |
| 1162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1163 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1164 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1165 | VkImage image; |
| 1166 | VkDeviceMemory mem; // buffer will be bound first |
| 1167 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1168 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1169 | |
| 1170 | VkBufferCreateInfo buf_info = {}; |
| 1171 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1172 | buf_info.pNext = NULL; |
| 1173 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1174 | buf_info.size = 256; |
| 1175 | buf_info.queueFamilyIndexCount = 0; |
| 1176 | buf_info.pQueueFamilyIndices = NULL; |
| 1177 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1178 | buf_info.flags = 0; |
| 1179 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1180 | ASSERT_VK_SUCCESS(err); |
| 1181 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1182 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1183 | |
| 1184 | VkImageCreateInfo image_create_info = {}; |
| 1185 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1186 | image_create_info.pNext = NULL; |
| 1187 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1188 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1189 | image_create_info.extent.width = 64; |
| 1190 | image_create_info.extent.height = 64; |
| 1191 | image_create_info.extent.depth = 1; |
| 1192 | image_create_info.mipLevels = 1; |
| 1193 | image_create_info.arrayLayers = 1; |
| 1194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1195 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1196 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1197 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1198 | image_create_info.queueFamilyIndexCount = 0; |
| 1199 | image_create_info.pQueueFamilyIndices = NULL; |
| 1200 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1201 | image_create_info.flags = 0; |
| 1202 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1203 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1204 | ASSERT_VK_SUCCESS(err); |
| 1205 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1206 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1207 | |
| 1208 | VkMemoryAllocateInfo alloc_info = {}; |
| 1209 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1210 | alloc_info.pNext = NULL; |
| 1211 | alloc_info.memoryTypeIndex = 0; |
| 1212 | // Ensure memory is big enough for both bindings |
| 1213 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1214 | pass = m_device->phy().set_memory_type( |
| 1215 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1216 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1217 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1218 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1219 | vkDestroyImage(m_device->device(), image, NULL); |
| 1220 | return; |
| 1221 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1222 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1223 | ASSERT_VK_SUCCESS(err); |
| 1224 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1225 | ASSERT_VK_SUCCESS(err); |
| 1226 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1227 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1228 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1229 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1230 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1231 | m_errorMonitor->VerifyFound(); |
| 1232 | |
| 1233 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1234 | // aliasing buffer2 |
| 1235 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1236 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1237 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1238 | ASSERT_VK_SUCCESS(err); |
| 1239 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1240 | ASSERT_VK_SUCCESS(err); |
| 1241 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1242 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1243 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1244 | m_errorMonitor->VerifyFound(); |
| 1245 | |
| 1246 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1247 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1248 | vkDestroyImage(m_device->device(), image, NULL); |
| 1249 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1250 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1251 | } |
| 1252 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1253 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1254 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1255 | VkResult err; |
| 1256 | bool pass; |
| 1257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1258 | |
| 1259 | VkBuffer buffer; |
| 1260 | VkDeviceMemory mem; |
| 1261 | VkMemoryRequirements mem_reqs; |
| 1262 | |
| 1263 | VkBufferCreateInfo buf_info = {}; |
| 1264 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1265 | buf_info.pNext = NULL; |
| 1266 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1267 | buf_info.size = 256; |
| 1268 | buf_info.queueFamilyIndexCount = 0; |
| 1269 | buf_info.pQueueFamilyIndices = NULL; |
| 1270 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1271 | buf_info.flags = 0; |
| 1272 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1273 | ASSERT_VK_SUCCESS(err); |
| 1274 | |
| 1275 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1276 | VkMemoryAllocateInfo alloc_info = {}; |
| 1277 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1278 | alloc_info.pNext = NULL; |
| 1279 | alloc_info.memoryTypeIndex = 0; |
| 1280 | |
| 1281 | // Ensure memory is big enough for both bindings |
| 1282 | static const VkDeviceSize allocation_size = 0x10000; |
| 1283 | alloc_info.allocationSize = allocation_size; |
| 1284 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1285 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1286 | if (!pass) { |
| 1287 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1288 | return; |
| 1289 | } |
| 1290 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1291 | ASSERT_VK_SUCCESS(err); |
| 1292 | |
| 1293 | uint8_t *pData; |
| 1294 | // Attempt to map memory size 0 is invalid |
| 1295 | m_errorMonitor->SetDesiredFailureMsg( |
| 1296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1297 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1298 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1299 | m_errorMonitor->VerifyFound(); |
| 1300 | // Map memory twice |
| 1301 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1302 | (void **)&pData); |
| 1303 | ASSERT_VK_SUCCESS(err); |
| 1304 | m_errorMonitor->SetDesiredFailureMsg( |
| 1305 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1306 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1307 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1308 | (void **)&pData); |
| 1309 | m_errorMonitor->VerifyFound(); |
| 1310 | |
| 1311 | // Unmap the memory to avoid re-map error |
| 1312 | vkUnmapMemory(m_device->device(), mem); |
| 1313 | // overstep allocation with VK_WHOLE_SIZE |
| 1314 | m_errorMonitor->SetDesiredFailureMsg( |
| 1315 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1316 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1317 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1318 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1319 | m_errorMonitor->VerifyFound(); |
| 1320 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1321 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1322 | " oversteps total array size 0x"); |
| 1323 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1324 | (void **)&pData); |
| 1325 | m_errorMonitor->VerifyFound(); |
| 1326 | // Now error due to unmapping memory that's not mapped |
| 1327 | m_errorMonitor->SetDesiredFailureMsg( |
| 1328 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1329 | "Unmapping Memory without memory being mapped: "); |
| 1330 | vkUnmapMemory(m_device->device(), mem); |
| 1331 | m_errorMonitor->VerifyFound(); |
| 1332 | // Now map memory and cause errors due to flushing invalid ranges |
| 1333 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1334 | (void **)&pData); |
| 1335 | ASSERT_VK_SUCCESS(err); |
| 1336 | VkMappedMemoryRange mmr = {}; |
| 1337 | mmr.memory = mem; |
| 1338 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1339 | m_errorMonitor->SetDesiredFailureMsg( |
| 1340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1341 | ") is less than Memory Object's offset ("); |
| 1342 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1343 | m_errorMonitor->VerifyFound(); |
| 1344 | // Now flush range that oversteps mapped range |
| 1345 | vkUnmapMemory(m_device->device(), mem); |
| 1346 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1347 | ASSERT_VK_SUCCESS(err); |
| 1348 | mmr.offset = 16; |
| 1349 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1350 | m_errorMonitor->SetDesiredFailureMsg( |
| 1351 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1352 | ") exceeds the Memory Object's upper-bound ("); |
| 1353 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1354 | m_errorMonitor->VerifyFound(); |
| 1355 | |
| 1356 | pass = |
| 1357 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1358 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1359 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1360 | if (!pass) { |
| 1361 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1362 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1363 | return; |
| 1364 | } |
| 1365 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1366 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1367 | |
| 1368 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1369 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1370 | } |
| 1371 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1372 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1373 | VkResult err; |
| 1374 | bool pass; |
| 1375 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1376 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1377 | // following declaration (which is temporarily being moved below): |
| 1378 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1379 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1380 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1381 | uint32_t swapchain_image_count = 0; |
| 1382 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1383 | uint32_t image_index = 0; |
| 1384 | // VkPresentInfoKHR present_info = {}; |
| 1385 | |
| 1386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1387 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1388 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1389 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1390 | // Use the functions from the VK_KHR_android_surface extension without |
| 1391 | // enabling that extension: |
| 1392 | |
| 1393 | // Create a surface: |
| 1394 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1395 | m_errorMonitor->SetDesiredFailureMsg( |
| 1396 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1397 | "extension was not enabled for this"); |
| 1398 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1399 | &surface); |
| 1400 | pass = (err != VK_SUCCESS); |
| 1401 | ASSERT_TRUE(pass); |
| 1402 | m_errorMonitor->VerifyFound(); |
| 1403 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1404 | |
| 1405 | |
| 1406 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1407 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1408 | // that extension: |
| 1409 | |
| 1410 | // Create a surface: |
| 1411 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1412 | m_errorMonitor->SetDesiredFailureMsg( |
| 1413 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1414 | "extension was not enabled for this"); |
| 1415 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1416 | pass = (err != VK_SUCCESS); |
| 1417 | ASSERT_TRUE(pass); |
| 1418 | m_errorMonitor->VerifyFound(); |
| 1419 | |
| 1420 | // Tell whether an mir_connection supports presentation: |
| 1421 | MirConnection *mir_connection = NULL; |
| 1422 | m_errorMonitor->SetDesiredFailureMsg( |
| 1423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1424 | "extension was not enabled for this"); |
| 1425 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1426 | visual_id); |
| 1427 | m_errorMonitor->VerifyFound(); |
| 1428 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1429 | |
| 1430 | |
| 1431 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1432 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1433 | // enabling that extension: |
| 1434 | |
| 1435 | // Create a surface: |
| 1436 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1437 | m_errorMonitor->SetDesiredFailureMsg( |
| 1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1439 | "extension was not enabled for this"); |
| 1440 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1441 | &surface); |
| 1442 | pass = (err != VK_SUCCESS); |
| 1443 | ASSERT_TRUE(pass); |
| 1444 | m_errorMonitor->VerifyFound(); |
| 1445 | |
| 1446 | // Tell whether an wayland_display supports presentation: |
| 1447 | struct wl_display wayland_display = {}; |
| 1448 | m_errorMonitor->SetDesiredFailureMsg( |
| 1449 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1450 | "extension was not enabled for this"); |
| 1451 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1452 | &wayland_display); |
| 1453 | m_errorMonitor->VerifyFound(); |
| 1454 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1455 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1456 | |
| 1457 | |
| 1458 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1459 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1460 | // TO NON-LINUX PLATFORMS: |
| 1461 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1462 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1463 | // enabling that extension: |
| 1464 | |
| 1465 | // Create a surface: |
| 1466 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1467 | m_errorMonitor->SetDesiredFailureMsg( |
| 1468 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1469 | "extension was not enabled for this"); |
| 1470 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1471 | &surface); |
| 1472 | pass = (err != VK_SUCCESS); |
| 1473 | ASSERT_TRUE(pass); |
| 1474 | m_errorMonitor->VerifyFound(); |
| 1475 | |
| 1476 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1477 | m_errorMonitor->SetDesiredFailureMsg( |
| 1478 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1479 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1480 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1481 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1482 | // Set this (for now, until all platforms are supported and tested): |
| 1483 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1484 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1485 | |
| 1486 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1487 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1488 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1489 | // TO NON-LINUX PLATFORMS: |
| 1490 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1491 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1492 | // that extension: |
| 1493 | |
| 1494 | // Create a surface: |
| 1495 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1496 | m_errorMonitor->SetDesiredFailureMsg( |
| 1497 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1498 | "extension was not enabled for this"); |
| 1499 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1500 | pass = (err != VK_SUCCESS); |
| 1501 | ASSERT_TRUE(pass); |
| 1502 | m_errorMonitor->VerifyFound(); |
| 1503 | |
| 1504 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1505 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1506 | xcb_visualid_t visual_id = 0; |
| 1507 | m_errorMonitor->SetDesiredFailureMsg( |
| 1508 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1509 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1510 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1511 | visual_id); |
| 1512 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1513 | // Set this (for now, until all platforms are supported and tested): |
| 1514 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1515 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1516 | |
| 1517 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1518 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1519 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1520 | // that extension: |
| 1521 | |
| 1522 | // Create a surface: |
| 1523 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1524 | m_errorMonitor->SetDesiredFailureMsg( |
| 1525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1526 | "extension was not enabled for this"); |
| 1527 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1528 | pass = (err != VK_SUCCESS); |
| 1529 | ASSERT_TRUE(pass); |
| 1530 | m_errorMonitor->VerifyFound(); |
| 1531 | |
| 1532 | // Tell whether an Xlib VisualID supports presentation: |
| 1533 | Display *dpy = NULL; |
| 1534 | VisualID visual = 0; |
| 1535 | m_errorMonitor->SetDesiredFailureMsg( |
| 1536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1537 | "extension was not enabled for this"); |
| 1538 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1539 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1540 | // Set this (for now, until all platforms are supported and tested): |
| 1541 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1542 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1543 | |
| 1544 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1545 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1546 | // that extension: |
| 1547 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1548 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1549 | // Destroy a surface: |
| 1550 | m_errorMonitor->SetDesiredFailureMsg( |
| 1551 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1552 | "extension was not enabled for this"); |
| 1553 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1554 | m_errorMonitor->VerifyFound(); |
| 1555 | |
| 1556 | // Check if surface supports presentation: |
| 1557 | VkBool32 supported = false; |
| 1558 | m_errorMonitor->SetDesiredFailureMsg( |
| 1559 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1560 | "extension was not enabled for this"); |
| 1561 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1562 | pass = (err != VK_SUCCESS); |
| 1563 | ASSERT_TRUE(pass); |
| 1564 | m_errorMonitor->VerifyFound(); |
| 1565 | |
| 1566 | // Check surface capabilities: |
| 1567 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1568 | m_errorMonitor->SetDesiredFailureMsg( |
| 1569 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1570 | "extension was not enabled for this"); |
| 1571 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1572 | &capabilities); |
| 1573 | pass = (err != VK_SUCCESS); |
| 1574 | ASSERT_TRUE(pass); |
| 1575 | m_errorMonitor->VerifyFound(); |
| 1576 | |
| 1577 | // Check surface formats: |
| 1578 | uint32_t format_count = 0; |
| 1579 | VkSurfaceFormatKHR *formats = NULL; |
| 1580 | m_errorMonitor->SetDesiredFailureMsg( |
| 1581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1582 | "extension was not enabled for this"); |
| 1583 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1584 | &format_count, formats); |
| 1585 | pass = (err != VK_SUCCESS); |
| 1586 | ASSERT_TRUE(pass); |
| 1587 | m_errorMonitor->VerifyFound(); |
| 1588 | |
| 1589 | // Check surface present modes: |
| 1590 | uint32_t present_mode_count = 0; |
| 1591 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1592 | m_errorMonitor->SetDesiredFailureMsg( |
| 1593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1594 | "extension was not enabled for this"); |
| 1595 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1596 | &present_mode_count, present_modes); |
| 1597 | pass = (err != VK_SUCCESS); |
| 1598 | ASSERT_TRUE(pass); |
| 1599 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1600 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1601 | |
| 1602 | |
| 1603 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1604 | // that extension: |
| 1605 | |
| 1606 | // Create a swapchain: |
| 1607 | m_errorMonitor->SetDesiredFailureMsg( |
| 1608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1609 | "extension was not enabled for this"); |
| 1610 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1611 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1612 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1613 | NULL, &swapchain); |
| 1614 | pass = (err != VK_SUCCESS); |
| 1615 | ASSERT_TRUE(pass); |
| 1616 | m_errorMonitor->VerifyFound(); |
| 1617 | |
| 1618 | // Get the images from the swapchain: |
| 1619 | m_errorMonitor->SetDesiredFailureMsg( |
| 1620 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1621 | "extension was not enabled for this"); |
| 1622 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1623 | &swapchain_image_count, NULL); |
| 1624 | pass = (err != VK_SUCCESS); |
| 1625 | ASSERT_TRUE(pass); |
| 1626 | m_errorMonitor->VerifyFound(); |
| 1627 | |
| 1628 | // Try to acquire an image: |
| 1629 | m_errorMonitor->SetDesiredFailureMsg( |
| 1630 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1631 | "extension was not enabled for this"); |
| 1632 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1633 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1634 | pass = (err != VK_SUCCESS); |
| 1635 | ASSERT_TRUE(pass); |
| 1636 | m_errorMonitor->VerifyFound(); |
| 1637 | |
| 1638 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1639 | // |
| 1640 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1641 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1642 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1643 | |
| 1644 | // Destroy the swapchain: |
| 1645 | m_errorMonitor->SetDesiredFailureMsg( |
| 1646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1647 | "extension was not enabled for this"); |
| 1648 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1649 | m_errorMonitor->VerifyFound(); |
| 1650 | } |
| 1651 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1652 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1653 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1654 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1655 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1656 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1657 | VkResult err; |
| 1658 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1659 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1660 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1661 | // uint32_t swapchain_image_count = 0; |
| 1662 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1663 | // uint32_t image_index = 0; |
| 1664 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1665 | |
| 1666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1667 | |
| 1668 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1669 | // order to create a surface, testing all known errors in the process, |
| 1670 | // before successfully creating a surface: |
| 1671 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1672 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1673 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1674 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1675 | pass = (err != VK_SUCCESS); |
| 1676 | ASSERT_TRUE(pass); |
| 1677 | m_errorMonitor->VerifyFound(); |
| 1678 | |
| 1679 | // Next, try to create a surface with the wrong |
| 1680 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1681 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1682 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1684 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1685 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1686 | pass = (err != VK_SUCCESS); |
| 1687 | ASSERT_TRUE(pass); |
| 1688 | m_errorMonitor->VerifyFound(); |
| 1689 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1690 | // Create a native window, and then correctly create a surface: |
| 1691 | xcb_connection_t *connection; |
| 1692 | xcb_screen_t *screen; |
| 1693 | xcb_window_t xcb_window; |
| 1694 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1695 | |
| 1696 | const xcb_setup_t *setup; |
| 1697 | xcb_screen_iterator_t iter; |
| 1698 | int scr; |
| 1699 | uint32_t value_mask, value_list[32]; |
| 1700 | int width = 1; |
| 1701 | int height = 1; |
| 1702 | |
| 1703 | connection = xcb_connect(NULL, &scr); |
| 1704 | ASSERT_TRUE(connection != NULL); |
| 1705 | setup = xcb_get_setup(connection); |
| 1706 | iter = xcb_setup_roots_iterator(setup); |
| 1707 | while (scr-- > 0) |
| 1708 | xcb_screen_next(&iter); |
| 1709 | screen = iter.data; |
| 1710 | |
| 1711 | xcb_window = xcb_generate_id(connection); |
| 1712 | |
| 1713 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1714 | value_list[0] = screen->black_pixel; |
| 1715 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1716 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1717 | |
| 1718 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1719 | screen->root, 0, 0, width, height, 0, |
| 1720 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1721 | value_mask, value_list); |
| 1722 | |
| 1723 | /* Magic code that will send notification when window is destroyed */ |
| 1724 | xcb_intern_atom_cookie_t cookie = |
| 1725 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1726 | xcb_intern_atom_reply_t *reply = |
| 1727 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1728 | |
| 1729 | xcb_intern_atom_cookie_t cookie2 = |
| 1730 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1731 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1732 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1733 | (*reply).atom, 4, 32, 1, |
| 1734 | &(*atom_wm_delete_window).atom); |
| 1735 | free(reply); |
| 1736 | |
| 1737 | xcb_map_window(connection, xcb_window); |
| 1738 | |
| 1739 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1740 | // runs |
| 1741 | const uint32_t coords[] = {100, 100}; |
| 1742 | xcb_configure_window(connection, xcb_window, |
| 1743 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1744 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1745 | // Finally, try to correctly create a surface: |
| 1746 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1747 | xcb_create_info.pNext = NULL; |
| 1748 | xcb_create_info.flags = 0; |
| 1749 | xcb_create_info.connection = connection; |
| 1750 | xcb_create_info.window = xcb_window; |
| 1751 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1752 | pass = (err == VK_SUCCESS); |
| 1753 | ASSERT_TRUE(pass); |
| 1754 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1755 | // Check if surface supports presentation: |
| 1756 | |
| 1757 | // 1st, do so without having queried the queue families: |
| 1758 | VkBool32 supported = false; |
| 1759 | // TODO: Get the following error to come out: |
| 1760 | m_errorMonitor->SetDesiredFailureMsg( |
| 1761 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1762 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1763 | "function"); |
| 1764 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1765 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1766 | // ASSERT_TRUE(pass); |
| 1767 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1768 | |
| 1769 | // Next, query a queue family index that's too large: |
| 1770 | m_errorMonitor->SetDesiredFailureMsg( |
| 1771 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1772 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1773 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1774 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1775 | pass = (err != VK_SUCCESS); |
| 1776 | ASSERT_TRUE(pass); |
| 1777 | m_errorMonitor->VerifyFound(); |
| 1778 | |
| 1779 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1780 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1781 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1782 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1783 | pass = (err == VK_SUCCESS); |
| 1784 | ASSERT_TRUE(pass); |
| 1785 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1786 | // Before proceeding, try to create a swapchain without having called |
| 1787 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1788 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1789 | swapchain_create_info.pNext = NULL; |
| 1790 | swapchain_create_info.flags = 0; |
| 1791 | m_errorMonitor->SetDesiredFailureMsg( |
| 1792 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1793 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1794 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1795 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1796 | pass = (err != VK_SUCCESS); |
| 1797 | ASSERT_TRUE(pass); |
| 1798 | m_errorMonitor->VerifyFound(); |
| 1799 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1800 | // Get the surface capabilities: |
| 1801 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1802 | |
| 1803 | // Do so correctly (only error logged by this entrypoint is if the |
| 1804 | // extension isn't enabled): |
| 1805 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1806 | &surface_capabilities); |
| 1807 | pass = (err == VK_SUCCESS); |
| 1808 | ASSERT_TRUE(pass); |
| 1809 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1810 | // Get the surface formats: |
| 1811 | uint32_t surface_format_count; |
| 1812 | |
| 1813 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1814 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1815 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1816 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1817 | pass = (err == VK_SUCCESS); |
| 1818 | ASSERT_TRUE(pass); |
| 1819 | m_errorMonitor->VerifyFound(); |
| 1820 | |
| 1821 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1822 | // correctly done a 1st try (to get the count): |
| 1823 | m_errorMonitor->SetDesiredFailureMsg( |
| 1824 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1825 | "but no prior positive value has been seen for"); |
| 1826 | surface_format_count = 0; |
| 1827 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1828 | gpu(), surface, &surface_format_count, |
| 1829 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1830 | pass = (err == VK_SUCCESS); |
| 1831 | ASSERT_TRUE(pass); |
| 1832 | m_errorMonitor->VerifyFound(); |
| 1833 | |
| 1834 | // 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] | 1835 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1836 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1837 | pass = (err == VK_SUCCESS); |
| 1838 | ASSERT_TRUE(pass); |
| 1839 | |
| 1840 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1841 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1842 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1843 | |
| 1844 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1845 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1847 | "that is greater than the value"); |
| 1848 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1849 | surface_formats); |
| 1850 | pass = (err == VK_SUCCESS); |
| 1851 | ASSERT_TRUE(pass); |
| 1852 | m_errorMonitor->VerifyFound(); |
| 1853 | |
| 1854 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1855 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1856 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1857 | pass = (err == VK_SUCCESS); |
| 1858 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1859 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1860 | surface_formats); |
| 1861 | pass = (err == VK_SUCCESS); |
| 1862 | ASSERT_TRUE(pass); |
| 1863 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1864 | // Get the surface present modes: |
| 1865 | uint32_t surface_present_mode_count; |
| 1866 | |
| 1867 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1869 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1870 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1871 | pass = (err == VK_SUCCESS); |
| 1872 | ASSERT_TRUE(pass); |
| 1873 | m_errorMonitor->VerifyFound(); |
| 1874 | |
| 1875 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1876 | // correctly done a 1st try (to get the count): |
| 1877 | m_errorMonitor->SetDesiredFailureMsg( |
| 1878 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1879 | "but no prior positive value has been seen for"); |
| 1880 | surface_present_mode_count = 0; |
| 1881 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1882 | gpu(), surface, &surface_present_mode_count, |
| 1883 | (VkPresentModeKHR *)&surface_present_mode_count); |
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 | |
| 1888 | // 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] | 1889 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1890 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1891 | pass = (err == VK_SUCCESS); |
| 1892 | ASSERT_TRUE(pass); |
| 1893 | |
| 1894 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1895 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1896 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1897 | |
| 1898 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1899 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1900 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1901 | "that is greater than the value"); |
| 1902 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1903 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1904 | pass = (err == VK_SUCCESS); |
| 1905 | ASSERT_TRUE(pass); |
| 1906 | m_errorMonitor->VerifyFound(); |
| 1907 | |
| 1908 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1909 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1910 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1911 | pass = (err == VK_SUCCESS); |
| 1912 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1913 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1914 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1915 | pass = (err == VK_SUCCESS); |
| 1916 | ASSERT_TRUE(pass); |
| 1917 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1918 | // Create a swapchain: |
| 1919 | |
| 1920 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1921 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1922 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1923 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1924 | pass = (err != VK_SUCCESS); |
| 1925 | ASSERT_TRUE(pass); |
| 1926 | m_errorMonitor->VerifyFound(); |
| 1927 | |
| 1928 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1929 | // sType: |
| 1930 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1931 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1932 | "called with the wrong value for"); |
| 1933 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1934 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1935 | pass = (err != VK_SUCCESS); |
| 1936 | ASSERT_TRUE(pass); |
| 1937 | m_errorMonitor->VerifyFound(); |
| 1938 | |
| 1939 | // Next, call with a NULL swapchain pointer: |
| 1940 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1941 | swapchain_create_info.pNext = NULL; |
| 1942 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1944 | "called with NULL pointer"); |
| 1945 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1946 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1947 | pass = (err != VK_SUCCESS); |
| 1948 | ASSERT_TRUE(pass); |
| 1949 | m_errorMonitor->VerifyFound(); |
| 1950 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1951 | // TODO: Enhance swapchain layer so that |
| 1952 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1953 | |
| 1954 | // Next, call with a queue family index that's too large: |
| 1955 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1956 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1957 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1958 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1959 | m_errorMonitor->SetDesiredFailureMsg( |
| 1960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1961 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1962 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1963 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1964 | pass = (err != VK_SUCCESS); |
| 1965 | ASSERT_TRUE(pass); |
| 1966 | m_errorMonitor->VerifyFound(); |
| 1967 | |
| 1968 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1969 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1970 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1971 | m_errorMonitor->SetDesiredFailureMsg( |
| 1972 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1973 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1974 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1975 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1976 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1977 | pass = (err != VK_SUCCESS); |
| 1978 | ASSERT_TRUE(pass); |
| 1979 | m_errorMonitor->VerifyFound(); |
| 1980 | |
| 1981 | // Next, call with an invalid imageSharingMode: |
| 1982 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1983 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1984 | m_errorMonitor->SetDesiredFailureMsg( |
| 1985 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1986 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1987 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1988 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1989 | pass = (err != VK_SUCCESS); |
| 1990 | ASSERT_TRUE(pass); |
| 1991 | m_errorMonitor->VerifyFound(); |
| 1992 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1993 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1994 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1995 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1996 | queueFamilyIndex[0] = 0; |
| 1997 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1998 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1999 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2000 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2001 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2002 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2003 | // Destroy the swapchain: |
| 2004 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2005 | // TODOs: |
| 2006 | // |
| 2007 | // - Try destroying the device without first destroying the swapchain |
| 2008 | // |
| 2009 | // - Try destroying the device without first destroying the surface |
| 2010 | // |
| 2011 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2012 | |
| 2013 | // Destroy the surface: |
| 2014 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2015 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2016 | // Tear down the window: |
| 2017 | xcb_destroy_window(connection, xcb_window); |
| 2018 | xcb_disconnect(connection); |
| 2019 | |
| 2020 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2021 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2022 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2023 | } |
| 2024 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2025 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2026 | VkResult err; |
| 2027 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2029 | m_errorMonitor->SetDesiredFailureMsg( |
| 2030 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2031 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2032 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2033 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2034 | |
| 2035 | // 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] | 2036 | VkImage image; |
| 2037 | VkDeviceMemory mem; |
| 2038 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2040 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2041 | const int32_t tex_width = 32; |
| 2042 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2043 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2044 | VkImageCreateInfo image_create_info = {}; |
| 2045 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2046 | image_create_info.pNext = NULL; |
| 2047 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2048 | image_create_info.format = tex_format; |
| 2049 | image_create_info.extent.width = tex_width; |
| 2050 | image_create_info.extent.height = tex_height; |
| 2051 | image_create_info.extent.depth = 1; |
| 2052 | image_create_info.mipLevels = 1; |
| 2053 | image_create_info.arrayLayers = 1; |
| 2054 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2055 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2056 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2057 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2058 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2059 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2060 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2061 | mem_alloc.pNext = NULL; |
| 2062 | mem_alloc.allocationSize = 0; |
| 2063 | // Introduce failure, do NOT set memProps to |
| 2064 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2065 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2066 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2067 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2068 | ASSERT_VK_SUCCESS(err); |
| 2069 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2070 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2071 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2072 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2074 | pass = |
| 2075 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2076 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2077 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2078 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2079 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2080 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2081 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2082 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2083 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2084 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2085 | ASSERT_VK_SUCCESS(err); |
| 2086 | |
| 2087 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2088 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2089 | ASSERT_VK_SUCCESS(err); |
| 2090 | |
| 2091 | // Map memory as if to initialize the image |
| 2092 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2093 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2094 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2096 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2098 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2099 | } |
| 2100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2101 | TEST_F(VkLayerTest, RebindMemory) { |
| 2102 | VkResult err; |
| 2103 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2105 | m_errorMonitor->SetDesiredFailureMsg( |
| 2106 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2107 | "which has already been bound to mem object"); |
| 2108 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2110 | |
| 2111 | // 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] | 2112 | VkImage image; |
| 2113 | VkDeviceMemory mem1; |
| 2114 | VkDeviceMemory mem2; |
| 2115 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2117 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2118 | const int32_t tex_width = 32; |
| 2119 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2120 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2121 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2122 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2123 | image_create_info.pNext = NULL; |
| 2124 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2125 | image_create_info.format = tex_format; |
| 2126 | image_create_info.extent.width = tex_width; |
| 2127 | image_create_info.extent.height = tex_height; |
| 2128 | image_create_info.extent.depth = 1; |
| 2129 | image_create_info.mipLevels = 1; |
| 2130 | image_create_info.arrayLayers = 1; |
| 2131 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2132 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2133 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2134 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2135 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2136 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2137 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2138 | mem_alloc.pNext = NULL; |
| 2139 | mem_alloc.allocationSize = 0; |
| 2140 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2142 | // Introduce failure, do NOT set memProps to |
| 2143 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2144 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2145 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2146 | ASSERT_VK_SUCCESS(err); |
| 2147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2148 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2149 | |
| 2150 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2151 | pass = |
| 2152 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2153 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2154 | |
| 2155 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2156 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2157 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2158 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2159 | ASSERT_VK_SUCCESS(err); |
| 2160 | |
| 2161 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2162 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2163 | ASSERT_VK_SUCCESS(err); |
| 2164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2165 | // Introduce validation failure, try to bind a different memory object to |
| 2166 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2167 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2168 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2169 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2170 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2171 | vkDestroyImage(m_device->device(), image, NULL); |
| 2172 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2173 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2174 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2176 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2177 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2179 | m_errorMonitor->SetDesiredFailureMsg( |
| 2180 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2181 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2182 | |
| 2183 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2184 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2185 | fenceInfo.pNext = NULL; |
| 2186 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2187 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2188 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2189 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2190 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2191 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2192 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2193 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2194 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2195 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2196 | |
| 2197 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2198 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2199 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2200 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2201 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2202 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2203 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2204 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2205 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2206 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2207 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2208 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2209 | |
| 2210 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2211 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2213 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2214 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2215 | // This is a positive test. We used to expect error in this case but spec now |
| 2216 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2217 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2218 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2219 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2220 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2221 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2222 | fenceInfo.pNext = NULL; |
| 2223 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2224 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2225 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2226 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2227 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2228 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2229 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2230 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2231 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2232 | |
| 2233 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2234 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2235 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2236 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2237 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2238 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2239 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2240 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2241 | |
| 2242 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2243 | VkImageObj image(m_device); |
| 2244 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2245 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2246 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2247 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2248 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2249 | VkImageView dsv; |
| 2250 | VkImageViewCreateInfo dsvci = {}; |
| 2251 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2252 | dsvci.image = image.handle(); |
| 2253 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2254 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2255 | dsvci.subresourceRange.layerCount = 1; |
| 2256 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2257 | dsvci.subresourceRange.levelCount = 1; |
| 2258 | dsvci.subresourceRange.aspectMask = |
| 2259 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2260 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2261 | // Create a view with depth / stencil aspect for image with different usage |
| 2262 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2263 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2264 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2265 | |
| 2266 | // Initialize buffer with TRANSFER_DST usage |
| 2267 | vk_testing::Buffer buffer; |
| 2268 | VkMemoryPropertyFlags reqs = 0; |
| 2269 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2270 | VkBufferImageCopy region = {}; |
| 2271 | region.bufferRowLength = 128; |
| 2272 | region.bufferImageHeight = 128; |
| 2273 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2274 | region.imageSubresource.layerCount = 1; |
| 2275 | region.imageExtent.height = 16; |
| 2276 | region.imageExtent.width = 16; |
| 2277 | region.imageExtent.depth = 1; |
| 2278 | |
| 2279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2280 | "Invalid usage flag for buffer "); |
| 2281 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2282 | // TRANSFER_DST |
| 2283 | BeginCommandBuffer(); |
| 2284 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2285 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2286 | 1, ®ion); |
| 2287 | m_errorMonitor->VerifyFound(); |
| 2288 | |
| 2289 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2290 | "Invalid usage flag for image "); |
| 2291 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2292 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2293 | 1, ®ion); |
| 2294 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2295 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2296 | #endif // MEM_TRACKER_TESTS |
| 2297 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2298 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2299 | |
| 2300 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2301 | VkResult err; |
| 2302 | |
| 2303 | TEST_DESCRIPTION( |
| 2304 | "Create a fence and destroy its device without first destroying the fence."); |
| 2305 | |
| 2306 | // Note that we have to create a new device since destroying the |
| 2307 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2308 | // will destroy the errorMonitor. |
| 2309 | |
| 2310 | m_errorMonitor->SetDesiredFailureMsg( |
| 2311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2312 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2313 | |
| 2314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2315 | |
| 2316 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2317 | m_device->queue_props; |
| 2318 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2319 | queue_info.reserve(queue_props.size()); |
| 2320 | std::vector<std::vector<float>> queue_priorities; |
| 2321 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2322 | VkDeviceQueueCreateInfo qi = {}; |
| 2323 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2324 | qi.pNext = NULL; |
| 2325 | qi.queueFamilyIndex = i; |
| 2326 | qi.queueCount = queue_props[i].queueCount; |
| 2327 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2328 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2329 | queue_info.push_back(qi); |
| 2330 | } |
| 2331 | |
| 2332 | std::vector<const char *> device_layer_names; |
| 2333 | std::vector<const char *> device_extension_names; |
| 2334 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2335 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2336 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2337 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2338 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2339 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2340 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2341 | |
| 2342 | // The sacrificial device object |
| 2343 | VkDevice testDevice; |
| 2344 | VkDeviceCreateInfo device_create_info = {}; |
| 2345 | auto features = m_device->phy().features(); |
| 2346 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2347 | device_create_info.pNext = NULL; |
| 2348 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2349 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2350 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2351 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2352 | device_create_info.pEnabledFeatures = &features; |
| 2353 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2354 | ASSERT_VK_SUCCESS(err); |
| 2355 | |
| 2356 | VkFence fence; |
| 2357 | VkFenceCreateInfo fence_create_info = {}; |
| 2358 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2359 | fence_create_info.pNext = NULL; |
| 2360 | fence_create_info.flags = 0; |
| 2361 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2362 | ASSERT_VK_SUCCESS(err); |
| 2363 | |
| 2364 | // Induce failure by not calling vkDestroyFence |
| 2365 | vkDestroyDevice(testDevice, NULL); |
| 2366 | m_errorMonitor->VerifyFound(); |
| 2367 | } |
| 2368 | |
| 2369 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2370 | |
| 2371 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2372 | "attempt to delete them from another."); |
| 2373 | |
| 2374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2375 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2376 | |
| 2377 | VkCommandPool command_pool_one; |
| 2378 | VkCommandPool command_pool_two; |
| 2379 | |
| 2380 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2381 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2382 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2383 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2384 | |
| 2385 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2386 | &command_pool_one); |
| 2387 | |
| 2388 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2389 | &command_pool_two); |
| 2390 | |
| 2391 | VkCommandBuffer command_buffer[9]; |
| 2392 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2393 | command_buffer_allocate_info.sType = |
| 2394 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2395 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2396 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2397 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2398 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2399 | command_buffer); |
| 2400 | |
| 2401 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2402 | &command_buffer[3]); |
| 2403 | |
| 2404 | m_errorMonitor->VerifyFound(); |
| 2405 | |
| 2406 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2407 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2408 | } |
| 2409 | |
| 2410 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2411 | VkResult err; |
| 2412 | |
| 2413 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2414 | "attempt to delete them from another."); |
| 2415 | |
| 2416 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2417 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2418 | |
| 2419 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2420 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2421 | |
| 2422 | VkDescriptorPoolSize ds_type_count = {}; |
| 2423 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2424 | ds_type_count.descriptorCount = 1; |
| 2425 | |
| 2426 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2427 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2428 | ds_pool_ci.pNext = NULL; |
| 2429 | ds_pool_ci.flags = 0; |
| 2430 | ds_pool_ci.maxSets = 1; |
| 2431 | ds_pool_ci.poolSizeCount = 1; |
| 2432 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2433 | |
| 2434 | VkDescriptorPool ds_pool_one; |
| 2435 | err = |
| 2436 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2437 | ASSERT_VK_SUCCESS(err); |
| 2438 | |
| 2439 | // Create a second descriptor pool |
| 2440 | VkDescriptorPool ds_pool_two; |
| 2441 | err = |
| 2442 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2443 | ASSERT_VK_SUCCESS(err); |
| 2444 | |
| 2445 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2446 | dsl_binding.binding = 0; |
| 2447 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2448 | dsl_binding.descriptorCount = 1; |
| 2449 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2450 | dsl_binding.pImmutableSamplers = NULL; |
| 2451 | |
| 2452 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2453 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2454 | ds_layout_ci.pNext = NULL; |
| 2455 | ds_layout_ci.bindingCount = 1; |
| 2456 | ds_layout_ci.pBindings = &dsl_binding; |
| 2457 | |
| 2458 | VkDescriptorSetLayout ds_layout; |
| 2459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2460 | &ds_layout); |
| 2461 | ASSERT_VK_SUCCESS(err); |
| 2462 | |
| 2463 | VkDescriptorSet descriptorSet; |
| 2464 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2465 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2466 | alloc_info.descriptorSetCount = 1; |
| 2467 | alloc_info.descriptorPool = ds_pool_one; |
| 2468 | alloc_info.pSetLayouts = &ds_layout; |
| 2469 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2470 | &descriptorSet); |
| 2471 | ASSERT_VK_SUCCESS(err); |
| 2472 | |
| 2473 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2474 | |
| 2475 | m_errorMonitor->VerifyFound(); |
| 2476 | |
| 2477 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2478 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2479 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2480 | } |
| 2481 | |
| 2482 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2484 | "Invalid VkImage Object "); |
| 2485 | |
| 2486 | TEST_DESCRIPTION( |
| 2487 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2488 | |
| 2489 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2490 | |
| 2491 | // Pass bogus handle into GetImageMemoryRequirements |
| 2492 | VkMemoryRequirements mem_reqs; |
| 2493 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2494 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2495 | |
| 2496 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2497 | |
| 2498 | m_errorMonitor->VerifyFound(); |
| 2499 | } |
| 2500 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2501 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2502 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2503 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2504 | TEST_DESCRIPTION( |
| 2505 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2506 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2507 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2508 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2509 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2510 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2511 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2512 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2513 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2515 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2516 | |
| 2517 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2518 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2519 | ds_pool_ci.pNext = NULL; |
| 2520 | ds_pool_ci.maxSets = 1; |
| 2521 | ds_pool_ci.poolSizeCount = 1; |
| 2522 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2523 | |
| 2524 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2525 | err = |
| 2526 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2527 | ASSERT_VK_SUCCESS(err); |
| 2528 | |
| 2529 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2530 | dsl_binding.binding = 0; |
| 2531 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2532 | dsl_binding.descriptorCount = 1; |
| 2533 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2534 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2535 | |
| 2536 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2537 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2538 | ds_layout_ci.pNext = NULL; |
| 2539 | ds_layout_ci.bindingCount = 1; |
| 2540 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2541 | |
| 2542 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2543 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2544 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2545 | ASSERT_VK_SUCCESS(err); |
| 2546 | |
| 2547 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2548 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2549 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2550 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2551 | alloc_info.descriptorPool = ds_pool; |
| 2552 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2553 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2554 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2555 | ASSERT_VK_SUCCESS(err); |
| 2556 | |
| 2557 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2558 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2559 | pipeline_layout_ci.pNext = NULL; |
| 2560 | pipeline_layout_ci.setLayoutCount = 1; |
| 2561 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2562 | |
| 2563 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2564 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2565 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2566 | ASSERT_VK_SUCCESS(err); |
| 2567 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2568 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2569 | |
| 2570 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2572 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2573 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2574 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2575 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2576 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2577 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2578 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2579 | } |
| 2580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2582 | VkResult err; |
| 2583 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2584 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2585 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2586 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2587 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2588 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2589 | |
| 2590 | // 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] | 2591 | VkImage image; |
| 2592 | VkDeviceMemory mem; |
| 2593 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2595 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2596 | const int32_t tex_width = 32; |
| 2597 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2598 | |
| 2599 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2600 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2601 | image_create_info.pNext = NULL; |
| 2602 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2603 | image_create_info.format = tex_format; |
| 2604 | image_create_info.extent.width = tex_width; |
| 2605 | image_create_info.extent.height = tex_height; |
| 2606 | image_create_info.extent.depth = 1; |
| 2607 | image_create_info.mipLevels = 1; |
| 2608 | image_create_info.arrayLayers = 1; |
| 2609 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2610 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2611 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2612 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2613 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2614 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2615 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2616 | mem_alloc.pNext = NULL; |
| 2617 | mem_alloc.allocationSize = 0; |
| 2618 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2619 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2620 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2621 | ASSERT_VK_SUCCESS(err); |
| 2622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2623 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2624 | |
| 2625 | mem_alloc.allocationSize = mem_reqs.size; |
| 2626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2627 | pass = |
| 2628 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2629 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2630 | |
| 2631 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2632 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2633 | ASSERT_VK_SUCCESS(err); |
| 2634 | |
| 2635 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2636 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2637 | |
| 2638 | // Try to bind free memory that has been freed |
| 2639 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2640 | // This may very well return an error. |
| 2641 | (void)err; |
| 2642 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2643 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2644 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2645 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2646 | } |
| 2647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2648 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2649 | VkResult err; |
| 2650 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2653 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2654 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | // Create an image object, allocate memory, destroy the object and then try |
| 2658 | // to bind it |
| 2659 | VkImage image; |
| 2660 | VkDeviceMemory mem; |
| 2661 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2662 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2663 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2664 | const int32_t tex_width = 32; |
| 2665 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2666 | |
| 2667 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2669 | image_create_info.pNext = NULL; |
| 2670 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2671 | image_create_info.format = tex_format; |
| 2672 | image_create_info.extent.width = tex_width; |
| 2673 | image_create_info.extent.height = tex_height; |
| 2674 | image_create_info.extent.depth = 1; |
| 2675 | image_create_info.mipLevels = 1; |
| 2676 | image_create_info.arrayLayers = 1; |
| 2677 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2678 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2679 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2680 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2681 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2682 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2683 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2684 | mem_alloc.pNext = NULL; |
| 2685 | mem_alloc.allocationSize = 0; |
| 2686 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2687 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2688 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2689 | ASSERT_VK_SUCCESS(err); |
| 2690 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2691 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2692 | |
| 2693 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2694 | pass = |
| 2695 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2696 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2697 | |
| 2698 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2699 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2700 | ASSERT_VK_SUCCESS(err); |
| 2701 | |
| 2702 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2703 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2704 | ASSERT_VK_SUCCESS(err); |
| 2705 | |
| 2706 | // Now Try to bind memory to this destroyed object |
| 2707 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2708 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2709 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2711 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2712 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2713 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2714 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2715 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2716 | #endif // OBJ_TRACKER_TESTS |
| 2717 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2718 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2719 | |
| 2720 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2721 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 2722 | TEST_DESCRIPTION( |
| 2723 | "Wait on a event then set it after the wait has been submitted."); |
| 2724 | |
| 2725 | if ((m_device->queue_props.empty()) || |
| 2726 | (m_device->queue_props[0].queueCount < 2)) |
| 2727 | return; |
| 2728 | |
| 2729 | m_errorMonitor->ExpectSuccess(); |
| 2730 | |
| 2731 | VkEvent event; |
| 2732 | VkEventCreateInfo event_create_info{}; |
| 2733 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2734 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2735 | |
| 2736 | VkCommandPool command_pool; |
| 2737 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2738 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2739 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2740 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2741 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2742 | &command_pool); |
| 2743 | |
| 2744 | VkCommandBuffer command_buffer; |
| 2745 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2746 | command_buffer_allocate_info.sType = |
| 2747 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2748 | command_buffer_allocate_info.commandPool = command_pool; |
| 2749 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2750 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2751 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2752 | &command_buffer); |
| 2753 | |
| 2754 | VkQueue queue = VK_NULL_HANDLE; |
| 2755 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2756 | 1, &queue); |
| 2757 | |
| 2758 | { |
| 2759 | VkCommandBufferBeginInfo begin_info{}; |
| 2760 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2761 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2762 | |
| 2763 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2764 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2765 | nullptr, 0, nullptr); |
| 2766 | vkCmdResetEvent(command_buffer, event, |
| 2767 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2768 | vkEndCommandBuffer(command_buffer); |
| 2769 | } |
| 2770 | { |
| 2771 | VkSubmitInfo submit_info{}; |
| 2772 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2773 | submit_info.commandBufferCount = 1; |
| 2774 | submit_info.pCommandBuffers = &command_buffer; |
| 2775 | submit_info.signalSemaphoreCount = 0; |
| 2776 | submit_info.pSignalSemaphores = nullptr; |
| 2777 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2778 | } |
| 2779 | { vkSetEvent(m_device->device(), event); } |
| 2780 | |
| 2781 | vkQueueWaitIdle(queue); |
| 2782 | |
| 2783 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2784 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2785 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2786 | |
| 2787 | m_errorMonitor->VerifyNotFound(); |
| 2788 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2789 | // This is a positive test. No errors should be generated. |
| 2790 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2791 | TEST_DESCRIPTION( |
| 2792 | "Issue a query and copy from it on a second command buffer."); |
| 2793 | |
| 2794 | if ((m_device->queue_props.empty()) || |
| 2795 | (m_device->queue_props[0].queueCount < 2)) |
| 2796 | return; |
| 2797 | |
| 2798 | m_errorMonitor->ExpectSuccess(); |
| 2799 | |
| 2800 | VkQueryPool query_pool; |
| 2801 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2802 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2803 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2804 | query_pool_create_info.queryCount = 1; |
| 2805 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2806 | &query_pool); |
| 2807 | |
| 2808 | VkCommandPool command_pool; |
| 2809 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2810 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2811 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2812 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2813 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2814 | &command_pool); |
| 2815 | |
| 2816 | VkCommandBuffer command_buffer[2]; |
| 2817 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2818 | command_buffer_allocate_info.sType = |
| 2819 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2820 | command_buffer_allocate_info.commandPool = command_pool; |
| 2821 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2822 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2823 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2824 | command_buffer); |
| 2825 | |
| 2826 | VkQueue queue = VK_NULL_HANDLE; |
| 2827 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2828 | 1, &queue); |
| 2829 | |
| 2830 | uint32_t qfi = 0; |
| 2831 | VkBufferCreateInfo buff_create_info = {}; |
| 2832 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2833 | buff_create_info.size = 1024; |
| 2834 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2835 | buff_create_info.queueFamilyIndexCount = 1; |
| 2836 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2837 | |
| 2838 | VkResult err; |
| 2839 | VkBuffer buffer; |
| 2840 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2841 | ASSERT_VK_SUCCESS(err); |
| 2842 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2843 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2844 | mem_alloc.pNext = NULL; |
| 2845 | mem_alloc.allocationSize = 1024; |
| 2846 | mem_alloc.memoryTypeIndex = 0; |
| 2847 | |
| 2848 | VkMemoryRequirements memReqs; |
| 2849 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2850 | bool pass = |
| 2851 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2852 | if (!pass) { |
| 2853 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2854 | return; |
| 2855 | } |
| 2856 | |
| 2857 | VkDeviceMemory mem; |
| 2858 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2859 | ASSERT_VK_SUCCESS(err); |
| 2860 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2861 | ASSERT_VK_SUCCESS(err); |
| 2862 | |
| 2863 | { |
| 2864 | VkCommandBufferBeginInfo begin_info{}; |
| 2865 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2866 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2867 | |
| 2868 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2869 | vkCmdWriteTimestamp(command_buffer[0], |
| 2870 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2871 | |
| 2872 | vkEndCommandBuffer(command_buffer[0]); |
| 2873 | |
| 2874 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2875 | |
| 2876 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 2877 | 0, 0, 0); |
| 2878 | |
| 2879 | vkEndCommandBuffer(command_buffer[1]); |
| 2880 | } |
| 2881 | { |
| 2882 | VkSubmitInfo submit_info{}; |
| 2883 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2884 | submit_info.commandBufferCount = 2; |
| 2885 | submit_info.pCommandBuffers = command_buffer; |
| 2886 | submit_info.signalSemaphoreCount = 0; |
| 2887 | submit_info.pSignalSemaphores = nullptr; |
| 2888 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2889 | } |
| 2890 | |
| 2891 | vkQueueWaitIdle(queue); |
| 2892 | |
| 2893 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 2894 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 2895 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2896 | |
| 2897 | m_errorMonitor->VerifyNotFound(); |
| 2898 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2899 | |
| 2900 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 2901 | TEST_DESCRIPTION( |
| 2902 | "Reset an event then set it after the reset has been submitted."); |
| 2903 | |
| 2904 | if ((m_device->queue_props.empty()) || |
| 2905 | (m_device->queue_props[0].queueCount < 2)) |
| 2906 | return; |
| 2907 | |
| 2908 | m_errorMonitor->ExpectSuccess(); |
| 2909 | |
| 2910 | VkEvent event; |
| 2911 | VkEventCreateInfo event_create_info{}; |
| 2912 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2913 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2914 | |
| 2915 | VkCommandPool command_pool; |
| 2916 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2917 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2918 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2919 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2920 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2921 | &command_pool); |
| 2922 | |
| 2923 | VkCommandBuffer command_buffer; |
| 2924 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2925 | command_buffer_allocate_info.sType = |
| 2926 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2927 | command_buffer_allocate_info.commandPool = command_pool; |
| 2928 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2929 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2930 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2931 | &command_buffer); |
| 2932 | |
| 2933 | VkQueue queue = VK_NULL_HANDLE; |
| 2934 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2935 | 1, &queue); |
| 2936 | |
| 2937 | { |
| 2938 | VkCommandBufferBeginInfo begin_info{}; |
| 2939 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2940 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2941 | |
| 2942 | vkCmdResetEvent(command_buffer, event, |
| 2943 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2944 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 2945 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2946 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2947 | nullptr, 0, nullptr); |
| 2948 | vkEndCommandBuffer(command_buffer); |
| 2949 | } |
| 2950 | { |
| 2951 | VkSubmitInfo submit_info{}; |
| 2952 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2953 | submit_info.commandBufferCount = 1; |
| 2954 | submit_info.pCommandBuffers = &command_buffer; |
| 2955 | submit_info.signalSemaphoreCount = 0; |
| 2956 | submit_info.pSignalSemaphores = nullptr; |
| 2957 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2958 | } |
| 2959 | { |
| 2960 | m_errorMonitor->SetDesiredFailureMsg( |
| 2961 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 2962 | "0x1 that is already in use by a " |
| 2963 | "command buffer."); |
| 2964 | vkSetEvent(m_device->device(), event); |
| 2965 | m_errorMonitor->VerifyFound(); |
| 2966 | } |
| 2967 | |
| 2968 | vkQueueWaitIdle(queue); |
| 2969 | |
| 2970 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2971 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2972 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2973 | } |
| 2974 | |
| 2975 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 2976 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 2977 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 2978 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 2979 | "previously revealed a bug so running this positive test " |
| 2980 | "to prevent a regression."); |
| 2981 | m_errorMonitor->ExpectSuccess(); |
| 2982 | |
| 2983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2984 | VkQueue queue = VK_NULL_HANDLE; |
| 2985 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2986 | 0, &queue); |
| 2987 | |
| 2988 | static const uint32_t NUM_OBJECTS = 2; |
| 2989 | static const uint32_t NUM_FRAMES = 3; |
| 2990 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 2991 | VkFence fences[NUM_OBJECTS] = {}; |
| 2992 | |
| 2993 | VkCommandPool cmd_pool; |
| 2994 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 2995 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2996 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2997 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2998 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 2999 | nullptr, &cmd_pool); |
| 3000 | ASSERT_VK_SUCCESS(err); |
| 3001 | |
| 3002 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3003 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3004 | cmd_buf_info.commandPool = cmd_pool; |
| 3005 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3006 | cmd_buf_info.commandBufferCount = 1; |
| 3007 | |
| 3008 | VkFenceCreateInfo fence_ci = {}; |
| 3009 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3010 | fence_ci.pNext = nullptr; |
| 3011 | fence_ci.flags = 0; |
| 3012 | |
| 3013 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3014 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3015 | &cmd_buffers[i]); |
| 3016 | ASSERT_VK_SUCCESS(err); |
| 3017 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3018 | ASSERT_VK_SUCCESS(err); |
| 3019 | } |
| 3020 | |
| 3021 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3022 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3023 | // Create empty cmd buffer |
| 3024 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3025 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3026 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3027 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3028 | ASSERT_VK_SUCCESS(err); |
| 3029 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3030 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3031 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3032 | VkSubmitInfo submit_info = {}; |
| 3033 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3034 | submit_info.commandBufferCount = 1; |
| 3035 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3036 | // Submit cmd buffer and wait for fence |
| 3037 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3038 | ASSERT_VK_SUCCESS(err); |
| 3039 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3040 | UINT64_MAX); |
| 3041 | ASSERT_VK_SUCCESS(err); |
| 3042 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3043 | ASSERT_VK_SUCCESS(err); |
| 3044 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3045 | } |
| 3046 | m_errorMonitor->VerifyNotFound(); |
| 3047 | } |
| 3048 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3049 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3050 | |
| 3051 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3052 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3053 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3054 | if ((m_device->queue_props.empty()) || |
| 3055 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3056 | return; |
| 3057 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3058 | m_errorMonitor->ExpectSuccess(); |
| 3059 | |
| 3060 | VkSemaphore semaphore; |
| 3061 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3062 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3063 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3064 | &semaphore); |
| 3065 | |
| 3066 | VkCommandPool command_pool; |
| 3067 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3068 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3069 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3070 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3071 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3072 | &command_pool); |
| 3073 | |
| 3074 | VkCommandBuffer command_buffer[2]; |
| 3075 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3076 | command_buffer_allocate_info.sType = |
| 3077 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3078 | command_buffer_allocate_info.commandPool = command_pool; |
| 3079 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3080 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3081 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3082 | command_buffer); |
| 3083 | |
| 3084 | VkQueue queue = VK_NULL_HANDLE; |
| 3085 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3086 | 1, &queue); |
| 3087 | |
| 3088 | { |
| 3089 | VkCommandBufferBeginInfo begin_info{}; |
| 3090 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3091 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3092 | |
| 3093 | vkCmdPipelineBarrier(command_buffer[0], |
| 3094 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3095 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3096 | 0, nullptr, 0, nullptr); |
| 3097 | |
| 3098 | VkViewport viewport{}; |
| 3099 | viewport.maxDepth = 1.0f; |
| 3100 | viewport.minDepth = 0.0f; |
| 3101 | viewport.width = 512; |
| 3102 | viewport.height = 512; |
| 3103 | viewport.x = 0; |
| 3104 | viewport.y = 0; |
| 3105 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3106 | vkEndCommandBuffer(command_buffer[0]); |
| 3107 | } |
| 3108 | { |
| 3109 | VkCommandBufferBeginInfo begin_info{}; |
| 3110 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3111 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3112 | |
| 3113 | VkViewport viewport{}; |
| 3114 | viewport.maxDepth = 1.0f; |
| 3115 | viewport.minDepth = 0.0f; |
| 3116 | viewport.width = 512; |
| 3117 | viewport.height = 512; |
| 3118 | viewport.x = 0; |
| 3119 | viewport.y = 0; |
| 3120 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3121 | vkEndCommandBuffer(command_buffer[1]); |
| 3122 | } |
| 3123 | { |
| 3124 | VkSubmitInfo submit_info{}; |
| 3125 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3126 | submit_info.commandBufferCount = 1; |
| 3127 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3128 | submit_info.signalSemaphoreCount = 1; |
| 3129 | submit_info.pSignalSemaphores = &semaphore; |
| 3130 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3131 | } |
| 3132 | { |
| 3133 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3134 | VkSubmitInfo submit_info{}; |
| 3135 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3136 | submit_info.commandBufferCount = 1; |
| 3137 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3138 | submit_info.waitSemaphoreCount = 1; |
| 3139 | submit_info.pWaitSemaphores = &semaphore; |
| 3140 | submit_info.pWaitDstStageMask = flags; |
| 3141 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3142 | } |
| 3143 | |
| 3144 | vkQueueWaitIdle(m_device->m_queue); |
| 3145 | |
| 3146 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3147 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3148 | &command_buffer[0]); |
| 3149 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3150 | |
| 3151 | m_errorMonitor->VerifyNotFound(); |
| 3152 | } |
| 3153 | |
| 3154 | // This is a positive test. No errors should be generated. |
| 3155 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3156 | |
| 3157 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3158 | "submitted on separate queues, the second having a fence" |
| 3159 | "followed by a QueueWaitIdle."); |
| 3160 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3161 | if ((m_device->queue_props.empty()) || |
| 3162 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3163 | return; |
| 3164 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3165 | m_errorMonitor->ExpectSuccess(); |
| 3166 | |
| 3167 | VkFence fence; |
| 3168 | VkFenceCreateInfo fence_create_info{}; |
| 3169 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3170 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3171 | |
| 3172 | VkSemaphore semaphore; |
| 3173 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3174 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3175 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3176 | &semaphore); |
| 3177 | |
| 3178 | VkCommandPool command_pool; |
| 3179 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3180 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3181 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3182 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3183 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3184 | &command_pool); |
| 3185 | |
| 3186 | VkCommandBuffer command_buffer[2]; |
| 3187 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3188 | command_buffer_allocate_info.sType = |
| 3189 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3190 | command_buffer_allocate_info.commandPool = command_pool; |
| 3191 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3192 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3193 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3194 | command_buffer); |
| 3195 | |
| 3196 | VkQueue queue = VK_NULL_HANDLE; |
| 3197 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3198 | 1, &queue); |
| 3199 | |
| 3200 | { |
| 3201 | VkCommandBufferBeginInfo begin_info{}; |
| 3202 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3203 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3204 | |
| 3205 | vkCmdPipelineBarrier(command_buffer[0], |
| 3206 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3207 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3208 | 0, nullptr, 0, nullptr); |
| 3209 | |
| 3210 | VkViewport viewport{}; |
| 3211 | viewport.maxDepth = 1.0f; |
| 3212 | viewport.minDepth = 0.0f; |
| 3213 | viewport.width = 512; |
| 3214 | viewport.height = 512; |
| 3215 | viewport.x = 0; |
| 3216 | viewport.y = 0; |
| 3217 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3218 | vkEndCommandBuffer(command_buffer[0]); |
| 3219 | } |
| 3220 | { |
| 3221 | VkCommandBufferBeginInfo begin_info{}; |
| 3222 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3223 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3224 | |
| 3225 | VkViewport viewport{}; |
| 3226 | viewport.maxDepth = 1.0f; |
| 3227 | viewport.minDepth = 0.0f; |
| 3228 | viewport.width = 512; |
| 3229 | viewport.height = 512; |
| 3230 | viewport.x = 0; |
| 3231 | viewport.y = 0; |
| 3232 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3233 | vkEndCommandBuffer(command_buffer[1]); |
| 3234 | } |
| 3235 | { |
| 3236 | VkSubmitInfo submit_info{}; |
| 3237 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3238 | submit_info.commandBufferCount = 1; |
| 3239 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3240 | submit_info.signalSemaphoreCount = 1; |
| 3241 | submit_info.pSignalSemaphores = &semaphore; |
| 3242 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3243 | } |
| 3244 | { |
| 3245 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3246 | VkSubmitInfo submit_info{}; |
| 3247 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3248 | submit_info.commandBufferCount = 1; |
| 3249 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3250 | submit_info.waitSemaphoreCount = 1; |
| 3251 | submit_info.pWaitSemaphores = &semaphore; |
| 3252 | submit_info.pWaitDstStageMask = flags; |
| 3253 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3254 | } |
| 3255 | |
| 3256 | vkQueueWaitIdle(m_device->m_queue); |
| 3257 | |
| 3258 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3259 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3260 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3261 | &command_buffer[0]); |
| 3262 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3263 | |
| 3264 | m_errorMonitor->VerifyNotFound(); |
| 3265 | } |
| 3266 | |
| 3267 | // This is a positive test. No errors should be generated. |
| 3268 | TEST_F(VkLayerTest, |
| 3269 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3270 | |
| 3271 | TEST_DESCRIPTION( |
| 3272 | "Two command buffers, each in a separate QueueSubmit call " |
| 3273 | "submitted on separate queues, the second having a fence" |
| 3274 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3275 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3276 | if ((m_device->queue_props.empty()) || |
| 3277 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3278 | return; |
| 3279 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3280 | m_errorMonitor->ExpectSuccess(); |
| 3281 | |
| 3282 | VkFence fence; |
| 3283 | VkFenceCreateInfo fence_create_info{}; |
| 3284 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3285 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3286 | |
| 3287 | VkSemaphore semaphore; |
| 3288 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3289 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3290 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3291 | &semaphore); |
| 3292 | |
| 3293 | VkCommandPool command_pool; |
| 3294 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3295 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3296 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3297 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3298 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3299 | &command_pool); |
| 3300 | |
| 3301 | VkCommandBuffer command_buffer[2]; |
| 3302 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3303 | command_buffer_allocate_info.sType = |
| 3304 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3305 | command_buffer_allocate_info.commandPool = command_pool; |
| 3306 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3307 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3308 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3309 | command_buffer); |
| 3310 | |
| 3311 | VkQueue queue = VK_NULL_HANDLE; |
| 3312 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3313 | 1, &queue); |
| 3314 | |
| 3315 | { |
| 3316 | VkCommandBufferBeginInfo begin_info{}; |
| 3317 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3318 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3319 | |
| 3320 | vkCmdPipelineBarrier(command_buffer[0], |
| 3321 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3322 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3323 | 0, nullptr, 0, nullptr); |
| 3324 | |
| 3325 | VkViewport viewport{}; |
| 3326 | viewport.maxDepth = 1.0f; |
| 3327 | viewport.minDepth = 0.0f; |
| 3328 | viewport.width = 512; |
| 3329 | viewport.height = 512; |
| 3330 | viewport.x = 0; |
| 3331 | viewport.y = 0; |
| 3332 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3333 | vkEndCommandBuffer(command_buffer[0]); |
| 3334 | } |
| 3335 | { |
| 3336 | VkCommandBufferBeginInfo begin_info{}; |
| 3337 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3338 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3339 | |
| 3340 | VkViewport viewport{}; |
| 3341 | viewport.maxDepth = 1.0f; |
| 3342 | viewport.minDepth = 0.0f; |
| 3343 | viewport.width = 512; |
| 3344 | viewport.height = 512; |
| 3345 | viewport.x = 0; |
| 3346 | viewport.y = 0; |
| 3347 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3348 | vkEndCommandBuffer(command_buffer[1]); |
| 3349 | } |
| 3350 | { |
| 3351 | VkSubmitInfo submit_info{}; |
| 3352 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3353 | submit_info.commandBufferCount = 1; |
| 3354 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3355 | submit_info.signalSemaphoreCount = 1; |
| 3356 | submit_info.pSignalSemaphores = &semaphore; |
| 3357 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3358 | } |
| 3359 | { |
| 3360 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3361 | VkSubmitInfo submit_info{}; |
| 3362 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3363 | submit_info.commandBufferCount = 1; |
| 3364 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3365 | submit_info.waitSemaphoreCount = 1; |
| 3366 | submit_info.pWaitSemaphores = &semaphore; |
| 3367 | submit_info.pWaitDstStageMask = flags; |
| 3368 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3369 | } |
| 3370 | |
| 3371 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3372 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3373 | |
| 3374 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3375 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3376 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3377 | &command_buffer[0]); |
| 3378 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3379 | |
| 3380 | m_errorMonitor->VerifyNotFound(); |
| 3381 | } |
| 3382 | |
| 3383 | // This is a positive test. No errors should be generated. |
| 3384 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3385 | |
| 3386 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3387 | "submitted on separate queues, the second having a fence, " |
| 3388 | "followed by a WaitForFences call."); |
| 3389 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3390 | if ((m_device->queue_props.empty()) || |
| 3391 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3392 | return; |
| 3393 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3394 | m_errorMonitor->ExpectSuccess(); |
| 3395 | |
| 3396 | VkFence fence; |
| 3397 | VkFenceCreateInfo fence_create_info{}; |
| 3398 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3399 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3400 | |
| 3401 | VkSemaphore semaphore; |
| 3402 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3403 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3404 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3405 | &semaphore); |
| 3406 | |
| 3407 | VkCommandPool command_pool; |
| 3408 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3409 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3410 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3411 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3412 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3413 | &command_pool); |
| 3414 | |
| 3415 | VkCommandBuffer command_buffer[2]; |
| 3416 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3417 | command_buffer_allocate_info.sType = |
| 3418 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3419 | command_buffer_allocate_info.commandPool = command_pool; |
| 3420 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3421 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3422 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3423 | command_buffer); |
| 3424 | |
| 3425 | VkQueue queue = VK_NULL_HANDLE; |
| 3426 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3427 | 1, &queue); |
| 3428 | |
| 3429 | |
| 3430 | { |
| 3431 | VkCommandBufferBeginInfo begin_info{}; |
| 3432 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3433 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3434 | |
| 3435 | vkCmdPipelineBarrier(command_buffer[0], |
| 3436 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3437 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3438 | 0, nullptr, 0, nullptr); |
| 3439 | |
| 3440 | VkViewport viewport{}; |
| 3441 | viewport.maxDepth = 1.0f; |
| 3442 | viewport.minDepth = 0.0f; |
| 3443 | viewport.width = 512; |
| 3444 | viewport.height = 512; |
| 3445 | viewport.x = 0; |
| 3446 | viewport.y = 0; |
| 3447 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3448 | vkEndCommandBuffer(command_buffer[0]); |
| 3449 | } |
| 3450 | { |
| 3451 | VkCommandBufferBeginInfo begin_info{}; |
| 3452 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3453 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3454 | |
| 3455 | VkViewport viewport{}; |
| 3456 | viewport.maxDepth = 1.0f; |
| 3457 | viewport.minDepth = 0.0f; |
| 3458 | viewport.width = 512; |
| 3459 | viewport.height = 512; |
| 3460 | viewport.x = 0; |
| 3461 | viewport.y = 0; |
| 3462 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3463 | vkEndCommandBuffer(command_buffer[1]); |
| 3464 | } |
| 3465 | { |
| 3466 | VkSubmitInfo submit_info{}; |
| 3467 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3468 | submit_info.commandBufferCount = 1; |
| 3469 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3470 | submit_info.signalSemaphoreCount = 1; |
| 3471 | submit_info.pSignalSemaphores = &semaphore; |
| 3472 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3473 | } |
| 3474 | { |
| 3475 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3476 | VkSubmitInfo submit_info{}; |
| 3477 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3478 | submit_info.commandBufferCount = 1; |
| 3479 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3480 | submit_info.waitSemaphoreCount = 1; |
| 3481 | submit_info.pWaitSemaphores = &semaphore; |
| 3482 | submit_info.pWaitDstStageMask = flags; |
| 3483 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3484 | } |
| 3485 | |
| 3486 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3487 | |
| 3488 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3489 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3490 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3491 | &command_buffer[0]); |
| 3492 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3493 | |
| 3494 | m_errorMonitor->VerifyNotFound(); |
| 3495 | } |
| 3496 | |
| 3497 | // This is a positive test. No errors should be generated. |
| 3498 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3499 | |
| 3500 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3501 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3502 | "second having a fence, " |
| 3503 | "followed by a WaitForFences call."); |
| 3504 | |
| 3505 | m_errorMonitor->ExpectSuccess(); |
| 3506 | |
| 3507 | VkFence fence; |
| 3508 | VkFenceCreateInfo fence_create_info{}; |
| 3509 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3510 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3511 | |
| 3512 | VkSemaphore semaphore; |
| 3513 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3514 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3515 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3516 | &semaphore); |
| 3517 | |
| 3518 | VkCommandPool command_pool; |
| 3519 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3520 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3521 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3522 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3523 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3524 | &command_pool); |
| 3525 | |
| 3526 | VkCommandBuffer command_buffer[2]; |
| 3527 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3528 | command_buffer_allocate_info.sType = |
| 3529 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3530 | command_buffer_allocate_info.commandPool = command_pool; |
| 3531 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3532 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3533 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3534 | command_buffer); |
| 3535 | |
| 3536 | { |
| 3537 | VkCommandBufferBeginInfo begin_info{}; |
| 3538 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3539 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3540 | |
| 3541 | vkCmdPipelineBarrier(command_buffer[0], |
| 3542 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3543 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3544 | 0, nullptr, 0, nullptr); |
| 3545 | |
| 3546 | VkViewport viewport{}; |
| 3547 | viewport.maxDepth = 1.0f; |
| 3548 | viewport.minDepth = 0.0f; |
| 3549 | viewport.width = 512; |
| 3550 | viewport.height = 512; |
| 3551 | viewport.x = 0; |
| 3552 | viewport.y = 0; |
| 3553 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3554 | vkEndCommandBuffer(command_buffer[0]); |
| 3555 | } |
| 3556 | { |
| 3557 | VkCommandBufferBeginInfo begin_info{}; |
| 3558 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3559 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3560 | |
| 3561 | VkViewport viewport{}; |
| 3562 | viewport.maxDepth = 1.0f; |
| 3563 | viewport.minDepth = 0.0f; |
| 3564 | viewport.width = 512; |
| 3565 | viewport.height = 512; |
| 3566 | viewport.x = 0; |
| 3567 | viewport.y = 0; |
| 3568 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3569 | vkEndCommandBuffer(command_buffer[1]); |
| 3570 | } |
| 3571 | { |
| 3572 | VkSubmitInfo submit_info{}; |
| 3573 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3574 | submit_info.commandBufferCount = 1; |
| 3575 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3576 | submit_info.signalSemaphoreCount = 1; |
| 3577 | submit_info.pSignalSemaphores = &semaphore; |
| 3578 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3579 | } |
| 3580 | { |
| 3581 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3582 | VkSubmitInfo submit_info{}; |
| 3583 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3584 | submit_info.commandBufferCount = 1; |
| 3585 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3586 | submit_info.waitSemaphoreCount = 1; |
| 3587 | submit_info.pWaitSemaphores = &semaphore; |
| 3588 | submit_info.pWaitDstStageMask = flags; |
| 3589 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3590 | } |
| 3591 | |
| 3592 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3593 | |
| 3594 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3595 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3596 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3597 | &command_buffer[0]); |
| 3598 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3599 | |
| 3600 | m_errorMonitor->VerifyNotFound(); |
| 3601 | } |
| 3602 | |
| 3603 | // This is a positive test. No errors should be generated. |
| 3604 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3605 | |
| 3606 | TEST_DESCRIPTION( |
| 3607 | "Two command buffers, each in a separate QueueSubmit call " |
| 3608 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3609 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3610 | |
| 3611 | m_errorMonitor->ExpectSuccess(); |
| 3612 | |
| 3613 | VkFence fence; |
| 3614 | VkFenceCreateInfo fence_create_info{}; |
| 3615 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3616 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3617 | |
| 3618 | VkCommandPool command_pool; |
| 3619 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3620 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3621 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3622 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3623 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3624 | &command_pool); |
| 3625 | |
| 3626 | VkCommandBuffer command_buffer[2]; |
| 3627 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3628 | command_buffer_allocate_info.sType = |
| 3629 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3630 | command_buffer_allocate_info.commandPool = command_pool; |
| 3631 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3632 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3633 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3634 | command_buffer); |
| 3635 | |
| 3636 | { |
| 3637 | VkCommandBufferBeginInfo begin_info{}; |
| 3638 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3639 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3640 | |
| 3641 | vkCmdPipelineBarrier(command_buffer[0], |
| 3642 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3643 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3644 | 0, nullptr, 0, nullptr); |
| 3645 | |
| 3646 | VkViewport viewport{}; |
| 3647 | viewport.maxDepth = 1.0f; |
| 3648 | viewport.minDepth = 0.0f; |
| 3649 | viewport.width = 512; |
| 3650 | viewport.height = 512; |
| 3651 | viewport.x = 0; |
| 3652 | viewport.y = 0; |
| 3653 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3654 | vkEndCommandBuffer(command_buffer[0]); |
| 3655 | } |
| 3656 | { |
| 3657 | VkCommandBufferBeginInfo begin_info{}; |
| 3658 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3659 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3660 | |
| 3661 | VkViewport viewport{}; |
| 3662 | viewport.maxDepth = 1.0f; |
| 3663 | viewport.minDepth = 0.0f; |
| 3664 | viewport.width = 512; |
| 3665 | viewport.height = 512; |
| 3666 | viewport.x = 0; |
| 3667 | viewport.y = 0; |
| 3668 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3669 | vkEndCommandBuffer(command_buffer[1]); |
| 3670 | } |
| 3671 | { |
| 3672 | VkSubmitInfo submit_info{}; |
| 3673 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3674 | submit_info.commandBufferCount = 1; |
| 3675 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3676 | submit_info.signalSemaphoreCount = 0; |
| 3677 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3678 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3679 | } |
| 3680 | { |
| 3681 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3682 | VkSubmitInfo submit_info{}; |
| 3683 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3684 | submit_info.commandBufferCount = 1; |
| 3685 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3686 | submit_info.waitSemaphoreCount = 0; |
| 3687 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3688 | submit_info.pWaitDstStageMask = flags; |
| 3689 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3690 | } |
| 3691 | |
| 3692 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3693 | |
| 3694 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3695 | |
| 3696 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3697 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3698 | &command_buffer[0]); |
| 3699 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3700 | |
| 3701 | m_errorMonitor->VerifyNotFound(); |
| 3702 | } |
| 3703 | |
| 3704 | // This is a positive test. No errors should be generated. |
| 3705 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3706 | |
| 3707 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3708 | "on the same queue, the second having a fence, followed " |
| 3709 | "by a WaitForFences call."); |
| 3710 | |
| 3711 | m_errorMonitor->ExpectSuccess(); |
| 3712 | |
| 3713 | VkFence fence; |
| 3714 | VkFenceCreateInfo fence_create_info{}; |
| 3715 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3716 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3717 | |
| 3718 | VkCommandPool command_pool; |
| 3719 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3720 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3721 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3722 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3723 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3724 | &command_pool); |
| 3725 | |
| 3726 | VkCommandBuffer command_buffer[2]; |
| 3727 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3728 | command_buffer_allocate_info.sType = |
| 3729 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3730 | command_buffer_allocate_info.commandPool = command_pool; |
| 3731 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3732 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3733 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3734 | command_buffer); |
| 3735 | |
| 3736 | { |
| 3737 | VkCommandBufferBeginInfo begin_info{}; |
| 3738 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3739 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3740 | |
| 3741 | vkCmdPipelineBarrier(command_buffer[0], |
| 3742 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3743 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3744 | 0, nullptr, 0, nullptr); |
| 3745 | |
| 3746 | VkViewport viewport{}; |
| 3747 | viewport.maxDepth = 1.0f; |
| 3748 | viewport.minDepth = 0.0f; |
| 3749 | viewport.width = 512; |
| 3750 | viewport.height = 512; |
| 3751 | viewport.x = 0; |
| 3752 | viewport.y = 0; |
| 3753 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3754 | vkEndCommandBuffer(command_buffer[0]); |
| 3755 | } |
| 3756 | { |
| 3757 | VkCommandBufferBeginInfo begin_info{}; |
| 3758 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3759 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 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[1], 0, 1, &viewport); |
| 3769 | vkEndCommandBuffer(command_buffer[1]); |
| 3770 | } |
| 3771 | { |
| 3772 | VkSubmitInfo submit_info{}; |
| 3773 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3774 | submit_info.commandBufferCount = 1; |
| 3775 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3776 | submit_info.signalSemaphoreCount = 0; |
| 3777 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3778 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3779 | } |
| 3780 | { |
| 3781 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3782 | VkSubmitInfo submit_info{}; |
| 3783 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3784 | submit_info.commandBufferCount = 1; |
| 3785 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3786 | submit_info.waitSemaphoreCount = 0; |
| 3787 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3788 | submit_info.pWaitDstStageMask = flags; |
| 3789 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3790 | } |
| 3791 | |
| 3792 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3793 | |
| 3794 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3795 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3796 | &command_buffer[0]); |
| 3797 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3798 | |
| 3799 | m_errorMonitor->VerifyNotFound(); |
| 3800 | } |
| 3801 | |
| 3802 | // This is a positive test. No errors should be generated. |
| 3803 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3804 | |
| 3805 | TEST_DESCRIPTION( |
| 3806 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3807 | "QueueSubmit call followed by a WaitForFences call."); |
| 3808 | |
| 3809 | m_errorMonitor->ExpectSuccess(); |
| 3810 | |
| 3811 | VkFence fence; |
| 3812 | VkFenceCreateInfo fence_create_info{}; |
| 3813 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3814 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3815 | |
| 3816 | VkSemaphore semaphore; |
| 3817 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3818 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3819 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3820 | &semaphore); |
| 3821 | |
| 3822 | VkCommandPool command_pool; |
| 3823 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3824 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3825 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3826 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3827 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3828 | &command_pool); |
| 3829 | |
| 3830 | VkCommandBuffer command_buffer[2]; |
| 3831 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3832 | command_buffer_allocate_info.sType = |
| 3833 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3834 | command_buffer_allocate_info.commandPool = command_pool; |
| 3835 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3836 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3837 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3838 | command_buffer); |
| 3839 | |
| 3840 | { |
| 3841 | VkCommandBufferBeginInfo begin_info{}; |
| 3842 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3843 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3844 | |
| 3845 | vkCmdPipelineBarrier(command_buffer[0], |
| 3846 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3847 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3848 | 0, nullptr, 0, nullptr); |
| 3849 | |
| 3850 | VkViewport viewport{}; |
| 3851 | viewport.maxDepth = 1.0f; |
| 3852 | viewport.minDepth = 0.0f; |
| 3853 | viewport.width = 512; |
| 3854 | viewport.height = 512; |
| 3855 | viewport.x = 0; |
| 3856 | viewport.y = 0; |
| 3857 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3858 | vkEndCommandBuffer(command_buffer[0]); |
| 3859 | } |
| 3860 | { |
| 3861 | VkCommandBufferBeginInfo begin_info{}; |
| 3862 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3863 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3864 | |
| 3865 | VkViewport viewport{}; |
| 3866 | viewport.maxDepth = 1.0f; |
| 3867 | viewport.minDepth = 0.0f; |
| 3868 | viewport.width = 512; |
| 3869 | viewport.height = 512; |
| 3870 | viewport.x = 0; |
| 3871 | viewport.y = 0; |
| 3872 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3873 | vkEndCommandBuffer(command_buffer[1]); |
| 3874 | } |
| 3875 | { |
| 3876 | VkSubmitInfo submit_info[2]; |
| 3877 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3878 | |
| 3879 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3880 | submit_info[0].pNext = NULL; |
| 3881 | submit_info[0].commandBufferCount = 1; |
| 3882 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3883 | submit_info[0].signalSemaphoreCount = 1; |
| 3884 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3885 | submit_info[0].waitSemaphoreCount = 0; |
| 3886 | submit_info[0].pWaitSemaphores = NULL; |
| 3887 | submit_info[0].pWaitDstStageMask = 0; |
| 3888 | |
| 3889 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3890 | submit_info[1].pNext = NULL; |
| 3891 | submit_info[1].commandBufferCount = 1; |
| 3892 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3893 | submit_info[1].waitSemaphoreCount = 1; |
| 3894 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3895 | submit_info[1].pWaitDstStageMask = flags; |
| 3896 | submit_info[1].signalSemaphoreCount = 0; |
| 3897 | submit_info[1].pSignalSemaphores = NULL; |
| 3898 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3899 | } |
| 3900 | |
| 3901 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3902 | |
| 3903 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3904 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3905 | &command_buffer[0]); |
| 3906 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3907 | |
| 3908 | m_errorMonitor->VerifyNotFound(); |
| 3909 | } |
| 3910 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3911 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3912 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3913 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 3914 | "state is required but not correctly bound."); |
| 3915 | |
| 3916 | // Dynamic depth bias |
| 3917 | m_errorMonitor->SetDesiredFailureMsg( |
| 3918 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3919 | "Dynamic depth bias state not set for this command buffer"); |
| 3920 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3921 | BsoFailDepthBias); |
| 3922 | m_errorMonitor->VerifyFound(); |
| 3923 | } |
| 3924 | |
| 3925 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 3926 | TEST_DESCRIPTION( |
| 3927 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 3928 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3929 | |
| 3930 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | m_errorMonitor->SetDesiredFailureMsg( |
| 3932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3933 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3934 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3935 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3936 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3937 | } |
| 3938 | |
| 3939 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 3940 | TEST_DESCRIPTION( |
| 3941 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 3942 | "state is required but not correctly bound."); |
| 3943 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3944 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3945 | m_errorMonitor->SetDesiredFailureMsg( |
| 3946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3947 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3949 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3950 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 3954 | TEST_DESCRIPTION( |
| 3955 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 3956 | "state is required but not correctly bound."); |
| 3957 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3958 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3959 | m_errorMonitor->SetDesiredFailureMsg( |
| 3960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3961 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3962 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3963 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3964 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3965 | } |
| 3966 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3967 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3968 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3969 | "Run a simple draw calls to validate failure when Blend Constants " |
| 3970 | "dynamic state is required but not correctly bound."); |
| 3971 | // Dynamic blend constant state |
| 3972 | m_errorMonitor->SetDesiredFailureMsg( |
| 3973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3974 | "Dynamic blend constants state not set for this command buffer"); |
| 3975 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3976 | BsoFailBlend); |
| 3977 | m_errorMonitor->VerifyFound(); |
| 3978 | } |
| 3979 | |
| 3980 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 3981 | TEST_DESCRIPTION( |
| 3982 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3983 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3984 | if (!m_device->phy().features().depthBounds) { |
| 3985 | printf("Device does not support depthBounds test; skipped.\n"); |
| 3986 | return; |
| 3987 | } |
| 3988 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | m_errorMonitor->SetDesiredFailureMsg( |
| 3990 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3991 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3992 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3993 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3994 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3995 | } |
| 3996 | |
| 3997 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 3998 | TEST_DESCRIPTION( |
| 3999 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4000 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4001 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4002 | m_errorMonitor->SetDesiredFailureMsg( |
| 4003 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4004 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4006 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4007 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4011 | TEST_DESCRIPTION( |
| 4012 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4013 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4014 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | m_errorMonitor->SetDesiredFailureMsg( |
| 4016 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4017 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4018 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4019 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4020 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4021 | } |
| 4022 | |
| 4023 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4024 | TEST_DESCRIPTION( |
| 4025 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4026 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4027 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4028 | m_errorMonitor->SetDesiredFailureMsg( |
| 4029 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4030 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4031 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4032 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4033 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4034 | } |
| 4035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4036 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4037 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4039 | m_errorMonitor->SetDesiredFailureMsg( |
| 4040 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4041 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4042 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4043 | |
| 4044 | VkFenceCreateInfo fenceInfo = {}; |
| 4045 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4046 | fenceInfo.pNext = NULL; |
| 4047 | fenceInfo.flags = 0; |
| 4048 | |
| 4049 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4050 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4051 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | // We luck out b/c by default the framework creates CB w/ the |
| 4054 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4055 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4056 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4057 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4058 | EndCommandBuffer(); |
| 4059 | |
| 4060 | testFence.init(*m_device, fenceInfo); |
| 4061 | |
| 4062 | // Bypass framework since it does the waits automatically |
| 4063 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4064 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4065 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4066 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4067 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4068 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4069 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4070 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4071 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4072 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4073 | submit_info.pSignalSemaphores = NULL; |
| 4074 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 4076 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4078 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4079 | // submitted once |
| 4080 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4082 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4083 | } |
| 4084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4086 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4087 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4088 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4089 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | "Unable to allocate 1 descriptors of " |
| 4091 | "type " |
| 4092 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4093 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4094 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4095 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4097 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4098 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4099 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4100 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4101 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4102 | |
| 4103 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4104 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4105 | ds_pool_ci.pNext = NULL; |
| 4106 | ds_pool_ci.flags = 0; |
| 4107 | ds_pool_ci.maxSets = 1; |
| 4108 | ds_pool_ci.poolSizeCount = 1; |
| 4109 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4110 | |
| 4111 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4112 | err = |
| 4113 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4114 | ASSERT_VK_SUCCESS(err); |
| 4115 | |
| 4116 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | dsl_binding.binding = 0; |
| 4118 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4119 | dsl_binding.descriptorCount = 1; |
| 4120 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4121 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4122 | |
| 4123 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4125 | ds_layout_ci.pNext = NULL; |
| 4126 | ds_layout_ci.bindingCount = 1; |
| 4127 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4128 | |
| 4129 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4130 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4131 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4132 | ASSERT_VK_SUCCESS(err); |
| 4133 | |
| 4134 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4135 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4136 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4137 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4138 | alloc_info.descriptorPool = ds_pool; |
| 4139 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4141 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4142 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4143 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4144 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4145 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4146 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4147 | } |
| 4148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4149 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4150 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | m_errorMonitor->SetDesiredFailureMsg( |
| 4153 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4154 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4155 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4156 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4157 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4158 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4159 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4160 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4162 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4163 | |
| 4164 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4165 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4166 | ds_pool_ci.pNext = NULL; |
| 4167 | ds_pool_ci.maxSets = 1; |
| 4168 | ds_pool_ci.poolSizeCount = 1; |
| 4169 | ds_pool_ci.flags = 0; |
| 4170 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4171 | // app can only call vkResetDescriptorPool on this pool.; |
| 4172 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4173 | |
| 4174 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4175 | err = |
| 4176 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4177 | ASSERT_VK_SUCCESS(err); |
| 4178 | |
| 4179 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4180 | dsl_binding.binding = 0; |
| 4181 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4182 | dsl_binding.descriptorCount = 1; |
| 4183 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4184 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4185 | |
| 4186 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4187 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4188 | ds_layout_ci.pNext = NULL; |
| 4189 | ds_layout_ci.bindingCount = 1; |
| 4190 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4191 | |
| 4192 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4194 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4195 | ASSERT_VK_SUCCESS(err); |
| 4196 | |
| 4197 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4198 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4199 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4200 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4201 | alloc_info.descriptorPool = ds_pool; |
| 4202 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4203 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4204 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4205 | ASSERT_VK_SUCCESS(err); |
| 4206 | |
| 4207 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4208 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4209 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4210 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4211 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4212 | } |
| 4213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4214 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4215 | // Attempt to clear Descriptor Pool with bad object. |
| 4216 | // ObjectTracker should catch this. |
| 4217 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4218 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4219 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4220 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4221 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4222 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4223 | } |
| 4224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4226 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4227 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4228 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4229 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4230 | |
| 4231 | uint64_t fake_set_handle = 0xbaad6001; |
| 4232 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4233 | VkResult err; |
| 4234 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4235 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4236 | |
| 4237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4238 | |
| 4239 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4240 | layout_bindings[0].binding = 0; |
| 4241 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4242 | layout_bindings[0].descriptorCount = 1; |
| 4243 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4244 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4245 | |
| 4246 | VkDescriptorSetLayout descriptor_set_layout; |
| 4247 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4248 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4249 | dslci.pNext = NULL; |
| 4250 | dslci.bindingCount = 1; |
| 4251 | dslci.pBindings = layout_bindings; |
| 4252 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4253 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4254 | |
| 4255 | VkPipelineLayout pipeline_layout; |
| 4256 | VkPipelineLayoutCreateInfo plci = {}; |
| 4257 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4258 | plci.pNext = NULL; |
| 4259 | plci.setLayoutCount = 1; |
| 4260 | plci.pSetLayouts = &descriptor_set_layout; |
| 4261 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4262 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4263 | |
| 4264 | BeginCommandBuffer(); |
| 4265 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4266 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4267 | m_errorMonitor->VerifyFound(); |
| 4268 | EndCommandBuffer(); |
| 4269 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4270 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4271 | } |
| 4272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4274 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4275 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4276 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4277 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4278 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4279 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4280 | |
| 4281 | VkPipelineLayout pipeline_layout; |
| 4282 | VkPipelineLayoutCreateInfo plci = {}; |
| 4283 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4284 | plci.pNext = NULL; |
| 4285 | plci.setLayoutCount = 1; |
| 4286 | plci.pSetLayouts = &bad_layout; |
| 4287 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4288 | |
| 4289 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4290 | } |
| 4291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4292 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4293 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4294 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4295 | // Create a valid cmd buffer |
| 4296 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4297 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4298 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4299 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4300 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4302 | BeginCommandBuffer(); |
| 4303 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4304 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4305 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4306 | |
| 4307 | // Now issue a draw call with no pipeline bound |
| 4308 | m_errorMonitor->SetDesiredFailureMsg( |
| 4309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4310 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4311 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4312 | BeginCommandBuffer(); |
| 4313 | Draw(1, 0, 0, 0); |
| 4314 | m_errorMonitor->VerifyFound(); |
| 4315 | // Finally same check once more but with Dispatch/Compute |
| 4316 | m_errorMonitor->SetDesiredFailureMsg( |
| 4317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4318 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4319 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4320 | BeginCommandBuffer(); |
| 4321 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4322 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4323 | } |
| 4324 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4325 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4326 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4327 | // CommandBuffer |
| 4328 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4329 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4330 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4331 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4332 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4333 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4334 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4335 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4336 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4338 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4339 | |
| 4340 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4341 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4342 | ds_pool_ci.pNext = NULL; |
| 4343 | ds_pool_ci.maxSets = 1; |
| 4344 | ds_pool_ci.poolSizeCount = 1; |
| 4345 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4346 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4347 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4348 | err = |
| 4349 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4350 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4351 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4352 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4353 | dsl_binding.binding = 0; |
| 4354 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4355 | dsl_binding.descriptorCount = 1; |
| 4356 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4357 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4358 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4359 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4361 | ds_layout_ci.pNext = NULL; |
| 4362 | ds_layout_ci.bindingCount = 1; |
| 4363 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4364 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4365 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4366 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4367 | ASSERT_VK_SUCCESS(err); |
| 4368 | |
| 4369 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4370 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4371 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4372 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4373 | alloc_info.descriptorPool = ds_pool; |
| 4374 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4375 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4376 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4377 | ASSERT_VK_SUCCESS(err); |
| 4378 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4379 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4380 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4381 | pipeline_layout_ci.pNext = NULL; |
| 4382 | pipeline_layout_ci.setLayoutCount = 1; |
| 4383 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4384 | |
| 4385 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4387 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4388 | ASSERT_VK_SUCCESS(err); |
| 4389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4391 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4392 | // 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] | 4393 | // on more devices |
| 4394 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4395 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4396 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4397 | VkPipelineObj pipe(m_device); |
| 4398 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4399 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4400 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4401 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4402 | |
| 4403 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4404 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4405 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4408 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4409 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4410 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4411 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4412 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4413 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4414 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4415 | } |
| 4416 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4417 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4418 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4420 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4423 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4424 | |
| 4425 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4426 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4427 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4428 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4429 | |
| 4430 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4432 | ds_pool_ci.pNext = NULL; |
| 4433 | ds_pool_ci.maxSets = 1; |
| 4434 | ds_pool_ci.poolSizeCount = 1; |
| 4435 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4436 | |
| 4437 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4438 | err = |
| 4439 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4440 | ASSERT_VK_SUCCESS(err); |
| 4441 | |
| 4442 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4443 | dsl_binding.binding = 0; |
| 4444 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4445 | dsl_binding.descriptorCount = 1; |
| 4446 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4447 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4448 | |
| 4449 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4451 | ds_layout_ci.pNext = NULL; |
| 4452 | ds_layout_ci.bindingCount = 1; |
| 4453 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4454 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4456 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4457 | ASSERT_VK_SUCCESS(err); |
| 4458 | |
| 4459 | VkDescriptorSet descriptorSet; |
| 4460 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4461 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4462 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4463 | alloc_info.descriptorPool = ds_pool; |
| 4464 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4465 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4466 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4467 | ASSERT_VK_SUCCESS(err); |
| 4468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4469 | VkBufferView view = |
| 4470 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4471 | VkWriteDescriptorSet descriptor_write; |
| 4472 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4473 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4474 | descriptor_write.dstSet = descriptorSet; |
| 4475 | descriptor_write.dstBinding = 0; |
| 4476 | descriptor_write.descriptorCount = 1; |
| 4477 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4478 | descriptor_write.pTexelBufferView = &view; |
| 4479 | |
| 4480 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4481 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4482 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4483 | |
| 4484 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4485 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4486 | } |
| 4487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4488 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4489 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4490 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4491 | // 1. No dynamicOffset supplied |
| 4492 | // 2. Too many dynamicOffsets supplied |
| 4493 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4495 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4496 | " requires 1 dynamicOffsets, but only " |
| 4497 | "0 dynamicOffsets are left in " |
| 4498 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4499 | |
| 4500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4501 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4502 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4503 | |
| 4504 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4506 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4507 | |
| 4508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4510 | ds_pool_ci.pNext = NULL; |
| 4511 | ds_pool_ci.maxSets = 1; |
| 4512 | ds_pool_ci.poolSizeCount = 1; |
| 4513 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4514 | |
| 4515 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4516 | err = |
| 4517 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4518 | ASSERT_VK_SUCCESS(err); |
| 4519 | |
| 4520 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4521 | dsl_binding.binding = 0; |
| 4522 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4523 | dsl_binding.descriptorCount = 1; |
| 4524 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4525 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4526 | |
| 4527 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4528 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4529 | ds_layout_ci.pNext = NULL; |
| 4530 | ds_layout_ci.bindingCount = 1; |
| 4531 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4532 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4534 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4535 | ASSERT_VK_SUCCESS(err); |
| 4536 | |
| 4537 | VkDescriptorSet descriptorSet; |
| 4538 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4539 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4540 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4541 | alloc_info.descriptorPool = ds_pool; |
| 4542 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4543 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4544 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4545 | ASSERT_VK_SUCCESS(err); |
| 4546 | |
| 4547 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4548 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4549 | pipeline_layout_ci.pNext = NULL; |
| 4550 | pipeline_layout_ci.setLayoutCount = 1; |
| 4551 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4552 | |
| 4553 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4554 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4555 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4556 | ASSERT_VK_SUCCESS(err); |
| 4557 | |
| 4558 | // Create a buffer to update the descriptor with |
| 4559 | uint32_t qfi = 0; |
| 4560 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4561 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4562 | buffCI.size = 1024; |
| 4563 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4564 | buffCI.queueFamilyIndexCount = 1; |
| 4565 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4566 | |
| 4567 | VkBuffer dyub; |
| 4568 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4569 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4570 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4571 | // error |
| 4572 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4573 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4574 | mem_alloc.pNext = NULL; |
| 4575 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4576 | mem_alloc.memoryTypeIndex = 0; |
| 4577 | |
| 4578 | VkMemoryRequirements memReqs; |
| 4579 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4580 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4581 | 0); |
| 4582 | if (!pass) { |
| 4583 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4584 | return; |
| 4585 | } |
| 4586 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4587 | VkDeviceMemory mem; |
| 4588 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4589 | ASSERT_VK_SUCCESS(err); |
| 4590 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4591 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4592 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4593 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4594 | buffInfo.buffer = dyub; |
| 4595 | buffInfo.offset = 0; |
| 4596 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4597 | |
| 4598 | VkWriteDescriptorSet descriptor_write; |
| 4599 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4600 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4601 | descriptor_write.dstSet = descriptorSet; |
| 4602 | descriptor_write.dstBinding = 0; |
| 4603 | descriptor_write.descriptorCount = 1; |
| 4604 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4605 | descriptor_write.pBufferInfo = &buffInfo; |
| 4606 | |
| 4607 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4608 | |
| 4609 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4610 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4611 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4612 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4613 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4614 | uint32_t pDynOff[2] = {512, 756}; |
| 4615 | // 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] | 4616 | m_errorMonitor->SetDesiredFailureMsg( |
| 4617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4618 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4619 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4620 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4621 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4622 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4623 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4624 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4625 | " dynamic offset 512 combined with " |
| 4626 | "offset 0 and range 1024 that " |
| 4627 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4628 | // Create PSO to be used for draw-time errors below |
| 4629 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4630 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4631 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4632 | "out gl_PerVertex { \n" |
| 4633 | " vec4 gl_Position;\n" |
| 4634 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4635 | "void main(){\n" |
| 4636 | " gl_Position = vec4(1);\n" |
| 4637 | "}\n"; |
| 4638 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4639 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4640 | "\n" |
| 4641 | "layout(location=0) out vec4 x;\n" |
| 4642 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4643 | "void main(){\n" |
| 4644 | " x = vec4(bar.y);\n" |
| 4645 | "}\n"; |
| 4646 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4647 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4648 | VkPipelineObj pipe(m_device); |
| 4649 | pipe.AddShader(&vs); |
| 4650 | pipe.AddShader(&fs); |
| 4651 | pipe.AddColorAttachment(); |
| 4652 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4654 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4655 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4656 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4657 | // /w range 1024 & size 1024 |
| 4658 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4659 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4660 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4661 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4662 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4663 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4664 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4665 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4666 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4667 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4668 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4669 | } |
| 4670 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4671 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4672 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4674 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4675 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4676 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4677 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4678 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4679 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4680 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4681 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4682 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4683 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4684 | // |
| 4685 | // Check for invalid push constant ranges in pipeline layouts. |
| 4686 | // |
| 4687 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4688 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4689 | char const *msg; |
| 4690 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4691 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4692 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4693 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4694 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4695 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4696 | "size 0."}, |
| 4697 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4698 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4699 | "size 1."}, |
| 4700 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4701 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4702 | "size 1."}, |
| 4703 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4704 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4705 | "size 0."}, |
| 4706 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4707 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4708 | "offset 1. Offset must"}, |
| 4709 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4710 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4711 | "with offset "}, |
| 4712 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4713 | "vkCreatePipelineLayout() call has push constants " |
| 4714 | "index 0 with offset "}, |
| 4715 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4716 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4717 | "with offset "}, |
| 4718 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4719 | "vkCreatePipelineLayout() call has push " |
| 4720 | "constants index 0 with offset "}, |
| 4721 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4722 | "vkCreatePipelineLayout() call has push " |
| 4723 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4724 | }}; |
| 4725 | |
| 4726 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4727 | for (const auto &iter : range_tests) { |
| 4728 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4730 | iter.msg); |
| 4731 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4732 | NULL, &pipeline_layout); |
| 4733 | m_errorMonitor->VerifyFound(); |
| 4734 | if (VK_SUCCESS == err) { |
| 4735 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4736 | } |
| 4737 | } |
| 4738 | |
| 4739 | // Check for invalid stage flag |
| 4740 | pc_range.offset = 0; |
| 4741 | pc_range.size = 16; |
| 4742 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4743 | m_errorMonitor->SetDesiredFailureMsg( |
| 4744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4745 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4746 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4747 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4748 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4749 | if (VK_SUCCESS == err) { |
| 4750 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4751 | } |
| 4752 | |
| 4753 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4754 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4755 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4756 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4757 | char const *msg; |
| 4758 | }; |
| 4759 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4760 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4761 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4762 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4763 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4764 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4765 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4766 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4767 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4768 | { |
| 4769 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4770 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4771 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4772 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4773 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4774 | "vkCreatePipelineLayout() call has push constants with " |
| 4775 | "overlapping " |
| 4776 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4777 | }, |
| 4778 | { |
| 4779 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4780 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4781 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4782 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4783 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4784 | "vkCreatePipelineLayout() call has push constants with " |
| 4785 | "overlapping " |
| 4786 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4787 | }, |
| 4788 | { |
| 4789 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4790 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4791 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4792 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4793 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4794 | "vkCreatePipelineLayout() call has push constants with " |
| 4795 | "overlapping " |
| 4796 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4797 | }, |
| 4798 | { |
| 4799 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4800 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4801 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4802 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4803 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4804 | "vkCreatePipelineLayout() call has push constants with " |
| 4805 | "overlapping " |
| 4806 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4807 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4808 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4809 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4810 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4811 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4812 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4813 | iter.msg); |
| 4814 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4815 | NULL, &pipeline_layout); |
| 4816 | m_errorMonitor->VerifyFound(); |
| 4817 | if (VK_SUCCESS == err) { |
| 4818 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4819 | } |
| 4820 | } |
| 4821 | |
| 4822 | // 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] | 4823 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4824 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4825 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4826 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4827 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4828 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4829 | ""}, |
| 4830 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4831 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4832 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4833 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4834 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4835 | ""}}}; |
| 4836 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4837 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4838 | m_errorMonitor->ExpectSuccess(); |
| 4839 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4840 | NULL, &pipeline_layout); |
| 4841 | m_errorMonitor->VerifyNotFound(); |
| 4842 | if (VK_SUCCESS == err) { |
| 4843 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4844 | } |
| 4845 | } |
| 4846 | |
| 4847 | // |
| 4848 | // CmdPushConstants tests |
| 4849 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4850 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4851 | |
| 4852 | // 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] | 4853 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4854 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4855 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4856 | "must be greater than zero and a multiple of 4."}, |
| 4857 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4858 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4859 | "must be greater than zero and a multiple of 4."}, |
| 4860 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4861 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4862 | "must be greater than zero and a multiple of 4."}, |
| 4863 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4864 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4865 | "Offset must be a multiple of 4."}, |
| 4866 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4867 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4868 | "Offset must be a multiple of 4."}, |
| 4869 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4870 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4871 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4872 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4873 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4874 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4875 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4876 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4877 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4878 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4879 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4880 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4881 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4882 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4883 | "any of the ranges in pipeline layout"}, |
| 4884 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4885 | 0, 16}, |
| 4886 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4887 | "any of the ranges in pipeline layout"}, |
| 4888 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4889 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4890 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4891 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4892 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4893 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4894 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4895 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4896 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4897 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4898 | }}; |
| 4899 | |
| 4900 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4901 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4902 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4903 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4904 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4905 | pipeline_layout_ci.pushConstantRangeCount = |
| 4906 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4907 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4908 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4909 | &pipeline_layout); |
| 4910 | ASSERT_VK_SUCCESS(err); |
| 4911 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4912 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4913 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4914 | iter.msg); |
| 4915 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4916 | iter.range.stageFlags, iter.range.offset, |
| 4917 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4918 | m_errorMonitor->VerifyFound(); |
| 4919 | } |
| 4920 | |
| 4921 | // Check for invalid stage flag |
| 4922 | m_errorMonitor->SetDesiredFailureMsg( |
| 4923 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4924 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4925 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4926 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4927 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4928 | EndCommandBuffer(); |
| 4929 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4930 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4931 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4932 | // overlapping range tests with cmd |
| 4933 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4934 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4935 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4936 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4937 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4938 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4939 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4940 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4941 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4942 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4943 | }}; |
| 4944 | const VkPushConstantRange pc_range3[] = { |
| 4945 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4946 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4947 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4948 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4949 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4950 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4951 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4952 | }; |
| 4953 | pipeline_layout_ci.pushConstantRangeCount = |
| 4954 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4955 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4956 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4957 | &pipeline_layout); |
| 4958 | ASSERT_VK_SUCCESS(err); |
| 4959 | BeginCommandBuffer(); |
| 4960 | for (const auto &iter : cmd_overlap_tests) { |
| 4961 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4962 | iter.msg); |
| 4963 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4964 | iter.range.stageFlags, iter.range.offset, |
| 4965 | iter.range.size, dummy_values); |
| 4966 | m_errorMonitor->VerifyFound(); |
| 4967 | } |
| 4968 | EndCommandBuffer(); |
| 4969 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4970 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4971 | |
| 4972 | // positive overlapping range tests with cmd |
| 4973 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4974 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4975 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4976 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4977 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4978 | }}; |
| 4979 | const VkPushConstantRange pc_range4[] = { |
| 4980 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4981 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4982 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4983 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4984 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4985 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4986 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4987 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4988 | }; |
| 4989 | pipeline_layout_ci.pushConstantRangeCount = |
| 4990 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4991 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4992 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4993 | &pipeline_layout); |
| 4994 | ASSERT_VK_SUCCESS(err); |
| 4995 | BeginCommandBuffer(); |
| 4996 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4997 | m_errorMonitor->ExpectSuccess(); |
| 4998 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4999 | iter.range.stageFlags, iter.range.offset, |
| 5000 | iter.range.size, dummy_values); |
| 5001 | m_errorMonitor->VerifyNotFound(); |
| 5002 | } |
| 5003 | EndCommandBuffer(); |
| 5004 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5005 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5006 | } |
| 5007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5009 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5010 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5011 | |
| 5012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5013 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5015 | |
| 5016 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5017 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5018 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5019 | ds_type_count[0].descriptorCount = 10; |
| 5020 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5021 | ds_type_count[1].descriptorCount = 2; |
| 5022 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5023 | ds_type_count[2].descriptorCount = 2; |
| 5024 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5025 | ds_type_count[3].descriptorCount = 5; |
| 5026 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5027 | // type |
| 5028 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5029 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5030 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5031 | |
| 5032 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5033 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5034 | ds_pool_ci.pNext = NULL; |
| 5035 | ds_pool_ci.maxSets = 5; |
| 5036 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5037 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5038 | |
| 5039 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5040 | err = |
| 5041 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5042 | ASSERT_VK_SUCCESS(err); |
| 5043 | |
| 5044 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5045 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5046 | dsl_binding[0].binding = 0; |
| 5047 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5048 | dsl_binding[0].descriptorCount = 5; |
| 5049 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5050 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5051 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5052 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5053 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5054 | dsl_fs_stage_only.binding = 0; |
| 5055 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5056 | dsl_fs_stage_only.descriptorCount = 5; |
| 5057 | dsl_fs_stage_only.stageFlags = |
| 5058 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5059 | // bind time |
| 5060 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5061 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5062 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5063 | ds_layout_ci.pNext = NULL; |
| 5064 | ds_layout_ci.bindingCount = 1; |
| 5065 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5066 | static const uint32_t NUM_LAYOUTS = 4; |
| 5067 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5068 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5069 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5070 | // layout for error case |
| 5071 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5072 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5073 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5074 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5075 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5076 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5077 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5078 | dsl_binding[0].binding = 0; |
| 5079 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5080 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5081 | dsl_binding[1].binding = 1; |
| 5082 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5083 | dsl_binding[1].descriptorCount = 2; |
| 5084 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5085 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5086 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5087 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5088 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5089 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5090 | ASSERT_VK_SUCCESS(err); |
| 5091 | dsl_binding[0].binding = 0; |
| 5092 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5093 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5094 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5095 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5096 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5097 | ASSERT_VK_SUCCESS(err); |
| 5098 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5099 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5101 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | |
| 5104 | static const uint32_t NUM_SETS = 4; |
| 5105 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5106 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5107 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5108 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5109 | alloc_info.descriptorPool = ds_pool; |
| 5110 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5111 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5112 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5113 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5114 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5115 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5116 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5117 | err = |
| 5118 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5119 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5120 | |
| 5121 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5122 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5123 | pipeline_layout_ci.pNext = NULL; |
| 5124 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5125 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5126 | |
| 5127 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5128 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5129 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5130 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5131 | // Create pipelineLayout with only one setLayout |
| 5132 | pipeline_layout_ci.setLayoutCount = 1; |
| 5133 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5134 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5135 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5136 | ASSERT_VK_SUCCESS(err); |
| 5137 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5138 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5139 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5140 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5141 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5142 | ASSERT_VK_SUCCESS(err); |
| 5143 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5144 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5145 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5146 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5147 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5148 | ASSERT_VK_SUCCESS(err); |
| 5149 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5150 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5151 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5152 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5153 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5154 | ASSERT_VK_SUCCESS(err); |
| 5155 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5156 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5157 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5158 | pl_bad_s0[1] = ds_layout[1]; |
| 5159 | pipeline_layout_ci.setLayoutCount = 2; |
| 5160 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5161 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5163 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5164 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5165 | |
| 5166 | // Create a buffer to update the descriptor with |
| 5167 | uint32_t qfi = 0; |
| 5168 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5169 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5170 | buffCI.size = 1024; |
| 5171 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5172 | buffCI.queueFamilyIndexCount = 1; |
| 5173 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5174 | |
| 5175 | VkBuffer dyub; |
| 5176 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5177 | ASSERT_VK_SUCCESS(err); |
| 5178 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5179 | static const uint32_t NUM_BUFFS = 5; |
| 5180 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5181 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5182 | buffInfo[i].buffer = dyub; |
| 5183 | buffInfo[i].offset = 0; |
| 5184 | buffInfo[i].range = 1024; |
| 5185 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5186 | VkImage image; |
| 5187 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5188 | const int32_t tex_width = 32; |
| 5189 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5190 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5191 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5192 | image_create_info.pNext = NULL; |
| 5193 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5194 | image_create_info.format = tex_format; |
| 5195 | image_create_info.extent.width = tex_width; |
| 5196 | image_create_info.extent.height = tex_height; |
| 5197 | image_create_info.extent.depth = 1; |
| 5198 | image_create_info.mipLevels = 1; |
| 5199 | image_create_info.arrayLayers = 1; |
| 5200 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5201 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5202 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5203 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5204 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5205 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5207 | VkMemoryRequirements memReqs; |
| 5208 | VkDeviceMemory imageMem; |
| 5209 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5210 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5211 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5212 | memAlloc.pNext = NULL; |
| 5213 | memAlloc.allocationSize = 0; |
| 5214 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5215 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5216 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5217 | pass = |
| 5218 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5219 | ASSERT_TRUE(pass); |
| 5220 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5221 | ASSERT_VK_SUCCESS(err); |
| 5222 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5223 | ASSERT_VK_SUCCESS(err); |
| 5224 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5225 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5226 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5227 | image_view_create_info.image = image; |
| 5228 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5229 | image_view_create_info.format = tex_format; |
| 5230 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5231 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5232 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5233 | image_view_create_info.subresourceRange.aspectMask = |
| 5234 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5235 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5236 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5238 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5239 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5240 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5241 | imageInfo[0].imageView = view; |
| 5242 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5243 | imageInfo[1].imageView = view; |
| 5244 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5245 | imageInfo[2].imageView = view; |
| 5246 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5247 | imageInfo[3].imageView = view; |
| 5248 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5249 | |
| 5250 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5251 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5252 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5253 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5254 | descriptor_write[0].dstBinding = 0; |
| 5255 | descriptor_write[0].descriptorCount = 5; |
| 5256 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5257 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5258 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5259 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5260 | descriptor_write[1].dstBinding = 0; |
| 5261 | descriptor_write[1].descriptorCount = 2; |
| 5262 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5263 | descriptor_write[1].pImageInfo = imageInfo; |
| 5264 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5265 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5266 | descriptor_write[2].dstBinding = 1; |
| 5267 | descriptor_write[2].descriptorCount = 2; |
| 5268 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5269 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5270 | |
| 5271 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5272 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5273 | // Create PSO to be used for draw-time errors below |
| 5274 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5275 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5276 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5277 | "out gl_PerVertex {\n" |
| 5278 | " vec4 gl_Position;\n" |
| 5279 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5280 | "void main(){\n" |
| 5281 | " gl_Position = vec4(1);\n" |
| 5282 | "}\n"; |
| 5283 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5284 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5285 | "\n" |
| 5286 | "layout(location=0) out vec4 x;\n" |
| 5287 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5288 | "void main(){\n" |
| 5289 | " x = vec4(bar.y);\n" |
| 5290 | "}\n"; |
| 5291 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5292 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5293 | VkPipelineObj pipe(m_device); |
| 5294 | pipe.AddShader(&vs); |
| 5295 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5296 | pipe.AddColorAttachment(); |
| 5297 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5298 | |
| 5299 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5301 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5302 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5303 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5304 | // of PSO |
| 5305 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5306 | // cmd_pipeline.c |
| 5307 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5308 | // cmd_bind_graphics_pipeline() |
| 5309 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5310 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5311 | // First cause various verify_layout_compatibility() fails |
| 5312 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5313 | // verify_set_layout_compatibility fail cases: |
| 5314 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5315 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5316 | " due to: invalid VkPipelineLayout "); |
| 5317 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5318 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5319 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5320 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5321 | m_errorMonitor->VerifyFound(); |
| 5322 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5323 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5324 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5325 | " attempting to bind set to index 1"); |
| 5326 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5327 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5328 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5329 | m_errorMonitor->VerifyFound(); |
| 5330 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5331 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5332 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5333 | // descriptors |
| 5334 | m_errorMonitor->SetDesiredFailureMsg( |
| 5335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5336 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5337 | vkCmdBindDescriptorSets( |
| 5338 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5339 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5340 | m_errorMonitor->VerifyFound(); |
| 5341 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5342 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5343 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5344 | m_errorMonitor->SetDesiredFailureMsg( |
| 5345 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5346 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5347 | vkCmdBindDescriptorSets( |
| 5348 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5349 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5350 | m_errorMonitor->VerifyFound(); |
| 5351 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5352 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5353 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5354 | m_errorMonitor->SetDesiredFailureMsg( |
| 5355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5356 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | vkCmdBindDescriptorSets( |
| 5358 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5359 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5360 | m_errorMonitor->VerifyFound(); |
| 5361 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5362 | // Cause INFO messages due to disturbing previously bound Sets |
| 5363 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5364 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5365 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5366 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5367 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5368 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5369 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | " previously bound as set #0 was disturbed "); |
| 5371 | vkCmdBindDescriptorSets( |
| 5372 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5373 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5374 | m_errorMonitor->VerifyFound(); |
| 5375 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5376 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5377 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5378 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5379 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5380 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | " newly bound as set #0 so set #1 and " |
| 5382 | "any subsequent sets were disturbed "); |
| 5383 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5384 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5385 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5386 | m_errorMonitor->VerifyFound(); |
| 5387 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5388 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5389 | // 1. Error due to not binding required set (we actually use same code as |
| 5390 | // above to disturb set0) |
| 5391 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5392 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5393 | 2, &descriptorSet[0], 0, NULL); |
| 5394 | vkCmdBindDescriptorSets( |
| 5395 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5396 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5397 | m_errorMonitor->SetDesiredFailureMsg( |
| 5398 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5399 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5400 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5401 | m_errorMonitor->VerifyFound(); |
| 5402 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5403 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5404 | // 2. Error due to bound set not being compatible with PSO's |
| 5405 | // VkPipelineLayout (diff stageFlags in this case) |
| 5406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5408 | 2, &descriptorSet[0], 0, NULL); |
| 5409 | m_errorMonitor->SetDesiredFailureMsg( |
| 5410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5411 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5412 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5413 | m_errorMonitor->VerifyFound(); |
| 5414 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5415 | // Remaining clean-up |
| 5416 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5417 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5418 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5419 | } |
| 5420 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5421 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5422 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5423 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5424 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5425 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5426 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5429 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5430 | m_errorMonitor->SetDesiredFailureMsg( |
| 5431 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5432 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5433 | |
| 5434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5435 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5436 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5437 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5439 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5440 | } |
| 5441 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5442 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5443 | VkResult err; |
| 5444 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | m_errorMonitor->SetDesiredFailureMsg( |
| 5447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5448 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5449 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5451 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5452 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5453 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5454 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5455 | cmd.commandPool = m_commandPool; |
| 5456 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5457 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5458 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5459 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5460 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5461 | |
| 5462 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5463 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5464 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5465 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5466 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5467 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5468 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5469 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5470 | |
| 5471 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5472 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5473 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5474 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5475 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5476 | } |
| 5477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5479 | // Cause error due to Begin while recording CB |
| 5480 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5481 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5482 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5484 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5485 | |
| 5486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5487 | |
| 5488 | // Calls AllocateCommandBuffers |
| 5489 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5492 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5493 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5494 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5495 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5496 | cmd_buf_info.pNext = NULL; |
| 5497 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5498 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5499 | |
| 5500 | // Begin CB to transition to recording state |
| 5501 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5502 | // Can't re-begin. This should trigger error |
| 5503 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5504 | m_errorMonitor->VerifyFound(); |
| 5505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5506 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5507 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5508 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5509 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5510 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5511 | m_errorMonitor->VerifyFound(); |
| 5512 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5513 | m_errorMonitor->SetDesiredFailureMsg( |
| 5514 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5515 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5516 | // Transition CB to RECORDED state |
| 5517 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5518 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5519 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5520 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5521 | } |
| 5522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5523 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5524 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | m_errorMonitor->SetDesiredFailureMsg( |
| 5528 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5529 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5530 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5531 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5532 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5533 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5534 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5535 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5536 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5537 | |
| 5538 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5540 | ds_pool_ci.pNext = NULL; |
| 5541 | ds_pool_ci.maxSets = 1; |
| 5542 | ds_pool_ci.poolSizeCount = 1; |
| 5543 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5544 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5545 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5546 | err = |
| 5547 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5548 | ASSERT_VK_SUCCESS(err); |
| 5549 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5550 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5551 | dsl_binding.binding = 0; |
| 5552 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5553 | dsl_binding.descriptorCount = 1; |
| 5554 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5555 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5556 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5557 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5558 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5559 | ds_layout_ci.pNext = NULL; |
| 5560 | ds_layout_ci.bindingCount = 1; |
| 5561 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5562 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5563 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5565 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5566 | ASSERT_VK_SUCCESS(err); |
| 5567 | |
| 5568 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5569 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5570 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5571 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5572 | alloc_info.descriptorPool = ds_pool; |
| 5573 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5575 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5576 | ASSERT_VK_SUCCESS(err); |
| 5577 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5578 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5579 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5580 | pipeline_layout_ci.setLayoutCount = 1; |
| 5581 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5582 | |
| 5583 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5585 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5586 | ASSERT_VK_SUCCESS(err); |
| 5587 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5588 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5589 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5590 | |
| 5591 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5592 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5593 | vp_state_ci.scissorCount = 1; |
| 5594 | vp_state_ci.pScissors = ≻ |
| 5595 | vp_state_ci.viewportCount = 1; |
| 5596 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5597 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5598 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5599 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5600 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5601 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5602 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5603 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5604 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5605 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5606 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5607 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5608 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5609 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5610 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5611 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5612 | gp_ci.layout = pipeline_layout; |
| 5613 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5614 | |
| 5615 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5616 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5617 | pc_ci.initialDataSize = 0; |
| 5618 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5619 | |
| 5620 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5621 | VkPipelineCache pipelineCache; |
| 5622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | err = |
| 5624 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5625 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5626 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5627 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5628 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5629 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5630 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5631 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5632 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5633 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5634 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5635 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5636 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5637 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5638 | { |
| 5639 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5640 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5641 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5642 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5643 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5644 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5645 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5647 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5648 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5649 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5650 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5651 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5652 | |
| 5653 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5654 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5655 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5656 | ds_pool_ci.poolSizeCount = 1; |
| 5657 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5658 | |
| 5659 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5660 | err = vkCreateDescriptorPool(m_device->device(), |
| 5661 | 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] | 5662 | ASSERT_VK_SUCCESS(err); |
| 5663 | |
| 5664 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5665 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5666 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5667 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5668 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5669 | dsl_binding.pImmutableSamplers = NULL; |
| 5670 | |
| 5671 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5672 | ds_layout_ci.sType = |
| 5673 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5674 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5675 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5676 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5677 | |
| 5678 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5679 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5680 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5681 | ASSERT_VK_SUCCESS(err); |
| 5682 | |
| 5683 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5684 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5685 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5686 | ASSERT_VK_SUCCESS(err); |
| 5687 | |
| 5688 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5689 | pipeline_layout_ci.sType = |
| 5690 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5691 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5692 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5693 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5694 | |
| 5695 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5696 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5697 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5698 | ASSERT_VK_SUCCESS(err); |
| 5699 | |
| 5700 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5701 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5703 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5704 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5705 | // 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] | 5706 | VkShaderObj |
| 5707 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5708 | this); |
| 5709 | VkShaderObj |
| 5710 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5711 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5713 | shaderStages[0].sType = |
| 5714 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5715 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5716 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | shaderStages[1].sType = |
| 5718 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5719 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5720 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5721 | shaderStages[2].sType = |
| 5722 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5723 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5724 | shaderStages[2].shader = te.handle(); |
| 5725 | |
| 5726 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5727 | iaCI.sType = |
| 5728 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5729 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5730 | |
| 5731 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5732 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5733 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5734 | |
| 5735 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5736 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5737 | gp_ci.pNext = NULL; |
| 5738 | gp_ci.stageCount = 3; |
| 5739 | gp_ci.pStages = shaderStages; |
| 5740 | gp_ci.pVertexInputState = NULL; |
| 5741 | gp_ci.pInputAssemblyState = &iaCI; |
| 5742 | gp_ci.pTessellationState = &tsCI; |
| 5743 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5744 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5745 | gp_ci.pMultisampleState = NULL; |
| 5746 | gp_ci.pDepthStencilState = NULL; |
| 5747 | gp_ci.pColorBlendState = NULL; |
| 5748 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5749 | gp_ci.layout = pipeline_layout; |
| 5750 | gp_ci.renderPass = renderPass(); |
| 5751 | |
| 5752 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5753 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5754 | pc_ci.pNext = NULL; |
| 5755 | pc_ci.initialSize = 0; |
| 5756 | pc_ci.initialData = 0; |
| 5757 | pc_ci.maxSize = 0; |
| 5758 | |
| 5759 | VkPipeline pipeline; |
| 5760 | VkPipelineCache pipelineCache; |
| 5761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5762 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5763 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5764 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5765 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5766 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5767 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5768 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5769 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5770 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5771 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5772 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5773 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5774 | } |
| 5775 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5776 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5777 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5780 | m_errorMonitor->SetDesiredFailureMsg( |
| 5781 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5782 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5783 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5784 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5785 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5786 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5787 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5788 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5789 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5790 | |
| 5791 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5793 | ds_pool_ci.maxSets = 1; |
| 5794 | ds_pool_ci.poolSizeCount = 1; |
| 5795 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5796 | |
| 5797 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5798 | err = |
| 5799 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5800 | ASSERT_VK_SUCCESS(err); |
| 5801 | |
| 5802 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5803 | dsl_binding.binding = 0; |
| 5804 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5805 | dsl_binding.descriptorCount = 1; |
| 5806 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5807 | |
| 5808 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5809 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5810 | ds_layout_ci.bindingCount = 1; |
| 5811 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5812 | |
| 5813 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5814 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5815 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5816 | ASSERT_VK_SUCCESS(err); |
| 5817 | |
| 5818 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5819 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5820 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5821 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5822 | alloc_info.descriptorPool = ds_pool; |
| 5823 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5824 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5825 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5826 | ASSERT_VK_SUCCESS(err); |
| 5827 | |
| 5828 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5829 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5830 | pipeline_layout_ci.setLayoutCount = 1; |
| 5831 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5832 | |
| 5833 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5834 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5835 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5836 | ASSERT_VK_SUCCESS(err); |
| 5837 | |
| 5838 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5839 | |
| 5840 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5841 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5842 | vp_state_ci.scissorCount = 0; |
| 5843 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5844 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5845 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5846 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5847 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5848 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5849 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5850 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5851 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5852 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5853 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5854 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5855 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5856 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5858 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5859 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5860 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5861 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5862 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5863 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5864 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5865 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5866 | |
| 5867 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5868 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5869 | gp_ci.stageCount = 2; |
| 5870 | gp_ci.pStages = shaderStages; |
| 5871 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5872 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5873 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5874 | gp_ci.layout = pipeline_layout; |
| 5875 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5876 | |
| 5877 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5878 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5879 | |
| 5880 | VkPipeline pipeline; |
| 5881 | VkPipelineCache pipelineCache; |
| 5882 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5883 | err = |
| 5884 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5885 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5886 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5887 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5888 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5889 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5890 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5891 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5892 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5895 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5896 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5897 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5898 | // 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] | 5899 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5900 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5902 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5903 | m_errorMonitor->SetDesiredFailureMsg( |
| 5904 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5905 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5906 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5907 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5908 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5909 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5910 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5911 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5912 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5913 | |
| 5914 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5915 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5916 | ds_pool_ci.maxSets = 1; |
| 5917 | ds_pool_ci.poolSizeCount = 1; |
| 5918 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5919 | |
| 5920 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5921 | err = |
| 5922 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5923 | ASSERT_VK_SUCCESS(err); |
| 5924 | |
| 5925 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5926 | dsl_binding.binding = 0; |
| 5927 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5928 | dsl_binding.descriptorCount = 1; |
| 5929 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5930 | |
| 5931 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5932 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5933 | ds_layout_ci.bindingCount = 1; |
| 5934 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5935 | |
| 5936 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5938 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5939 | ASSERT_VK_SUCCESS(err); |
| 5940 | |
| 5941 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5942 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5943 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5944 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5945 | alloc_info.descriptorPool = ds_pool; |
| 5946 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5947 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5948 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
| 5950 | |
| 5951 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5952 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5953 | pipeline_layout_ci.setLayoutCount = 1; |
| 5954 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5955 | |
| 5956 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5958 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5959 | ASSERT_VK_SUCCESS(err); |
| 5960 | |
| 5961 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5962 | // Set scissor as dynamic to avoid second error |
| 5963 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5964 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5965 | dyn_state_ci.dynamicStateCount = 1; |
| 5966 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5967 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5968 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5969 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5972 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5973 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5974 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5975 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5977 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5978 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5979 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5980 | |
| 5981 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5982 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5983 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5984 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5985 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5986 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5987 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5988 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5989 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5990 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5991 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5992 | gp_ci.stageCount = 2; |
| 5993 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5994 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5995 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5996 | // should cause validation error |
| 5997 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5998 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5999 | gp_ci.layout = pipeline_layout; |
| 6000 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6001 | |
| 6002 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6004 | |
| 6005 | VkPipeline pipeline; |
| 6006 | VkPipelineCache pipelineCache; |
| 6007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6008 | err = |
| 6009 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6010 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6012 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6013 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6014 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6015 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6016 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6017 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6018 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6019 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6020 | } |
| 6021 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6022 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6023 | // count |
| 6024 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6025 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | m_errorMonitor->SetDesiredFailureMsg( |
| 6028 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6029 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6030 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6032 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6033 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6034 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6036 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6037 | |
| 6038 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6040 | ds_pool_ci.maxSets = 1; |
| 6041 | ds_pool_ci.poolSizeCount = 1; |
| 6042 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6043 | |
| 6044 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6045 | err = |
| 6046 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6047 | ASSERT_VK_SUCCESS(err); |
| 6048 | |
| 6049 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6050 | dsl_binding.binding = 0; |
| 6051 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6052 | dsl_binding.descriptorCount = 1; |
| 6053 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6054 | |
| 6055 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6056 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6057 | ds_layout_ci.bindingCount = 1; |
| 6058 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6059 | |
| 6060 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6062 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6063 | ASSERT_VK_SUCCESS(err); |
| 6064 | |
| 6065 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6066 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6067 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6068 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6069 | alloc_info.descriptorPool = ds_pool; |
| 6070 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6071 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6072 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6073 | ASSERT_VK_SUCCESS(err); |
| 6074 | |
| 6075 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6076 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6077 | pipeline_layout_ci.setLayoutCount = 1; |
| 6078 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6079 | |
| 6080 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6081 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6082 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6083 | ASSERT_VK_SUCCESS(err); |
| 6084 | |
| 6085 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6086 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6087 | vp_state_ci.viewportCount = 1; |
| 6088 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6089 | vp_state_ci.scissorCount = 1; |
| 6090 | vp_state_ci.pScissors = |
| 6091 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6092 | |
| 6093 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6094 | // Set scissor as dynamic to avoid that error |
| 6095 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6096 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6097 | dyn_state_ci.dynamicStateCount = 1; |
| 6098 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6099 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6100 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6103 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6104 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6105 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6106 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6107 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6108 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6109 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6110 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6111 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6112 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6113 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6114 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6115 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6116 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6117 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6118 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6119 | |
| 6120 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6121 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6122 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6123 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6124 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6125 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6126 | rs_ci.pNext = nullptr; |
| 6127 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6128 | VkPipelineColorBlendAttachmentState att = {}; |
| 6129 | att.blendEnable = VK_FALSE; |
| 6130 | att.colorWriteMask = 0xf; |
| 6131 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6132 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6133 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6134 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6135 | cb_ci.attachmentCount = 1; |
| 6136 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6137 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6138 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6139 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6140 | gp_ci.stageCount = 2; |
| 6141 | gp_ci.pStages = shaderStages; |
| 6142 | gp_ci.pVertexInputState = &vi_ci; |
| 6143 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6144 | gp_ci.pViewportState = &vp_state_ci; |
| 6145 | gp_ci.pRasterizationState = &rs_ci; |
| 6146 | gp_ci.pColorBlendState = &cb_ci; |
| 6147 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6148 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6149 | gp_ci.layout = pipeline_layout; |
| 6150 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6151 | |
| 6152 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6153 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6154 | |
| 6155 | VkPipeline pipeline; |
| 6156 | VkPipelineCache pipelineCache; |
| 6157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6158 | err = |
| 6159 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6160 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6161 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6162 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6163 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6164 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6165 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6166 | // 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] | 6167 | // First need to successfully create the PSO from above by setting |
| 6168 | // pViewports |
| 6169 | m_errorMonitor->SetDesiredFailureMsg( |
| 6170 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6171 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6172 | "scissorCount is 1. These counts must match."); |
| 6173 | |
| 6174 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6175 | vp_state_ci.pViewports = &vp; |
| 6176 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6177 | &gp_ci, NULL, &pipeline); |
| 6178 | ASSERT_VK_SUCCESS(err); |
| 6179 | BeginCommandBuffer(); |
| 6180 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6181 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6182 | VkRect2D scissors[2] = {}; // don't care about data |
| 6183 | // Count of 2 doesn't match PSO count of 1 |
| 6184 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6185 | Draw(1, 0, 0, 0); |
| 6186 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6187 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6188 | |
| 6189 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6190 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6191 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6192 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6193 | } |
| 6194 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6195 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6196 | // viewportCount |
| 6197 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6198 | VkResult err; |
| 6199 | |
| 6200 | m_errorMonitor->SetDesiredFailureMsg( |
| 6201 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6202 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6203 | |
| 6204 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6205 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6206 | |
| 6207 | VkDescriptorPoolSize ds_type_count = {}; |
| 6208 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6209 | ds_type_count.descriptorCount = 1; |
| 6210 | |
| 6211 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6212 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6213 | ds_pool_ci.maxSets = 1; |
| 6214 | ds_pool_ci.poolSizeCount = 1; |
| 6215 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6216 | |
| 6217 | VkDescriptorPool ds_pool; |
| 6218 | err = |
| 6219 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6220 | ASSERT_VK_SUCCESS(err); |
| 6221 | |
| 6222 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6223 | dsl_binding.binding = 0; |
| 6224 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6225 | dsl_binding.descriptorCount = 1; |
| 6226 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6227 | |
| 6228 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6229 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6230 | ds_layout_ci.bindingCount = 1; |
| 6231 | ds_layout_ci.pBindings = &dsl_binding; |
| 6232 | |
| 6233 | VkDescriptorSetLayout ds_layout; |
| 6234 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6235 | &ds_layout); |
| 6236 | ASSERT_VK_SUCCESS(err); |
| 6237 | |
| 6238 | VkDescriptorSet descriptorSet; |
| 6239 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6240 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6241 | alloc_info.descriptorSetCount = 1; |
| 6242 | alloc_info.descriptorPool = ds_pool; |
| 6243 | alloc_info.pSetLayouts = &ds_layout; |
| 6244 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6245 | &descriptorSet); |
| 6246 | ASSERT_VK_SUCCESS(err); |
| 6247 | |
| 6248 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6249 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6250 | pipeline_layout_ci.setLayoutCount = 1; |
| 6251 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6252 | |
| 6253 | VkPipelineLayout pipeline_layout; |
| 6254 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6255 | &pipeline_layout); |
| 6256 | ASSERT_VK_SUCCESS(err); |
| 6257 | |
| 6258 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6259 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6260 | vp_state_ci.scissorCount = 1; |
| 6261 | vp_state_ci.pScissors = |
| 6262 | NULL; // Null scissor w/ count of 1 should cause error |
| 6263 | vp_state_ci.viewportCount = 1; |
| 6264 | vp_state_ci.pViewports = |
| 6265 | NULL; // vp is dynamic (below) so this won't cause error |
| 6266 | |
| 6267 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6268 | // Set scissor as dynamic to avoid that error |
| 6269 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6270 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6271 | dyn_state_ci.dynamicStateCount = 1; |
| 6272 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6273 | |
| 6274 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6275 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6276 | |
| 6277 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6278 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6279 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6280 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6281 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6282 | // but add it to be able to run on more devices |
| 6283 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6284 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6285 | |
| 6286 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6287 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6288 | vi_ci.pNext = nullptr; |
| 6289 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6290 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6291 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6292 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6293 | |
| 6294 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6295 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6296 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6297 | |
| 6298 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6299 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6300 | rs_ci.pNext = nullptr; |
| 6301 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6302 | VkPipelineColorBlendAttachmentState att = {}; |
| 6303 | att.blendEnable = VK_FALSE; |
| 6304 | att.colorWriteMask = 0xf; |
| 6305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6306 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6307 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6308 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6309 | cb_ci.attachmentCount = 1; |
| 6310 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6311 | |
| 6312 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6313 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6314 | gp_ci.stageCount = 2; |
| 6315 | gp_ci.pStages = shaderStages; |
| 6316 | gp_ci.pVertexInputState = &vi_ci; |
| 6317 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6318 | gp_ci.pViewportState = &vp_state_ci; |
| 6319 | gp_ci.pRasterizationState = &rs_ci; |
| 6320 | gp_ci.pColorBlendState = &cb_ci; |
| 6321 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6322 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6323 | gp_ci.layout = pipeline_layout; |
| 6324 | gp_ci.renderPass = renderPass(); |
| 6325 | |
| 6326 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6327 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6328 | |
| 6329 | VkPipeline pipeline; |
| 6330 | VkPipelineCache pipelineCache; |
| 6331 | |
| 6332 | err = |
| 6333 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6334 | ASSERT_VK_SUCCESS(err); |
| 6335 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6336 | &gp_ci, NULL, &pipeline); |
| 6337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6338 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6339 | |
| 6340 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6341 | // First need to successfully create the PSO from above by setting |
| 6342 | // pViewports |
| 6343 | m_errorMonitor->SetDesiredFailureMsg( |
| 6344 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6345 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6346 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6347 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6348 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6349 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6350 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6351 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6352 | ASSERT_VK_SUCCESS(err); |
| 6353 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6355 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6356 | VkViewport viewports[2] = {}; // don't care about data |
| 6357 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6358 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6359 | Draw(1, 0, 0, 0); |
| 6360 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6361 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6362 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6363 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6364 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6365 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6366 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6367 | } |
| 6368 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6369 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6370 | VkResult err; |
| 6371 | |
| 6372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6373 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6374 | |
| 6375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6376 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6377 | |
| 6378 | VkDescriptorPoolSize ds_type_count = {}; |
| 6379 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6380 | ds_type_count.descriptorCount = 1; |
| 6381 | |
| 6382 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6383 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6384 | ds_pool_ci.maxSets = 1; |
| 6385 | ds_pool_ci.poolSizeCount = 1; |
| 6386 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6387 | |
| 6388 | VkDescriptorPool ds_pool; |
| 6389 | err = |
| 6390 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6391 | ASSERT_VK_SUCCESS(err); |
| 6392 | |
| 6393 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6394 | dsl_binding.binding = 0; |
| 6395 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6396 | dsl_binding.descriptorCount = 1; |
| 6397 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6398 | |
| 6399 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6400 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6401 | ds_layout_ci.bindingCount = 1; |
| 6402 | ds_layout_ci.pBindings = &dsl_binding; |
| 6403 | |
| 6404 | VkDescriptorSetLayout ds_layout; |
| 6405 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6406 | &ds_layout); |
| 6407 | ASSERT_VK_SUCCESS(err); |
| 6408 | |
| 6409 | VkDescriptorSet descriptorSet; |
| 6410 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6411 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6412 | alloc_info.descriptorSetCount = 1; |
| 6413 | alloc_info.descriptorPool = ds_pool; |
| 6414 | alloc_info.pSetLayouts = &ds_layout; |
| 6415 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6416 | &descriptorSet); |
| 6417 | ASSERT_VK_SUCCESS(err); |
| 6418 | |
| 6419 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6420 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6421 | pipeline_layout_ci.setLayoutCount = 1; |
| 6422 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6423 | |
| 6424 | VkPipelineLayout pipeline_layout; |
| 6425 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6426 | &pipeline_layout); |
| 6427 | ASSERT_VK_SUCCESS(err); |
| 6428 | |
| 6429 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6430 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6431 | vp_state_ci.scissorCount = 1; |
| 6432 | vp_state_ci.pScissors = NULL; |
| 6433 | vp_state_ci.viewportCount = 1; |
| 6434 | vp_state_ci.pViewports = NULL; |
| 6435 | |
| 6436 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6437 | VK_DYNAMIC_STATE_SCISSOR, |
| 6438 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6439 | // Set scissor as dynamic to avoid that error |
| 6440 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6441 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6442 | dyn_state_ci.dynamicStateCount = 2; |
| 6443 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6444 | |
| 6445 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6446 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6447 | |
| 6448 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6449 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6450 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6451 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6452 | this); // TODO - We shouldn't need a fragment shader |
| 6453 | // but add it to be able to run on more devices |
| 6454 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6455 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6456 | |
| 6457 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6458 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6459 | vi_ci.pNext = nullptr; |
| 6460 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6461 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6462 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6463 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6464 | |
| 6465 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6466 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6467 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6468 | |
| 6469 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6470 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6471 | rs_ci.pNext = nullptr; |
| 6472 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6473 | // Check too low (line width of -1.0f). |
| 6474 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6475 | |
| 6476 | VkPipelineColorBlendAttachmentState att = {}; |
| 6477 | att.blendEnable = VK_FALSE; |
| 6478 | att.colorWriteMask = 0xf; |
| 6479 | |
| 6480 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6481 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6482 | cb_ci.pNext = nullptr; |
| 6483 | cb_ci.attachmentCount = 1; |
| 6484 | cb_ci.pAttachments = &att; |
| 6485 | |
| 6486 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6487 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6488 | gp_ci.stageCount = 2; |
| 6489 | gp_ci.pStages = shaderStages; |
| 6490 | gp_ci.pVertexInputState = &vi_ci; |
| 6491 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6492 | gp_ci.pViewportState = &vp_state_ci; |
| 6493 | gp_ci.pRasterizationState = &rs_ci; |
| 6494 | gp_ci.pColorBlendState = &cb_ci; |
| 6495 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6496 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6497 | gp_ci.layout = pipeline_layout; |
| 6498 | gp_ci.renderPass = renderPass(); |
| 6499 | |
| 6500 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6501 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6502 | |
| 6503 | VkPipeline pipeline; |
| 6504 | VkPipelineCache pipelineCache; |
| 6505 | |
| 6506 | err = |
| 6507 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6508 | ASSERT_VK_SUCCESS(err); |
| 6509 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6510 | &gp_ci, NULL, &pipeline); |
| 6511 | |
| 6512 | m_errorMonitor->VerifyFound(); |
| 6513 | |
| 6514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6515 | "Attempt to set lineWidth to 65536"); |
| 6516 | |
| 6517 | // Check too high (line width of 65536.0f). |
| 6518 | rs_ci.lineWidth = 65536.0f; |
| 6519 | |
| 6520 | err = |
| 6521 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6522 | ASSERT_VK_SUCCESS(err); |
| 6523 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6524 | &gp_ci, NULL, &pipeline); |
| 6525 | |
| 6526 | m_errorMonitor->VerifyFound(); |
| 6527 | |
| 6528 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6529 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6530 | |
| 6531 | dyn_state_ci.dynamicStateCount = 3; |
| 6532 | |
| 6533 | rs_ci.lineWidth = 1.0f; |
| 6534 | |
| 6535 | err = |
| 6536 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6537 | ASSERT_VK_SUCCESS(err); |
| 6538 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6539 | &gp_ci, NULL, &pipeline); |
| 6540 | BeginCommandBuffer(); |
| 6541 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6542 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6543 | |
| 6544 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6545 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6546 | m_errorMonitor->VerifyFound(); |
| 6547 | |
| 6548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6549 | "Attempt to set lineWidth to 65536"); |
| 6550 | |
| 6551 | // Check too high with dynamic setting. |
| 6552 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6553 | m_errorMonitor->VerifyFound(); |
| 6554 | EndCommandBuffer(); |
| 6555 | |
| 6556 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6557 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6558 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6559 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6560 | } |
| 6561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6562 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6563 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6564 | m_errorMonitor->SetDesiredFailureMsg( |
| 6565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6566 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6567 | |
| 6568 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6569 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6570 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6571 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6572 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6573 | // that |
| 6574 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6575 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6576 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6577 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6578 | } |
| 6579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6580 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6581 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6582 | m_errorMonitor->SetDesiredFailureMsg( |
| 6583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6584 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6585 | |
| 6586 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6587 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6588 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6589 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6590 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6591 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6592 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6594 | rp_begin.pNext = NULL; |
| 6595 | rp_begin.renderPass = renderPass(); |
| 6596 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6597 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6598 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6599 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6600 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6601 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6602 | } |
| 6603 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6604 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 6605 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 6606 | "the number of renderPass attachments that use loadOp" |
| 6607 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 6608 | |
| 6609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6610 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6611 | |
| 6612 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 6613 | VkAttachmentReference attach = {}; |
| 6614 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6615 | VkSubpassDescription subpass = {}; |
| 6616 | subpass.inputAttachmentCount = 1; |
| 6617 | subpass.pInputAttachments = &attach; |
| 6618 | VkRenderPassCreateInfo rpci = {}; |
| 6619 | rpci.subpassCount = 1; |
| 6620 | rpci.pSubpasses = &subpass; |
| 6621 | rpci.attachmentCount = 1; |
| 6622 | VkAttachmentDescription attach_desc = {}; |
| 6623 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6624 | // Set loadOp to CLEAR |
| 6625 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6626 | rpci.pAttachments = &attach_desc; |
| 6627 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 6628 | VkRenderPass rp; |
| 6629 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6630 | |
| 6631 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 6632 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 6633 | hinfo.renderPass = VK_NULL_HANDLE; |
| 6634 | hinfo.subpass = 0; |
| 6635 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 6636 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 6637 | hinfo.queryFlags = 0; |
| 6638 | hinfo.pipelineStatistics = 0; |
| 6639 | VkCommandBufferBeginInfo info = {}; |
| 6640 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 6641 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6642 | info.pInheritanceInfo = &hinfo; |
| 6643 | |
| 6644 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 6645 | VkRenderPassBeginInfo rp_begin = {}; |
| 6646 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6647 | rp_begin.pNext = NULL; |
| 6648 | rp_begin.renderPass = renderPass(); |
| 6649 | rp_begin.framebuffer = framebuffer(); |
| 6650 | rp_begin.clearValueCount = 0; // Should be 1 |
| 6651 | |
| 6652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6653 | " has a clearValueCount of 0 but the " |
| 6654 | "actual number of attachments in " |
| 6655 | "renderPass "); |
| 6656 | |
| 6657 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6658 | VK_SUBPASS_CONTENTS_INLINE); |
| 6659 | |
| 6660 | m_errorMonitor->VerifyFound(); |
| 6661 | } |
| 6662 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6663 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6664 | |
| 6665 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6666 | |
| 6667 | m_errorMonitor->SetDesiredFailureMsg( |
| 6668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6669 | "It is invalid to issue this call inside an active render pass"); |
| 6670 | |
| 6671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6672 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6673 | |
| 6674 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6675 | BeginCommandBuffer(); |
| 6676 | |
| 6677 | // Call directly into vkEndCommandBuffer instead of the |
| 6678 | // the framework's EndCommandBuffer, which inserts a |
| 6679 | // vkEndRenderPass |
| 6680 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6681 | |
| 6682 | m_errorMonitor->VerifyFound(); |
| 6683 | |
| 6684 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6685 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6686 | } |
| 6687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6688 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6689 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | m_errorMonitor->SetDesiredFailureMsg( |
| 6691 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6692 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6693 | |
| 6694 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6695 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6696 | |
| 6697 | // Renderpass is started here |
| 6698 | BeginCommandBuffer(); |
| 6699 | |
| 6700 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6701 | vk_testing::Buffer dstBuffer; |
| 6702 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6703 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6704 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6705 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6706 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6707 | } |
| 6708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6710 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6711 | m_errorMonitor->SetDesiredFailureMsg( |
| 6712 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6713 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6714 | |
| 6715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6716 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6717 | |
| 6718 | // Renderpass is started here |
| 6719 | BeginCommandBuffer(); |
| 6720 | |
| 6721 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6722 | vk_testing::Buffer dstBuffer; |
| 6723 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6724 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | VkDeviceSize dstOffset = 0; |
| 6726 | VkDeviceSize dataSize = 1024; |
| 6727 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6729 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6730 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6731 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6732 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6733 | } |
| 6734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6735 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6736 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6737 | m_errorMonitor->SetDesiredFailureMsg( |
| 6738 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6739 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6740 | |
| 6741 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6742 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6743 | |
| 6744 | // Renderpass is started here |
| 6745 | BeginCommandBuffer(); |
| 6746 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6747 | VkClearColorValue clear_color; |
| 6748 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6749 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6750 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6751 | const int32_t tex_width = 32; |
| 6752 | const int32_t tex_height = 32; |
| 6753 | VkImageCreateInfo image_create_info = {}; |
| 6754 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6755 | image_create_info.pNext = NULL; |
| 6756 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6757 | image_create_info.format = tex_format; |
| 6758 | image_create_info.extent.width = tex_width; |
| 6759 | image_create_info.extent.height = tex_height; |
| 6760 | image_create_info.extent.depth = 1; |
| 6761 | image_create_info.mipLevels = 1; |
| 6762 | image_create_info.arrayLayers = 1; |
| 6763 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6764 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6765 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6766 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6767 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6768 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6769 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6771 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6772 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6774 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6775 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6776 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6777 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6778 | } |
| 6779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6780 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6781 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6782 | m_errorMonitor->SetDesiredFailureMsg( |
| 6783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6784 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6785 | |
| 6786 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6787 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6788 | |
| 6789 | // Renderpass is started here |
| 6790 | BeginCommandBuffer(); |
| 6791 | |
| 6792 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6793 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6794 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6795 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6796 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6797 | image_create_info.extent.width = 64; |
| 6798 | image_create_info.extent.height = 64; |
| 6799 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6800 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6801 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6802 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6803 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6804 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6805 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6806 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6807 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6809 | vkCmdClearDepthStencilImage( |
| 6810 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6811 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6812 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6813 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6814 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6815 | } |
| 6816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6817 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6818 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6819 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6820 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6821 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6822 | "vkCmdClearAttachments: This call " |
| 6823 | "must be issued inside an active " |
| 6824 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6825 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6826 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6827 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6828 | |
| 6829 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6830 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6831 | ASSERT_VK_SUCCESS(err); |
| 6832 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6833 | VkClearAttachment color_attachment; |
| 6834 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6835 | color_attachment.clearValue.color.float32[0] = 0; |
| 6836 | color_attachment.clearValue.color.float32[1] = 0; |
| 6837 | color_attachment.clearValue.color.float32[2] = 0; |
| 6838 | color_attachment.clearValue.color.float32[3] = 0; |
| 6839 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6840 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6841 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6842 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6843 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6844 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6845 | } |
| 6846 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6847 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6848 | // Try to add a buffer memory barrier with no buffer. |
| 6849 | m_errorMonitor->SetDesiredFailureMsg( |
| 6850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6851 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6852 | |
| 6853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6854 | BeginCommandBuffer(); |
| 6855 | |
| 6856 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6857 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6858 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6859 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6860 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6861 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6862 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6863 | buf_barrier.offset = 0; |
| 6864 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6865 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6866 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6867 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6868 | |
| 6869 | m_errorMonitor->VerifyFound(); |
| 6870 | } |
| 6871 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6872 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6873 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6874 | |
| 6875 | m_errorMonitor->SetDesiredFailureMsg( |
| 6876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6877 | |
| 6878 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6879 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6880 | |
| 6881 | VkMemoryBarrier mem_barrier = {}; |
| 6882 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6883 | mem_barrier.pNext = NULL; |
| 6884 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6885 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6886 | BeginCommandBuffer(); |
| 6887 | // BeginCommandBuffer() starts a render pass |
| 6888 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6889 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6890 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6891 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6892 | m_errorMonitor->VerifyFound(); |
| 6893 | |
| 6894 | m_errorMonitor->SetDesiredFailureMsg( |
| 6895 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6896 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6897 | VkImageObj image(m_device); |
| 6898 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6899 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6900 | ASSERT_TRUE(image.initialized()); |
| 6901 | VkImageMemoryBarrier img_barrier = {}; |
| 6902 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6903 | img_barrier.pNext = NULL; |
| 6904 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6905 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6906 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6907 | // New layout can't be UNDEFINED |
| 6908 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6909 | img_barrier.image = image.handle(); |
| 6910 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6911 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6912 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6913 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6914 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6915 | img_barrier.subresourceRange.layerCount = 1; |
| 6916 | img_barrier.subresourceRange.levelCount = 1; |
| 6917 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6918 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6919 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6920 | nullptr, 1, &img_barrier); |
| 6921 | m_errorMonitor->VerifyFound(); |
| 6922 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6923 | |
| 6924 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6925 | "Subresource must have the sum of the " |
| 6926 | "baseArrayLayer"); |
| 6927 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6928 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6929 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6930 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6931 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6932 | nullptr, 1, &img_barrier); |
| 6933 | m_errorMonitor->VerifyFound(); |
| 6934 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6935 | |
| 6936 | m_errorMonitor->SetDesiredFailureMsg( |
| 6937 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6938 | "Subresource must have the sum of the baseMipLevel"); |
| 6939 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6940 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6941 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6942 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6943 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6944 | nullptr, 1, &img_barrier); |
| 6945 | m_errorMonitor->VerifyFound(); |
| 6946 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6947 | |
| 6948 | m_errorMonitor->SetDesiredFailureMsg( |
| 6949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6950 | "Buffer Barriers cannot be used during a render pass"); |
| 6951 | vk_testing::Buffer buffer; |
| 6952 | buffer.init(*m_device, 256); |
| 6953 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6954 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6955 | buf_barrier.pNext = NULL; |
| 6956 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6957 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6958 | buf_barrier.buffer = buffer.handle(); |
| 6959 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6960 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6961 | buf_barrier.offset = 0; |
| 6962 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6963 | // Can't send buffer barrier during a render pass |
| 6964 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6965 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6966 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6967 | &buf_barrier, 0, nullptr); |
| 6968 | m_errorMonitor->VerifyFound(); |
| 6969 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6970 | |
| 6971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6972 | "which is not less than total size"); |
| 6973 | buf_barrier.offset = 257; |
| 6974 | // Offset greater than total size |
| 6975 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6976 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6977 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6978 | &buf_barrier, 0, nullptr); |
| 6979 | m_errorMonitor->VerifyFound(); |
| 6980 | buf_barrier.offset = 0; |
| 6981 | |
| 6982 | m_errorMonitor->SetDesiredFailureMsg( |
| 6983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6984 | buf_barrier.size = 257; |
| 6985 | // Size greater than total size |
| 6986 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6987 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6988 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6989 | &buf_barrier, 0, nullptr); |
| 6990 | m_errorMonitor->VerifyFound(); |
| 6991 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6992 | |
| 6993 | m_errorMonitor->SetDesiredFailureMsg( |
| 6994 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6995 | "Image is a depth and stencil format and thus must " |
| 6996 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6997 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6998 | VkDepthStencilObj ds_image(m_device); |
| 6999 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7000 | ASSERT_TRUE(ds_image.initialized()); |
| 7001 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7002 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7003 | img_barrier.image = ds_image.handle(); |
| 7004 | // Leave aspectMask at COLOR on purpose |
| 7005 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7006 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7007 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7008 | nullptr, 1, &img_barrier); |
| 7009 | m_errorMonitor->VerifyFound(); |
| 7010 | } |
| 7011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7012 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7013 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7014 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7016 | m_errorMonitor->SetDesiredFailureMsg( |
| 7017 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7018 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7019 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7020 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7021 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7022 | uint32_t qfi = 0; |
| 7023 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7024 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7025 | buffCI.size = 1024; |
| 7026 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7027 | buffCI.queueFamilyIndexCount = 1; |
| 7028 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7029 | |
| 7030 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7031 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7032 | ASSERT_VK_SUCCESS(err); |
| 7033 | |
| 7034 | BeginCommandBuffer(); |
| 7035 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7036 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7037 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7038 | // 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] | 7039 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7040 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7041 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7042 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7043 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7044 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7045 | } |
| 7046 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7047 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7048 | // Create an out-of-range queueFamilyIndex |
| 7049 | m_errorMonitor->SetDesiredFailureMsg( |
| 7050 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7051 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7052 | "of the indices specified when the device was created, via the " |
| 7053 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7054 | |
| 7055 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7056 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7057 | VkBufferCreateInfo buffCI = {}; |
| 7058 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7059 | buffCI.size = 1024; |
| 7060 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7061 | buffCI.queueFamilyIndexCount = 1; |
| 7062 | // Introduce failure by specifying invalid queue_family_index |
| 7063 | uint32_t qfi = 777; |
| 7064 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7065 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7066 | |
| 7067 | VkBuffer ib; |
| 7068 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7069 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7070 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7071 | } |
| 7072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7073 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7074 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7075 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7077 | m_errorMonitor->SetDesiredFailureMsg( |
| 7078 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7079 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7080 | |
| 7081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7083 | |
| 7084 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7085 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7086 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7087 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7088 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7089 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7090 | } |
| 7091 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7092 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7093 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7094 | "that do not have correct usage bits sets."); |
| 7095 | VkResult err; |
| 7096 | |
| 7097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7098 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7099 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7100 | ds_type_count[i].type = VkDescriptorType(i); |
| 7101 | ds_type_count[i].descriptorCount = 1; |
| 7102 | } |
| 7103 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7104 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7105 | ds_pool_ci.pNext = NULL; |
| 7106 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7107 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7108 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7109 | |
| 7110 | VkDescriptorPool ds_pool; |
| 7111 | err = |
| 7112 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7113 | ASSERT_VK_SUCCESS(err); |
| 7114 | |
| 7115 | // Create 10 layouts where each has a single descriptor of different type |
| 7116 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7117 | {}; |
| 7118 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7119 | dsl_binding[i].binding = 0; |
| 7120 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7121 | dsl_binding[i].descriptorCount = 1; |
| 7122 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7123 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7124 | } |
| 7125 | |
| 7126 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7127 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7128 | ds_layout_ci.pNext = NULL; |
| 7129 | ds_layout_ci.bindingCount = 1; |
| 7130 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7131 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7132 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7133 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7134 | NULL, ds_layouts + i); |
| 7135 | ASSERT_VK_SUCCESS(err); |
| 7136 | } |
| 7137 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7138 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7139 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7140 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7141 | alloc_info.descriptorPool = ds_pool; |
| 7142 | alloc_info.pSetLayouts = ds_layouts; |
| 7143 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7144 | descriptor_sets); |
| 7145 | ASSERT_VK_SUCCESS(err); |
| 7146 | |
| 7147 | // Create a buffer & bufferView to be used for invalid updates |
| 7148 | VkBufferCreateInfo buff_ci = {}; |
| 7149 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7150 | // This usage is not valid for any descriptor type |
| 7151 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7152 | buff_ci.size = 256; |
| 7153 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7154 | VkBuffer buffer; |
| 7155 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7156 | ASSERT_VK_SUCCESS(err); |
| 7157 | |
| 7158 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7159 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7160 | buff_view_ci.buffer = buffer; |
| 7161 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7162 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7163 | VkBufferView buff_view; |
| 7164 | err = |
| 7165 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7166 | ASSERT_VK_SUCCESS(err); |
| 7167 | |
| 7168 | // Create an image to be used for invalid updates |
| 7169 | VkImageCreateInfo image_ci = {}; |
| 7170 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7171 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7172 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7173 | image_ci.extent.width = 64; |
| 7174 | image_ci.extent.height = 64; |
| 7175 | image_ci.extent.depth = 1; |
| 7176 | image_ci.mipLevels = 1; |
| 7177 | image_ci.arrayLayers = 1; |
| 7178 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7179 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7180 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7181 | // This usage is not valid for any descriptor type |
| 7182 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7183 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7184 | VkImage image; |
| 7185 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7186 | ASSERT_VK_SUCCESS(err); |
| 7187 | // Bind memory to image |
| 7188 | VkMemoryRequirements mem_reqs; |
| 7189 | VkDeviceMemory image_mem; |
| 7190 | bool pass; |
| 7191 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7192 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7193 | mem_alloc.pNext = NULL; |
| 7194 | mem_alloc.allocationSize = 0; |
| 7195 | mem_alloc.memoryTypeIndex = 0; |
| 7196 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7197 | mem_alloc.allocationSize = mem_reqs.size; |
| 7198 | pass = |
| 7199 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7200 | ASSERT_TRUE(pass); |
| 7201 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7202 | ASSERT_VK_SUCCESS(err); |
| 7203 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7204 | ASSERT_VK_SUCCESS(err); |
| 7205 | // Now create view for image |
| 7206 | VkImageViewCreateInfo image_view_ci = {}; |
| 7207 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7208 | image_view_ci.image = image; |
| 7209 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7210 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7211 | image_view_ci.subresourceRange.layerCount = 1; |
| 7212 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7213 | image_view_ci.subresourceRange.levelCount = 1; |
| 7214 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7215 | VkImageView image_view; |
| 7216 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7217 | &image_view); |
| 7218 | ASSERT_VK_SUCCESS(err); |
| 7219 | |
| 7220 | VkDescriptorBufferInfo buff_info = {}; |
| 7221 | buff_info.buffer = buffer; |
| 7222 | VkDescriptorImageInfo img_info = {}; |
| 7223 | img_info.imageView = image_view; |
| 7224 | VkWriteDescriptorSet descriptor_write = {}; |
| 7225 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7226 | descriptor_write.dstBinding = 0; |
| 7227 | descriptor_write.descriptorCount = 1; |
| 7228 | descriptor_write.pTexelBufferView = &buff_view; |
| 7229 | descriptor_write.pBufferInfo = &buff_info; |
| 7230 | descriptor_write.pImageInfo = &img_info; |
| 7231 | |
| 7232 | // These error messages align with VkDescriptorType struct |
| 7233 | const char *error_msgs[] = { |
| 7234 | "", // placeholder, no error for SAMPLER descriptor |
| 7235 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7236 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7237 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7238 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7239 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 7240 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7241 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7242 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7243 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7244 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7245 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7246 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7247 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7248 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7249 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7250 | error_msgs[i]); |
| 7251 | |
| 7252 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7253 | NULL); |
| 7254 | |
| 7255 | m_errorMonitor->VerifyFound(); |
| 7256 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7257 | } |
| 7258 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7259 | vkDestroyImage(m_device->device(), image, NULL); |
| 7260 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7261 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7262 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7263 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7264 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7265 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7266 | } |
| 7267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7268 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7269 | // 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] | 7270 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7271 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7272 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7274 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7275 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7276 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7277 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7278 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7279 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7280 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7281 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7282 | |
| 7283 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7284 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7285 | ds_pool_ci.pNext = NULL; |
| 7286 | ds_pool_ci.maxSets = 1; |
| 7287 | ds_pool_ci.poolSizeCount = 1; |
| 7288 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7289 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7290 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7291 | err = |
| 7292 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7293 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7294 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7295 | dsl_binding.binding = 0; |
| 7296 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7297 | dsl_binding.descriptorCount = 1; |
| 7298 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7299 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7300 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7301 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7302 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7303 | ds_layout_ci.pNext = NULL; |
| 7304 | ds_layout_ci.bindingCount = 1; |
| 7305 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7306 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7307 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7308 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7309 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7310 | ASSERT_VK_SUCCESS(err); |
| 7311 | |
| 7312 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7313 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7314 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7315 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7316 | alloc_info.descriptorPool = ds_pool; |
| 7317 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7318 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7319 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7320 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7321 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7322 | VkSamplerCreateInfo sampler_ci = {}; |
| 7323 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7324 | sampler_ci.pNext = NULL; |
| 7325 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7326 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7327 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7328 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7329 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7330 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7331 | sampler_ci.mipLodBias = 1.0; |
| 7332 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7333 | sampler_ci.maxAnisotropy = 1; |
| 7334 | sampler_ci.compareEnable = VK_FALSE; |
| 7335 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7336 | sampler_ci.minLod = 1.0; |
| 7337 | sampler_ci.maxLod = 1.0; |
| 7338 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7339 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7340 | VkSampler sampler; |
| 7341 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7342 | ASSERT_VK_SUCCESS(err); |
| 7343 | |
| 7344 | VkDescriptorImageInfo info = {}; |
| 7345 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7346 | |
| 7347 | VkWriteDescriptorSet descriptor_write; |
| 7348 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7349 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7350 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7351 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7352 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7353 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7354 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7355 | |
| 7356 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7357 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7358 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7359 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7360 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7361 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7362 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7363 | } |
| 7364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7365 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7366 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7367 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7369 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7370 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7371 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7372 | "starting at binding offset of 0 combined with update array element " |
| 7373 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7374 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7376 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7377 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7378 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7379 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7380 | |
| 7381 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7382 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7383 | ds_pool_ci.pNext = NULL; |
| 7384 | ds_pool_ci.maxSets = 1; |
| 7385 | ds_pool_ci.poolSizeCount = 1; |
| 7386 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7387 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7388 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7389 | err = |
| 7390 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7391 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7392 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7393 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7394 | dsl_binding.binding = 0; |
| 7395 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7396 | dsl_binding.descriptorCount = 1; |
| 7397 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7398 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7399 | |
| 7400 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7401 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7402 | ds_layout_ci.pNext = NULL; |
| 7403 | ds_layout_ci.bindingCount = 1; |
| 7404 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7405 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7406 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7407 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7408 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7409 | ASSERT_VK_SUCCESS(err); |
| 7410 | |
| 7411 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7412 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7413 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7414 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7415 | alloc_info.descriptorPool = ds_pool; |
| 7416 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7417 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7418 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7419 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7420 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7421 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7422 | VkDescriptorBufferInfo buff_info = {}; |
| 7423 | buff_info.buffer = |
| 7424 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7425 | buff_info.offset = 0; |
| 7426 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7427 | |
| 7428 | VkWriteDescriptorSet descriptor_write; |
| 7429 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7430 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7431 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7432 | descriptor_write.dstArrayElement = |
| 7433 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7434 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7435 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7436 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7437 | |
| 7438 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7439 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7440 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7441 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7442 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7443 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7444 | } |
| 7445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7446 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7447 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7448 | // index 2 |
| 7449 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7450 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7451 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7452 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7453 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7454 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7455 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7456 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7457 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7458 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7459 | |
| 7460 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7461 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7462 | ds_pool_ci.pNext = NULL; |
| 7463 | ds_pool_ci.maxSets = 1; |
| 7464 | ds_pool_ci.poolSizeCount = 1; |
| 7465 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7466 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7467 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7468 | err = |
| 7469 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7470 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7471 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7472 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7473 | dsl_binding.binding = 0; |
| 7474 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7475 | dsl_binding.descriptorCount = 1; |
| 7476 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7477 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7478 | |
| 7479 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7480 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7481 | ds_layout_ci.pNext = NULL; |
| 7482 | ds_layout_ci.bindingCount = 1; |
| 7483 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7484 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7485 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7486 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7487 | ASSERT_VK_SUCCESS(err); |
| 7488 | |
| 7489 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7490 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7491 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7492 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7493 | alloc_info.descriptorPool = ds_pool; |
| 7494 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7495 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7496 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7497 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7498 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7499 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7500 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7501 | sampler_ci.pNext = NULL; |
| 7502 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7503 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7504 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7505 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7506 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7507 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7508 | sampler_ci.mipLodBias = 1.0; |
| 7509 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7510 | sampler_ci.maxAnisotropy = 1; |
| 7511 | sampler_ci.compareEnable = VK_FALSE; |
| 7512 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7513 | sampler_ci.minLod = 1.0; |
| 7514 | sampler_ci.maxLod = 1.0; |
| 7515 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7516 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7517 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7518 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7519 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7520 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7521 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7522 | VkDescriptorImageInfo info = {}; |
| 7523 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7524 | |
| 7525 | VkWriteDescriptorSet descriptor_write; |
| 7526 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7527 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7528 | descriptor_write.dstSet = descriptorSet; |
| 7529 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7530 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7531 | // 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] | 7532 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7533 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7534 | |
| 7535 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7536 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7537 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7538 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7539 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7540 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7541 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7542 | } |
| 7543 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7544 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7545 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7546 | // types |
| 7547 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7548 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7549 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7550 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7551 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7552 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7553 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7554 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7555 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7556 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7557 | |
| 7558 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7559 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7560 | ds_pool_ci.pNext = NULL; |
| 7561 | ds_pool_ci.maxSets = 1; |
| 7562 | ds_pool_ci.poolSizeCount = 1; |
| 7563 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7564 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7565 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7566 | err = |
| 7567 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7568 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7569 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7570 | dsl_binding.binding = 0; |
| 7571 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7572 | dsl_binding.descriptorCount = 1; |
| 7573 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7574 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7575 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7576 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7577 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7578 | ds_layout_ci.pNext = NULL; |
| 7579 | ds_layout_ci.bindingCount = 1; |
| 7580 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7581 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7582 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7583 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7584 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7585 | ASSERT_VK_SUCCESS(err); |
| 7586 | |
| 7587 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7588 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7589 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7590 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7591 | alloc_info.descriptorPool = ds_pool; |
| 7592 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7593 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7594 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7595 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7596 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7597 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7598 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7599 | sampler_ci.pNext = NULL; |
| 7600 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7601 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7602 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7603 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7604 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7605 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7606 | sampler_ci.mipLodBias = 1.0; |
| 7607 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7608 | sampler_ci.maxAnisotropy = 1; |
| 7609 | sampler_ci.compareEnable = VK_FALSE; |
| 7610 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7611 | sampler_ci.minLod = 1.0; |
| 7612 | sampler_ci.maxLod = 1.0; |
| 7613 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7614 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7615 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7616 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7617 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7618 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7619 | VkDescriptorImageInfo info = {}; |
| 7620 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7621 | |
| 7622 | VkWriteDescriptorSet descriptor_write; |
| 7623 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7624 | descriptor_write.sType = |
| 7625 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7626 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7627 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7628 | // 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] | 7629 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7630 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7631 | |
| 7632 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7633 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7634 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7635 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7636 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7637 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7638 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7639 | } |
| 7640 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7641 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7642 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7643 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7645 | m_errorMonitor->SetDesiredFailureMsg( |
| 7646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7647 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7648 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7649 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7650 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7651 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7652 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7653 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7654 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7655 | |
| 7656 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7657 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7658 | ds_pool_ci.pNext = NULL; |
| 7659 | ds_pool_ci.maxSets = 1; |
| 7660 | ds_pool_ci.poolSizeCount = 1; |
| 7661 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7662 | |
| 7663 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7664 | err = |
| 7665 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7666 | ASSERT_VK_SUCCESS(err); |
| 7667 | |
| 7668 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7669 | dsl_binding.binding = 0; |
| 7670 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7671 | dsl_binding.descriptorCount = 1; |
| 7672 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7673 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7674 | |
| 7675 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7676 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7677 | ds_layout_ci.pNext = NULL; |
| 7678 | ds_layout_ci.bindingCount = 1; |
| 7679 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7680 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7681 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7682 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7683 | ASSERT_VK_SUCCESS(err); |
| 7684 | |
| 7685 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7686 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7687 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7688 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7689 | alloc_info.descriptorPool = ds_pool; |
| 7690 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7691 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7692 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7693 | ASSERT_VK_SUCCESS(err); |
| 7694 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7695 | VkSampler sampler = |
| 7696 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7697 | |
| 7698 | VkDescriptorImageInfo descriptor_info; |
| 7699 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7700 | descriptor_info.sampler = sampler; |
| 7701 | |
| 7702 | VkWriteDescriptorSet descriptor_write; |
| 7703 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7704 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7705 | descriptor_write.dstSet = descriptorSet; |
| 7706 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7707 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7708 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7709 | descriptor_write.pImageInfo = &descriptor_info; |
| 7710 | |
| 7711 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7712 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7713 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7714 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7715 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7716 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7717 | } |
| 7718 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7719 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7720 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7721 | // imageView |
| 7722 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7723 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7724 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7725 | "Attempted write update to combined " |
| 7726 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7727 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7728 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7730 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7731 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7732 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7733 | |
| 7734 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7735 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7736 | ds_pool_ci.pNext = NULL; |
| 7737 | ds_pool_ci.maxSets = 1; |
| 7738 | ds_pool_ci.poolSizeCount = 1; |
| 7739 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7740 | |
| 7741 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7742 | err = |
| 7743 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7744 | ASSERT_VK_SUCCESS(err); |
| 7745 | |
| 7746 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7747 | dsl_binding.binding = 0; |
| 7748 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7749 | dsl_binding.descriptorCount = 1; |
| 7750 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7751 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7752 | |
| 7753 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7754 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7755 | ds_layout_ci.pNext = NULL; |
| 7756 | ds_layout_ci.bindingCount = 1; |
| 7757 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7758 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7760 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7761 | ASSERT_VK_SUCCESS(err); |
| 7762 | |
| 7763 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7764 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7765 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7766 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7767 | alloc_info.descriptorPool = ds_pool; |
| 7768 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7769 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7770 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7771 | ASSERT_VK_SUCCESS(err); |
| 7772 | |
| 7773 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7774 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7775 | sampler_ci.pNext = NULL; |
| 7776 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7777 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7778 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7779 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7780 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7781 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7782 | sampler_ci.mipLodBias = 1.0; |
| 7783 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7784 | sampler_ci.maxAnisotropy = 1; |
| 7785 | sampler_ci.compareEnable = VK_FALSE; |
| 7786 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7787 | sampler_ci.minLod = 1.0; |
| 7788 | sampler_ci.maxLod = 1.0; |
| 7789 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7790 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7791 | |
| 7792 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7793 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7794 | ASSERT_VK_SUCCESS(err); |
| 7795 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7796 | VkImageView view = |
| 7797 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7798 | |
| 7799 | VkDescriptorImageInfo descriptor_info; |
| 7800 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7801 | descriptor_info.sampler = sampler; |
| 7802 | descriptor_info.imageView = view; |
| 7803 | |
| 7804 | VkWriteDescriptorSet descriptor_write; |
| 7805 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7806 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7807 | descriptor_write.dstSet = descriptorSet; |
| 7808 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7809 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7810 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7811 | descriptor_write.pImageInfo = &descriptor_info; |
| 7812 | |
| 7813 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7814 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7815 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7816 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7817 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7818 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7819 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7820 | } |
| 7821 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7822 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7823 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7824 | // into the other |
| 7825 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7826 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7827 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7828 | " binding #1 with type " |
| 7829 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7830 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7831 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7832 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7833 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7834 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7835 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7836 | ds_type_count[0].descriptorCount = 1; |
| 7837 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7838 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7839 | |
| 7840 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7841 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7842 | ds_pool_ci.pNext = NULL; |
| 7843 | ds_pool_ci.maxSets = 1; |
| 7844 | ds_pool_ci.poolSizeCount = 2; |
| 7845 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7846 | |
| 7847 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7848 | err = |
| 7849 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7850 | ASSERT_VK_SUCCESS(err); |
| 7851 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7852 | dsl_binding[0].binding = 0; |
| 7853 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7854 | dsl_binding[0].descriptorCount = 1; |
| 7855 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7856 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7857 | dsl_binding[1].binding = 1; |
| 7858 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7859 | dsl_binding[1].descriptorCount = 1; |
| 7860 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7861 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7862 | |
| 7863 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7864 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7865 | ds_layout_ci.pNext = NULL; |
| 7866 | ds_layout_ci.bindingCount = 2; |
| 7867 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7868 | |
| 7869 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7870 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7871 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7872 | ASSERT_VK_SUCCESS(err); |
| 7873 | |
| 7874 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7875 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7876 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7877 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7878 | alloc_info.descriptorPool = ds_pool; |
| 7879 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7880 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7881 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7882 | ASSERT_VK_SUCCESS(err); |
| 7883 | |
| 7884 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7885 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7886 | sampler_ci.pNext = NULL; |
| 7887 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7888 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7889 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7890 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7891 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7892 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7893 | sampler_ci.mipLodBias = 1.0; |
| 7894 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7895 | sampler_ci.maxAnisotropy = 1; |
| 7896 | sampler_ci.compareEnable = VK_FALSE; |
| 7897 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7898 | sampler_ci.minLod = 1.0; |
| 7899 | sampler_ci.maxLod = 1.0; |
| 7900 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7901 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7902 | |
| 7903 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7904 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7905 | ASSERT_VK_SUCCESS(err); |
| 7906 | |
| 7907 | VkDescriptorImageInfo info = {}; |
| 7908 | info.sampler = sampler; |
| 7909 | |
| 7910 | VkWriteDescriptorSet descriptor_write; |
| 7911 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7912 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7913 | descriptor_write.dstSet = descriptorSet; |
| 7914 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7915 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7916 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7917 | descriptor_write.pImageInfo = &info; |
| 7918 | // This write update should succeed |
| 7919 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7920 | // Now perform a copy update that fails due to type mismatch |
| 7921 | VkCopyDescriptorSet copy_ds_update; |
| 7922 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7923 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7924 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7925 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7926 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7927 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7928 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7929 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7930 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7931 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7932 | // 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] | 7933 | m_errorMonitor->SetDesiredFailureMsg( |
| 7934 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7935 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7936 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7937 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7938 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7939 | copy_ds_update.srcBinding = |
| 7940 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7941 | copy_ds_update.dstSet = descriptorSet; |
| 7942 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7943 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7944 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7945 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7946 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7947 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7948 | // 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] | 7949 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7950 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7951 | "update array offset of 0 and update of " |
| 7952 | "5 descriptors oversteps total number " |
| 7953 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7954 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7955 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7956 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7957 | copy_ds_update.srcSet = descriptorSet; |
| 7958 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7959 | copy_ds_update.dstSet = descriptorSet; |
| 7960 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7961 | copy_ds_update.descriptorCount = |
| 7962 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7963 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7964 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7965 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7966 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7967 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7968 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7969 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7970 | } |
| 7971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7972 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7973 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7974 | // sampleCount |
| 7975 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7976 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7977 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7978 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7979 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7980 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7981 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7982 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7983 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7984 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7985 | |
| 7986 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7987 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7988 | ds_pool_ci.pNext = NULL; |
| 7989 | ds_pool_ci.maxSets = 1; |
| 7990 | ds_pool_ci.poolSizeCount = 1; |
| 7991 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7992 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7993 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7994 | err = |
| 7995 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7996 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7997 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7998 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7999 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8000 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8001 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8002 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8003 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8004 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8005 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8006 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8007 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8008 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8009 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8010 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8011 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8012 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8013 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8014 | ASSERT_VK_SUCCESS(err); |
| 8015 | |
| 8016 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8017 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8018 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8019 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8020 | alloc_info.descriptorPool = ds_pool; |
| 8021 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8022 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8023 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8024 | ASSERT_VK_SUCCESS(err); |
| 8025 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8026 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8027 | pipe_ms_state_ci.sType = |
| 8028 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8029 | pipe_ms_state_ci.pNext = NULL; |
| 8030 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8031 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8032 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8033 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8034 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8035 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8036 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8037 | pipeline_layout_ci.pNext = NULL; |
| 8038 | pipeline_layout_ci.setLayoutCount = 1; |
| 8039 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8040 | |
| 8041 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8042 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8043 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8044 | ASSERT_VK_SUCCESS(err); |
| 8045 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8046 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8047 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8048 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8049 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8050 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8051 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8052 | VkPipelineObj pipe(m_device); |
| 8053 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8054 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8055 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8056 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8057 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8058 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8059 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8060 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8061 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8062 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8063 | // Render triangle (the error should trigger on the attempt to draw). |
| 8064 | Draw(3, 1, 0, 0); |
| 8065 | |
| 8066 | // Finalize recording of the command buffer |
| 8067 | EndCommandBuffer(); |
| 8068 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8069 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8070 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8071 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8072 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8073 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8074 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8075 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8076 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8077 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8078 | // number of color attachments. In this case, we don't add any color |
| 8079 | // blend attachments even though we have a color attachment. |
| 8080 | VkResult err; |
| 8081 | |
| 8082 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8083 | "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] | 8084 | |
| 8085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8086 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8087 | VkDescriptorPoolSize ds_type_count = {}; |
| 8088 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8089 | ds_type_count.descriptorCount = 1; |
| 8090 | |
| 8091 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8092 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8093 | ds_pool_ci.pNext = NULL; |
| 8094 | ds_pool_ci.maxSets = 1; |
| 8095 | ds_pool_ci.poolSizeCount = 1; |
| 8096 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8097 | |
| 8098 | VkDescriptorPool ds_pool; |
| 8099 | err = |
| 8100 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8101 | ASSERT_VK_SUCCESS(err); |
| 8102 | |
| 8103 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8104 | dsl_binding.binding = 0; |
| 8105 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8106 | dsl_binding.descriptorCount = 1; |
| 8107 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8108 | dsl_binding.pImmutableSamplers = NULL; |
| 8109 | |
| 8110 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8111 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8112 | ds_layout_ci.pNext = NULL; |
| 8113 | ds_layout_ci.bindingCount = 1; |
| 8114 | ds_layout_ci.pBindings = &dsl_binding; |
| 8115 | |
| 8116 | VkDescriptorSetLayout ds_layout; |
| 8117 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8118 | &ds_layout); |
| 8119 | ASSERT_VK_SUCCESS(err); |
| 8120 | |
| 8121 | VkDescriptorSet descriptorSet; |
| 8122 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8123 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8124 | alloc_info.descriptorSetCount = 1; |
| 8125 | alloc_info.descriptorPool = ds_pool; |
| 8126 | alloc_info.pSetLayouts = &ds_layout; |
| 8127 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8128 | &descriptorSet); |
| 8129 | ASSERT_VK_SUCCESS(err); |
| 8130 | |
| 8131 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8132 | pipe_ms_state_ci.sType = |
| 8133 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8134 | pipe_ms_state_ci.pNext = NULL; |
| 8135 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8136 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8137 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8138 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8139 | |
| 8140 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8141 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8142 | pipeline_layout_ci.pNext = NULL; |
| 8143 | pipeline_layout_ci.setLayoutCount = 1; |
| 8144 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8145 | |
| 8146 | VkPipelineLayout pipeline_layout; |
| 8147 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8148 | &pipeline_layout); |
| 8149 | ASSERT_VK_SUCCESS(err); |
| 8150 | |
| 8151 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8152 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8153 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8154 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8155 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8156 | // but add it to be able to run on more devices |
| 8157 | VkPipelineObj pipe(m_device); |
| 8158 | pipe.AddShader(&vs); |
| 8159 | pipe.AddShader(&fs); |
| 8160 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8161 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8162 | |
| 8163 | BeginCommandBuffer(); |
| 8164 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8165 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8166 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8167 | // Render triangle (the error should trigger on the attempt to draw). |
| 8168 | Draw(3, 1, 0, 0); |
| 8169 | |
| 8170 | // Finalize recording of the command buffer |
| 8171 | EndCommandBuffer(); |
| 8172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8173 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8174 | |
| 8175 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8176 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8177 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8178 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8179 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8180 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8181 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8182 | // to issuing a Draw |
| 8183 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8185 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8186 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8187 | "vkCmdClearAttachments() issued on CB object "); |
| 8188 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8189 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8190 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8191 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8192 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8193 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8194 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8195 | |
| 8196 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8197 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8198 | ds_pool_ci.pNext = NULL; |
| 8199 | ds_pool_ci.maxSets = 1; |
| 8200 | ds_pool_ci.poolSizeCount = 1; |
| 8201 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8202 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8203 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8204 | err = |
| 8205 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8206 | ASSERT_VK_SUCCESS(err); |
| 8207 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8208 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8209 | dsl_binding.binding = 0; |
| 8210 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8211 | dsl_binding.descriptorCount = 1; |
| 8212 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8213 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8214 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8215 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8216 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8217 | ds_layout_ci.pNext = NULL; |
| 8218 | ds_layout_ci.bindingCount = 1; |
| 8219 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8220 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8221 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8222 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8223 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8224 | ASSERT_VK_SUCCESS(err); |
| 8225 | |
| 8226 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8227 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8228 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8229 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8230 | alloc_info.descriptorPool = ds_pool; |
| 8231 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8232 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8233 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8234 | ASSERT_VK_SUCCESS(err); |
| 8235 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8236 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8237 | pipe_ms_state_ci.sType = |
| 8238 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8239 | pipe_ms_state_ci.pNext = NULL; |
| 8240 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8241 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8242 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8243 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8244 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8245 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8246 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8247 | pipeline_layout_ci.pNext = NULL; |
| 8248 | pipeline_layout_ci.setLayoutCount = 1; |
| 8249 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8250 | |
| 8251 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8252 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8253 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8254 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8257 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8258 | // 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] | 8259 | // on more devices |
| 8260 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8261 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8262 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8263 | VkPipelineObj pipe(m_device); |
| 8264 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8265 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8266 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8267 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8268 | |
| 8269 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8271 | // Main thing we care about for this test is that the VkImage obj we're |
| 8272 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8273 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8274 | VkClearAttachment color_attachment; |
| 8275 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8276 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8277 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8278 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8279 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8280 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8281 | VkClearRect clear_rect = { |
| 8282 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8284 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8285 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8286 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8287 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8288 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8289 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8290 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8291 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8292 | } |
| 8293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8294 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8295 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8296 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8297 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8298 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8299 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8300 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8302 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8303 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8304 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8305 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8306 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8307 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8308 | |
| 8309 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8310 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8311 | ds_pool_ci.pNext = NULL; |
| 8312 | ds_pool_ci.maxSets = 1; |
| 8313 | ds_pool_ci.poolSizeCount = 1; |
| 8314 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8315 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8316 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8317 | err = |
| 8318 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8319 | ASSERT_VK_SUCCESS(err); |
| 8320 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8321 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8322 | dsl_binding.binding = 0; |
| 8323 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8324 | dsl_binding.descriptorCount = 1; |
| 8325 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8326 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8327 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8328 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8329 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8330 | ds_layout_ci.pNext = NULL; |
| 8331 | ds_layout_ci.bindingCount = 1; |
| 8332 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8333 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8334 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8335 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8336 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8337 | ASSERT_VK_SUCCESS(err); |
| 8338 | |
| 8339 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8340 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8341 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8342 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8343 | alloc_info.descriptorPool = ds_pool; |
| 8344 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8346 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8347 | ASSERT_VK_SUCCESS(err); |
| 8348 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8349 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8350 | pipe_ms_state_ci.sType = |
| 8351 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8352 | pipe_ms_state_ci.pNext = NULL; |
| 8353 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8354 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8355 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8356 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8357 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8358 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8359 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8360 | pipeline_layout_ci.pNext = NULL; |
| 8361 | pipeline_layout_ci.setLayoutCount = 1; |
| 8362 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8363 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8365 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8366 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8367 | ASSERT_VK_SUCCESS(err); |
| 8368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8369 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8370 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8371 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8372 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8373 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8374 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8375 | VkPipelineObj pipe(m_device); |
| 8376 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8377 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8378 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8379 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8380 | pipe.SetViewport(m_viewports); |
| 8381 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8382 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8383 | |
| 8384 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8385 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8386 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8387 | // Don't care about actual data, just need to get to draw to flag error |
| 8388 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8389 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8390 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8391 | 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] | 8392 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8394 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8395 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8396 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8397 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8398 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8399 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8400 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8401 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8402 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8403 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8404 | "images in the wrong layout when they're copied or transitioned."); |
| 8405 | // 3 in ValidateCmdBufImageLayouts |
| 8406 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8407 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8408 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8409 | m_errorMonitor->SetDesiredFailureMsg( |
| 8410 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8411 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8412 | |
| 8413 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8414 | // Create src & dst images to use for copy operations |
| 8415 | VkImage src_image; |
| 8416 | VkImage dst_image; |
| 8417 | |
| 8418 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8419 | const int32_t tex_width = 32; |
| 8420 | const int32_t tex_height = 32; |
| 8421 | |
| 8422 | VkImageCreateInfo image_create_info = {}; |
| 8423 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8424 | image_create_info.pNext = NULL; |
| 8425 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8426 | image_create_info.format = tex_format; |
| 8427 | image_create_info.extent.width = tex_width; |
| 8428 | image_create_info.extent.height = tex_height; |
| 8429 | image_create_info.extent.depth = 1; |
| 8430 | image_create_info.mipLevels = 1; |
| 8431 | image_create_info.arrayLayers = 4; |
| 8432 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8433 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8434 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8435 | image_create_info.flags = 0; |
| 8436 | |
| 8437 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8438 | ASSERT_VK_SUCCESS(err); |
| 8439 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8440 | ASSERT_VK_SUCCESS(err); |
| 8441 | |
| 8442 | BeginCommandBuffer(); |
| 8443 | VkImageCopy copyRegion; |
| 8444 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8445 | copyRegion.srcSubresource.mipLevel = 0; |
| 8446 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8447 | copyRegion.srcSubresource.layerCount = 1; |
| 8448 | copyRegion.srcOffset.x = 0; |
| 8449 | copyRegion.srcOffset.y = 0; |
| 8450 | copyRegion.srcOffset.z = 0; |
| 8451 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8452 | copyRegion.dstSubresource.mipLevel = 0; |
| 8453 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8454 | copyRegion.dstSubresource.layerCount = 1; |
| 8455 | copyRegion.dstOffset.x = 0; |
| 8456 | copyRegion.dstOffset.y = 0; |
| 8457 | copyRegion.dstOffset.z = 0; |
| 8458 | copyRegion.extent.width = 1; |
| 8459 | copyRegion.extent.height = 1; |
| 8460 | copyRegion.extent.depth = 1; |
| 8461 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8462 | m_errorMonitor->VerifyFound(); |
| 8463 | // Now cause error due to src image layout changing |
| 8464 | m_errorMonitor->SetDesiredFailureMsg( |
| 8465 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8466 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8467 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8468 | m_errorMonitor->VerifyFound(); |
| 8469 | // Final src error is due to bad layout type |
| 8470 | m_errorMonitor->SetDesiredFailureMsg( |
| 8471 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8472 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8473 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8474 | m_errorMonitor->VerifyFound(); |
| 8475 | // Now verify same checks for dst |
| 8476 | m_errorMonitor->SetDesiredFailureMsg( |
| 8477 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8478 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8479 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8480 | m_errorMonitor->VerifyFound(); |
| 8481 | // Now cause error due to src image layout changing |
| 8482 | m_errorMonitor->SetDesiredFailureMsg( |
| 8483 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8484 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8485 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8486 | m_errorMonitor->VerifyFound(); |
| 8487 | m_errorMonitor->SetDesiredFailureMsg( |
| 8488 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8489 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8490 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8491 | m_errorMonitor->VerifyFound(); |
| 8492 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8493 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8494 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8495 | image_barrier[0].image = src_image; |
| 8496 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8497 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8498 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8499 | m_errorMonitor->SetDesiredFailureMsg( |
| 8500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8501 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8502 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8503 | m_errorMonitor->VerifyFound(); |
| 8504 | |
| 8505 | // Finally some layout errors at RenderPass create time |
| 8506 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8507 | VkAttachmentReference attach = {}; |
| 8508 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8509 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8510 | VkSubpassDescription subpass = {}; |
| 8511 | subpass.inputAttachmentCount = 1; |
| 8512 | subpass.pInputAttachments = &attach; |
| 8513 | VkRenderPassCreateInfo rpci = {}; |
| 8514 | rpci.subpassCount = 1; |
| 8515 | rpci.pSubpasses = &subpass; |
| 8516 | rpci.attachmentCount = 1; |
| 8517 | VkAttachmentDescription attach_desc = {}; |
| 8518 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8519 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8520 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8521 | VkRenderPass rp; |
| 8522 | m_errorMonitor->SetDesiredFailureMsg( |
| 8523 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8524 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8525 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8526 | m_errorMonitor->VerifyFound(); |
| 8527 | // error w/ non-general layout |
| 8528 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8529 | |
| 8530 | m_errorMonitor->SetDesiredFailureMsg( |
| 8531 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8532 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8533 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8534 | m_errorMonitor->VerifyFound(); |
| 8535 | subpass.inputAttachmentCount = 0; |
| 8536 | subpass.colorAttachmentCount = 1; |
| 8537 | subpass.pColorAttachments = &attach; |
| 8538 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8539 | // perf warning for GENERAL layout on color attachment |
| 8540 | m_errorMonitor->SetDesiredFailureMsg( |
| 8541 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8542 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8543 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8544 | m_errorMonitor->VerifyFound(); |
| 8545 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8546 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8547 | m_errorMonitor->SetDesiredFailureMsg( |
| 8548 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8549 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8550 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8551 | m_errorMonitor->VerifyFound(); |
| 8552 | subpass.colorAttachmentCount = 0; |
| 8553 | subpass.pDepthStencilAttachment = &attach; |
| 8554 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8555 | // perf warning for GENERAL layout on DS attachment |
| 8556 | m_errorMonitor->SetDesiredFailureMsg( |
| 8557 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8558 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8559 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8560 | m_errorMonitor->VerifyFound(); |
| 8561 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8562 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8563 | m_errorMonitor->SetDesiredFailureMsg( |
| 8564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8565 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8566 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8567 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8568 | // For this error we need a valid renderpass so create default one |
| 8569 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8570 | attach.attachment = 0; |
| 8571 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8572 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8573 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8574 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8575 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8576 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8577 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8578 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8579 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8580 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8581 | " with invalid first layout " |
| 8582 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8583 | "ONLY_OPTIMAL"); |
| 8584 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8585 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8586 | |
| 8587 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8588 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8589 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8590 | #endif // DRAW_STATE_TESTS |
| 8591 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8592 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8593 | #if GTEST_IS_THREADSAFE |
| 8594 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8595 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8596 | VkEvent event; |
| 8597 | bool bailout; |
| 8598 | }; |
| 8599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8600 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8601 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8603 | for (int i = 0; i < 10000; i++) { |
| 8604 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8605 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8606 | if (data->bailout) { |
| 8607 | break; |
| 8608 | } |
| 8609 | } |
| 8610 | return NULL; |
| 8611 | } |
| 8612 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8613 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8614 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8615 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8616 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8617 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8618 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8620 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8621 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8622 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8623 | // Calls AllocateCommandBuffers |
| 8624 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8625 | |
| 8626 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8627 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8628 | |
| 8629 | VkEventCreateInfo event_info; |
| 8630 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8631 | VkResult err; |
| 8632 | |
| 8633 | memset(&event_info, 0, sizeof(event_info)); |
| 8634 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8635 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8636 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8637 | ASSERT_VK_SUCCESS(err); |
| 8638 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8639 | err = vkResetEvent(device(), event); |
| 8640 | ASSERT_VK_SUCCESS(err); |
| 8641 | |
| 8642 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8643 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8644 | data.event = event; |
| 8645 | data.bailout = false; |
| 8646 | m_errorMonitor->SetBailout(&data.bailout); |
| 8647 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8648 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8649 | // Add many entries to command buffer from this thread at the same time. |
| 8650 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8651 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8652 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8653 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8654 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8655 | m_errorMonitor->SetBailout(NULL); |
| 8656 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8657 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8658 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8659 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8660 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8661 | #endif // GTEST_IS_THREADSAFE |
| 8662 | #endif // THREADING_TESTS |
| 8663 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8664 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8665 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8666 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8667 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8668 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8670 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8671 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8672 | VkShaderModule module; |
| 8673 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8674 | struct icd_spv_header spv; |
| 8675 | |
| 8676 | spv.magic = ICD_SPV_MAGIC; |
| 8677 | spv.version = ICD_SPV_VERSION; |
| 8678 | spv.gen_magic = 0; |
| 8679 | |
| 8680 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8681 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8682 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8683 | moduleCreateInfo.codeSize = 4; |
| 8684 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8685 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8686 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8687 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8688 | } |
| 8689 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8690 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8691 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8692 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8693 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8694 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8695 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8696 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8697 | VkShaderModule module; |
| 8698 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8699 | struct icd_spv_header spv; |
| 8700 | |
| 8701 | spv.magic = ~ICD_SPV_MAGIC; |
| 8702 | spv.version = ICD_SPV_VERSION; |
| 8703 | spv.gen_magic = 0; |
| 8704 | |
| 8705 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8706 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8707 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8708 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8709 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8710 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8711 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8712 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8713 | } |
| 8714 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8715 | #if 0 |
| 8716 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8717 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8718 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8719 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8720 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8721 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8722 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8723 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8724 | VkShaderModule module; |
| 8725 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8726 | struct icd_spv_header spv; |
| 8727 | |
| 8728 | spv.magic = ICD_SPV_MAGIC; |
| 8729 | spv.version = ~ICD_SPV_VERSION; |
| 8730 | spv.gen_magic = 0; |
| 8731 | |
| 8732 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8733 | moduleCreateInfo.pNext = NULL; |
| 8734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8735 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8736 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8737 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8738 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8739 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8740 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8741 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8742 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8744 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8745 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8746 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8747 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8748 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8749 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8750 | |
| 8751 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8752 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8753 | "\n" |
| 8754 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8755 | "out gl_PerVertex {\n" |
| 8756 | " vec4 gl_Position;\n" |
| 8757 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8758 | "void main(){\n" |
| 8759 | " gl_Position = vec4(1);\n" |
| 8760 | " x = 0;\n" |
| 8761 | "}\n"; |
| 8762 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8763 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8764 | "\n" |
| 8765 | "layout(location=0) out vec4 color;\n" |
| 8766 | "void main(){\n" |
| 8767 | " color = vec4(1);\n" |
| 8768 | "}\n"; |
| 8769 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8770 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8771 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8772 | |
| 8773 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8774 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8775 | pipe.AddShader(&vs); |
| 8776 | pipe.AddShader(&fs); |
| 8777 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8778 | VkDescriptorSetObj descriptorSet(m_device); |
| 8779 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8780 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8781 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8782 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8783 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8784 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8785 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8786 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8787 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8788 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8789 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8790 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8791 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8792 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8793 | |
| 8794 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8795 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8796 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8797 | "out gl_PerVertex {\n" |
| 8798 | " vec4 gl_Position;\n" |
| 8799 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8800 | "void main(){\n" |
| 8801 | " gl_Position = vec4(1);\n" |
| 8802 | "}\n"; |
| 8803 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8804 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8805 | "\n" |
| 8806 | "layout(location=0) in float x;\n" |
| 8807 | "layout(location=0) out vec4 color;\n" |
| 8808 | "void main(){\n" |
| 8809 | " color = vec4(x);\n" |
| 8810 | "}\n"; |
| 8811 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8812 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8813 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8814 | |
| 8815 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8816 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8817 | pipe.AddShader(&vs); |
| 8818 | pipe.AddShader(&fs); |
| 8819 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8820 | VkDescriptorSetObj descriptorSet(m_device); |
| 8821 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8822 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8823 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8824 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8825 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8826 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8827 | } |
| 8828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8829 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8831 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8832 | |
| 8833 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8834 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8835 | |
| 8836 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8837 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8838 | "\n" |
| 8839 | "out gl_PerVertex {\n" |
| 8840 | " vec4 gl_Position;\n" |
| 8841 | "};\n" |
| 8842 | "void main(){\n" |
| 8843 | " gl_Position = vec4(1);\n" |
| 8844 | "}\n"; |
| 8845 | char const *fsSource = |
| 8846 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8847 | "\n" |
| 8848 | "in block { layout(location=0) float x; } ins;\n" |
| 8849 | "layout(location=0) out vec4 color;\n" |
| 8850 | "void main(){\n" |
| 8851 | " color = vec4(ins.x);\n" |
| 8852 | "}\n"; |
| 8853 | |
| 8854 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8855 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8856 | |
| 8857 | VkPipelineObj pipe(m_device); |
| 8858 | pipe.AddColorAttachment(); |
| 8859 | pipe.AddShader(&vs); |
| 8860 | pipe.AddShader(&fs); |
| 8861 | |
| 8862 | VkDescriptorSetObj descriptorSet(m_device); |
| 8863 | descriptorSet.AppendDummy(); |
| 8864 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8865 | |
| 8866 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8867 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8868 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8869 | } |
| 8870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8871 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8872 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8873 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8874 | "output arr[2] of float32' vs 'ptr to " |
| 8875 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8876 | |
| 8877 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8878 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8879 | |
| 8880 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8881 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8882 | "\n" |
| 8883 | "layout(location=0) out float x[2];\n" |
| 8884 | "out gl_PerVertex {\n" |
| 8885 | " vec4 gl_Position;\n" |
| 8886 | "};\n" |
| 8887 | "void main(){\n" |
| 8888 | " x[0] = 0; x[1] = 0;\n" |
| 8889 | " gl_Position = vec4(1);\n" |
| 8890 | "}\n"; |
| 8891 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8892 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8893 | "\n" |
| 8894 | "layout(location=0) in float x[3];\n" |
| 8895 | "layout(location=0) out vec4 color;\n" |
| 8896 | "void main(){\n" |
| 8897 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8898 | "}\n"; |
| 8899 | |
| 8900 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8901 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8902 | |
| 8903 | VkPipelineObj pipe(m_device); |
| 8904 | pipe.AddColorAttachment(); |
| 8905 | pipe.AddShader(&vs); |
| 8906 | pipe.AddShader(&fs); |
| 8907 | |
| 8908 | VkDescriptorSetObj descriptorSet(m_device); |
| 8909 | descriptorSet.AppendDummy(); |
| 8910 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8911 | |
| 8912 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8913 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8914 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8915 | } |
| 8916 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8917 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8919 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8920 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8922 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8923 | |
| 8924 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8925 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8926 | "\n" |
| 8927 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8928 | "out gl_PerVertex {\n" |
| 8929 | " vec4 gl_Position;\n" |
| 8930 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8931 | "void main(){\n" |
| 8932 | " x = 0;\n" |
| 8933 | " gl_Position = vec4(1);\n" |
| 8934 | "}\n"; |
| 8935 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8936 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8937 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8938 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8939 | "layout(location=0) out vec4 color;\n" |
| 8940 | "void main(){\n" |
| 8941 | " color = vec4(x);\n" |
| 8942 | "}\n"; |
| 8943 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8944 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8945 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8946 | |
| 8947 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8948 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8949 | pipe.AddShader(&vs); |
| 8950 | pipe.AddShader(&fs); |
| 8951 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8952 | VkDescriptorSetObj descriptorSet(m_device); |
| 8953 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8954 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8955 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8956 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8957 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8958 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8959 | } |
| 8960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8961 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8962 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8963 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8964 | |
| 8965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8966 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8967 | |
| 8968 | char const *vsSource = |
| 8969 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8970 | "\n" |
| 8971 | "out block { layout(location=0) int x; } outs;\n" |
| 8972 | "out gl_PerVertex {\n" |
| 8973 | " vec4 gl_Position;\n" |
| 8974 | "};\n" |
| 8975 | "void main(){\n" |
| 8976 | " outs.x = 0;\n" |
| 8977 | " gl_Position = vec4(1);\n" |
| 8978 | "}\n"; |
| 8979 | char const *fsSource = |
| 8980 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8981 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8982 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8983 | "layout(location=0) out vec4 color;\n" |
| 8984 | "void main(){\n" |
| 8985 | " color = vec4(ins.x);\n" |
| 8986 | "}\n"; |
| 8987 | |
| 8988 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8989 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8990 | |
| 8991 | VkPipelineObj pipe(m_device); |
| 8992 | pipe.AddColorAttachment(); |
| 8993 | pipe.AddShader(&vs); |
| 8994 | pipe.AddShader(&fs); |
| 8995 | |
| 8996 | VkDescriptorSetObj descriptorSet(m_device); |
| 8997 | descriptorSet.AppendDummy(); |
| 8998 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8999 | |
| 9000 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9001 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9002 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9003 | } |
| 9004 | |
| 9005 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9006 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9007 | "location 0.0 which is not written by vertex shader"); |
| 9008 | |
| 9009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9011 | |
| 9012 | char const *vsSource = |
| 9013 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9014 | "\n" |
| 9015 | "out block { layout(location=1) float x; } outs;\n" |
| 9016 | "out gl_PerVertex {\n" |
| 9017 | " vec4 gl_Position;\n" |
| 9018 | "};\n" |
| 9019 | "void main(){\n" |
| 9020 | " outs.x = 0;\n" |
| 9021 | " gl_Position = vec4(1);\n" |
| 9022 | "}\n"; |
| 9023 | char const *fsSource = |
| 9024 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9025 | "\n" |
| 9026 | "in block { layout(location=0) float x; } ins;\n" |
| 9027 | "layout(location=0) out vec4 color;\n" |
| 9028 | "void main(){\n" |
| 9029 | " color = vec4(ins.x);\n" |
| 9030 | "}\n"; |
| 9031 | |
| 9032 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9033 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9034 | |
| 9035 | VkPipelineObj pipe(m_device); |
| 9036 | pipe.AddColorAttachment(); |
| 9037 | pipe.AddShader(&vs); |
| 9038 | pipe.AddShader(&fs); |
| 9039 | |
| 9040 | VkDescriptorSetObj descriptorSet(m_device); |
| 9041 | descriptorSet.AppendDummy(); |
| 9042 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9043 | |
| 9044 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9045 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9046 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9047 | } |
| 9048 | |
| 9049 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9051 | "location 0.1 which is not written by vertex shader"); |
| 9052 | |
| 9053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9054 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9055 | |
| 9056 | char const *vsSource = |
| 9057 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9058 | "\n" |
| 9059 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9060 | "out gl_PerVertex {\n" |
| 9061 | " vec4 gl_Position;\n" |
| 9062 | "};\n" |
| 9063 | "void main(){\n" |
| 9064 | " outs.x = 0;\n" |
| 9065 | " gl_Position = vec4(1);\n" |
| 9066 | "}\n"; |
| 9067 | char const *fsSource = |
| 9068 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9069 | "\n" |
| 9070 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9071 | "layout(location=0) out vec4 color;\n" |
| 9072 | "void main(){\n" |
| 9073 | " color = vec4(ins.x);\n" |
| 9074 | "}\n"; |
| 9075 | |
| 9076 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9077 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9078 | |
| 9079 | VkPipelineObj pipe(m_device); |
| 9080 | pipe.AddColorAttachment(); |
| 9081 | pipe.AddShader(&vs); |
| 9082 | pipe.AddShader(&fs); |
| 9083 | |
| 9084 | VkDescriptorSetObj descriptorSet(m_device); |
| 9085 | descriptorSet.AppendDummy(); |
| 9086 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9087 | |
| 9088 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9089 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9090 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9091 | } |
| 9092 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9093 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9094 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9095 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9096 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9098 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9099 | |
| 9100 | VkVertexInputBindingDescription input_binding; |
| 9101 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9102 | |
| 9103 | VkVertexInputAttributeDescription input_attrib; |
| 9104 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9105 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9106 | |
| 9107 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9108 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9109 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9110 | "out gl_PerVertex {\n" |
| 9111 | " vec4 gl_Position;\n" |
| 9112 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9113 | "void main(){\n" |
| 9114 | " gl_Position = vec4(1);\n" |
| 9115 | "}\n"; |
| 9116 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9117 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9118 | "\n" |
| 9119 | "layout(location=0) out vec4 color;\n" |
| 9120 | "void main(){\n" |
| 9121 | " color = vec4(1);\n" |
| 9122 | "}\n"; |
| 9123 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9124 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9125 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9126 | |
| 9127 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9128 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9129 | pipe.AddShader(&vs); |
| 9130 | pipe.AddShader(&fs); |
| 9131 | |
| 9132 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9133 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9134 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9135 | VkDescriptorSetObj descriptorSet(m_device); |
| 9136 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9137 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9138 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9139 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9140 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9141 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9142 | } |
| 9143 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9144 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9145 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9146 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9147 | |
| 9148 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9149 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9150 | |
| 9151 | VkVertexInputBindingDescription input_binding; |
| 9152 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9153 | |
| 9154 | VkVertexInputAttributeDescription input_attrib; |
| 9155 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9156 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9157 | |
| 9158 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9159 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9160 | "\n" |
| 9161 | "layout(location=1) in float x;\n" |
| 9162 | "out gl_PerVertex {\n" |
| 9163 | " vec4 gl_Position;\n" |
| 9164 | "};\n" |
| 9165 | "void main(){\n" |
| 9166 | " gl_Position = vec4(x);\n" |
| 9167 | "}\n"; |
| 9168 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9169 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9170 | "\n" |
| 9171 | "layout(location=0) out vec4 color;\n" |
| 9172 | "void main(){\n" |
| 9173 | " color = vec4(1);\n" |
| 9174 | "}\n"; |
| 9175 | |
| 9176 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9177 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9178 | |
| 9179 | VkPipelineObj pipe(m_device); |
| 9180 | pipe.AddColorAttachment(); |
| 9181 | pipe.AddShader(&vs); |
| 9182 | pipe.AddShader(&fs); |
| 9183 | |
| 9184 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9185 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9186 | |
| 9187 | VkDescriptorSetObj descriptorSet(m_device); |
| 9188 | descriptorSet.AppendDummy(); |
| 9189 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9190 | |
| 9191 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9192 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9193 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9194 | } |
| 9195 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9196 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9197 | m_errorMonitor->SetDesiredFailureMsg( |
| 9198 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9199 | "VS consumes input at location 0 but not provided"); |
| 9200 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9201 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9202 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9203 | |
| 9204 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9205 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9206 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9207 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9208 | "out gl_PerVertex {\n" |
| 9209 | " vec4 gl_Position;\n" |
| 9210 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9211 | "void main(){\n" |
| 9212 | " gl_Position = x;\n" |
| 9213 | "}\n"; |
| 9214 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9215 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9216 | "\n" |
| 9217 | "layout(location=0) out vec4 color;\n" |
| 9218 | "void main(){\n" |
| 9219 | " color = vec4(1);\n" |
| 9220 | "}\n"; |
| 9221 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9222 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9223 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9224 | |
| 9225 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9226 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9227 | pipe.AddShader(&vs); |
| 9228 | pipe.AddShader(&fs); |
| 9229 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9230 | VkDescriptorSetObj descriptorSet(m_device); |
| 9231 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9232 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9233 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9234 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9235 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9236 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9237 | } |
| 9238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9239 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9240 | m_errorMonitor->SetDesiredFailureMsg( |
| 9241 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9242 | "location 0 does not match VS input type"); |
| 9243 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9244 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9245 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9246 | |
| 9247 | VkVertexInputBindingDescription input_binding; |
| 9248 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9249 | |
| 9250 | VkVertexInputAttributeDescription input_attrib; |
| 9251 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9252 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9253 | |
| 9254 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9255 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9256 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9257 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9258 | "out gl_PerVertex {\n" |
| 9259 | " vec4 gl_Position;\n" |
| 9260 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9261 | "void main(){\n" |
| 9262 | " gl_Position = vec4(x);\n" |
| 9263 | "}\n"; |
| 9264 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9265 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9266 | "\n" |
| 9267 | "layout(location=0) out vec4 color;\n" |
| 9268 | "void main(){\n" |
| 9269 | " color = vec4(1);\n" |
| 9270 | "}\n"; |
| 9271 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9272 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9273 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9274 | |
| 9275 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9276 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9277 | pipe.AddShader(&vs); |
| 9278 | pipe.AddShader(&fs); |
| 9279 | |
| 9280 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9281 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9282 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9283 | VkDescriptorSetObj descriptorSet(m_device); |
| 9284 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9285 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9286 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9287 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9288 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9289 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9290 | } |
| 9291 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9292 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9293 | m_errorMonitor->SetDesiredFailureMsg( |
| 9294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9295 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9296 | |
| 9297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9298 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9299 | |
| 9300 | char const *vsSource = |
| 9301 | "#version 450\n" |
| 9302 | "\n" |
| 9303 | "out gl_PerVertex {\n" |
| 9304 | " vec4 gl_Position;\n" |
| 9305 | "};\n" |
| 9306 | "void main(){\n" |
| 9307 | " gl_Position = vec4(1);\n" |
| 9308 | "}\n"; |
| 9309 | char const *fsSource = |
| 9310 | "#version 450\n" |
| 9311 | "\n" |
| 9312 | "layout(location=0) out vec4 color;\n" |
| 9313 | "void main(){\n" |
| 9314 | " color = vec4(1);\n" |
| 9315 | "}\n"; |
| 9316 | |
| 9317 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9318 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9319 | |
| 9320 | VkPipelineObj pipe(m_device); |
| 9321 | pipe.AddColorAttachment(); |
| 9322 | pipe.AddShader(&vs); |
| 9323 | pipe.AddShader(&vs); |
| 9324 | pipe.AddShader(&fs); |
| 9325 | |
| 9326 | VkDescriptorSetObj descriptorSet(m_device); |
| 9327 | descriptorSet.AppendDummy(); |
| 9328 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9329 | |
| 9330 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9331 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9332 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9333 | } |
| 9334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9335 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9336 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9337 | |
| 9338 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9340 | |
| 9341 | VkVertexInputBindingDescription input_binding; |
| 9342 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9343 | |
| 9344 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9345 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9346 | |
| 9347 | for (int i = 0; i < 2; i++) { |
| 9348 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9349 | input_attribs[i].location = i; |
| 9350 | } |
| 9351 | |
| 9352 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9353 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9354 | "\n" |
| 9355 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9356 | "out gl_PerVertex {\n" |
| 9357 | " vec4 gl_Position;\n" |
| 9358 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9359 | "void main(){\n" |
| 9360 | " gl_Position = x[0] + x[1];\n" |
| 9361 | "}\n"; |
| 9362 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9363 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9364 | "\n" |
| 9365 | "layout(location=0) out vec4 color;\n" |
| 9366 | "void main(){\n" |
| 9367 | " color = vec4(1);\n" |
| 9368 | "}\n"; |
| 9369 | |
| 9370 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9371 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9372 | |
| 9373 | VkPipelineObj pipe(m_device); |
| 9374 | pipe.AddColorAttachment(); |
| 9375 | pipe.AddShader(&vs); |
| 9376 | pipe.AddShader(&fs); |
| 9377 | |
| 9378 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9379 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9380 | |
| 9381 | VkDescriptorSetObj descriptorSet(m_device); |
| 9382 | descriptorSet.AppendDummy(); |
| 9383 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9384 | |
| 9385 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9386 | |
| 9387 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9388 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9389 | } |
| 9390 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9391 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9392 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9393 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9394 | |
| 9395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9396 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9397 | |
| 9398 | VkVertexInputBindingDescription input_binding; |
| 9399 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9400 | |
| 9401 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9402 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9403 | |
| 9404 | for (int i = 0; i < 2; i++) { |
| 9405 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9406 | input_attribs[i].location = i; |
| 9407 | } |
| 9408 | |
| 9409 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9410 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9411 | "\n" |
| 9412 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9413 | "out gl_PerVertex {\n" |
| 9414 | " vec4 gl_Position;\n" |
| 9415 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9416 | "void main(){\n" |
| 9417 | " gl_Position = x[0] + x[1];\n" |
| 9418 | "}\n"; |
| 9419 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9420 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9421 | "\n" |
| 9422 | "layout(location=0) out vec4 color;\n" |
| 9423 | "void main(){\n" |
| 9424 | " color = vec4(1);\n" |
| 9425 | "}\n"; |
| 9426 | |
| 9427 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9428 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9429 | |
| 9430 | VkPipelineObj pipe(m_device); |
| 9431 | pipe.AddColorAttachment(); |
| 9432 | pipe.AddShader(&vs); |
| 9433 | pipe.AddShader(&fs); |
| 9434 | |
| 9435 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9436 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9437 | |
| 9438 | VkDescriptorSetObj descriptorSet(m_device); |
| 9439 | descriptorSet.AppendDummy(); |
| 9440 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9441 | |
| 9442 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9443 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9444 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9445 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9446 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9447 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9448 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9449 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9450 | |
| 9451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9453 | |
| 9454 | char const *vsSource = |
| 9455 | "#version 450\n" |
| 9456 | "out gl_PerVertex {\n" |
| 9457 | " vec4 gl_Position;\n" |
| 9458 | "};\n" |
| 9459 | "void main(){\n" |
| 9460 | " gl_Position = vec4(0);\n" |
| 9461 | "}\n"; |
| 9462 | char const *fsSource = |
| 9463 | "#version 450\n" |
| 9464 | "\n" |
| 9465 | "layout(location=0) out vec4 color;\n" |
| 9466 | "void main(){\n" |
| 9467 | " color = vec4(1);\n" |
| 9468 | "}\n"; |
| 9469 | |
| 9470 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9471 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9472 | |
| 9473 | VkPipelineObj pipe(m_device); |
| 9474 | pipe.AddColorAttachment(); |
| 9475 | pipe.AddShader(&vs); |
| 9476 | pipe.AddShader(&fs); |
| 9477 | |
| 9478 | VkDescriptorSetObj descriptorSet(m_device); |
| 9479 | descriptorSet.AppendDummy(); |
| 9480 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9481 | |
| 9482 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9483 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9484 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9485 | } |
| 9486 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9487 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9488 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9489 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9490 | |
| 9491 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9492 | |
| 9493 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9495 | |
| 9496 | char const *vsSource = |
| 9497 | "#version 450\n" |
| 9498 | "out gl_PerVertex {\n" |
| 9499 | " vec4 gl_Position;\n" |
| 9500 | "};\n" |
| 9501 | "layout(location=0) out vec3 x;\n" |
| 9502 | "layout(location=1) out ivec3 y;\n" |
| 9503 | "layout(location=2) out vec3 z;\n" |
| 9504 | "void main(){\n" |
| 9505 | " gl_Position = vec4(0);\n" |
| 9506 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9507 | "}\n"; |
| 9508 | char const *fsSource = |
| 9509 | "#version 450\n" |
| 9510 | "\n" |
| 9511 | "layout(location=0) out vec4 color;\n" |
| 9512 | "layout(location=0) in float x;\n" |
| 9513 | "layout(location=1) flat in int y;\n" |
| 9514 | "layout(location=2) in vec2 z;\n" |
| 9515 | "void main(){\n" |
| 9516 | " color = vec4(1 + x + y + z.x);\n" |
| 9517 | "}\n"; |
| 9518 | |
| 9519 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9520 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9521 | |
| 9522 | VkPipelineObj pipe(m_device); |
| 9523 | pipe.AddColorAttachment(); |
| 9524 | pipe.AddShader(&vs); |
| 9525 | pipe.AddShader(&fs); |
| 9526 | |
| 9527 | VkDescriptorSetObj descriptorSet(m_device); |
| 9528 | descriptorSet.AppendDummy(); |
| 9529 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9530 | |
| 9531 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9532 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9533 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9534 | } |
| 9535 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9536 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9537 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9538 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9539 | |
| 9540 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9541 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9542 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9543 | if (!m_device->phy().features().tessellationShader) { |
| 9544 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9545 | return; |
| 9546 | } |
| 9547 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9548 | char const *vsSource = |
| 9549 | "#version 450\n" |
| 9550 | "void main(){}\n"; |
| 9551 | char const *tcsSource = |
| 9552 | "#version 450\n" |
| 9553 | "layout(location=0) out int x[];\n" |
| 9554 | "layout(vertices=3) out;\n" |
| 9555 | "void main(){\n" |
| 9556 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9557 | " gl_TessLevelInner[0] = 1;\n" |
| 9558 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9559 | "}\n"; |
| 9560 | char const *tesSource = |
| 9561 | "#version 450\n" |
| 9562 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9563 | "layout(location=0) in int x[];\n" |
| 9564 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9565 | "void main(){\n" |
| 9566 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9567 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9568 | "}\n"; |
| 9569 | char const *fsSource = |
| 9570 | "#version 450\n" |
| 9571 | "layout(location=0) out vec4 color;\n" |
| 9572 | "void main(){\n" |
| 9573 | " color = vec4(1);\n" |
| 9574 | "}\n"; |
| 9575 | |
| 9576 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9577 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9578 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9579 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9580 | |
| 9581 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9582 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9583 | nullptr, |
| 9584 | 0, |
| 9585 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9586 | VK_FALSE}; |
| 9587 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9588 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9589 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9590 | nullptr, |
| 9591 | 0, |
| 9592 | 3}; |
| 9593 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9594 | VkPipelineObj pipe(m_device); |
| 9595 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9596 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9597 | pipe.AddColorAttachment(); |
| 9598 | pipe.AddShader(&vs); |
| 9599 | pipe.AddShader(&tcs); |
| 9600 | pipe.AddShader(&tes); |
| 9601 | pipe.AddShader(&fs); |
| 9602 | |
| 9603 | VkDescriptorSetObj descriptorSet(m_device); |
| 9604 | descriptorSet.AppendDummy(); |
| 9605 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9606 | |
| 9607 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9608 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9609 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9610 | } |
| 9611 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9612 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9613 | { |
| 9614 | m_errorMonitor->ExpectSuccess(); |
| 9615 | |
| 9616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9617 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9618 | |
| 9619 | if (!m_device->phy().features().geometryShader) { |
| 9620 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9621 | return; |
| 9622 | } |
| 9623 | |
| 9624 | char const *vsSource = |
| 9625 | "#version 450\n" |
| 9626 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9627 | "void main(){\n" |
| 9628 | " vs_out.x = vec4(1);\n" |
| 9629 | "}\n"; |
| 9630 | char const *gsSource = |
| 9631 | "#version 450\n" |
| 9632 | "layout(triangles) in;\n" |
| 9633 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9634 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9635 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9636 | "void main() {\n" |
| 9637 | " gl_Position = gs_in[0].x;\n" |
| 9638 | " EmitVertex();\n" |
| 9639 | "}\n"; |
| 9640 | char const *fsSource = |
| 9641 | "#version 450\n" |
| 9642 | "layout(location=0) out vec4 color;\n" |
| 9643 | "void main(){\n" |
| 9644 | " color = vec4(1);\n" |
| 9645 | "}\n"; |
| 9646 | |
| 9647 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9648 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9649 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9650 | |
| 9651 | VkPipelineObj pipe(m_device); |
| 9652 | pipe.AddColorAttachment(); |
| 9653 | pipe.AddShader(&vs); |
| 9654 | pipe.AddShader(&gs); |
| 9655 | pipe.AddShader(&fs); |
| 9656 | |
| 9657 | VkDescriptorSetObj descriptorSet(m_device); |
| 9658 | descriptorSet.AppendDummy(); |
| 9659 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9660 | |
| 9661 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9662 | |
| 9663 | m_errorMonitor->VerifyNotFound(); |
| 9664 | } |
| 9665 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9666 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9667 | { |
| 9668 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9669 | "is per-vertex in tessellation control shader stage " |
| 9670 | "but per-patch in tessellation evaluation shader stage"); |
| 9671 | |
| 9672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9673 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9674 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9675 | if (!m_device->phy().features().tessellationShader) { |
| 9676 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9677 | return; |
| 9678 | } |
| 9679 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9680 | char const *vsSource = |
| 9681 | "#version 450\n" |
| 9682 | "void main(){}\n"; |
| 9683 | char const *tcsSource = |
| 9684 | "#version 450\n" |
| 9685 | "layout(location=0) out int x[];\n" |
| 9686 | "layout(vertices=3) out;\n" |
| 9687 | "void main(){\n" |
| 9688 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9689 | " gl_TessLevelInner[0] = 1;\n" |
| 9690 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9691 | "}\n"; |
| 9692 | char const *tesSource = |
| 9693 | "#version 450\n" |
| 9694 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9695 | "layout(location=0) patch in int x;\n" |
| 9696 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9697 | "void main(){\n" |
| 9698 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9699 | " gl_Position.w = x;\n" |
| 9700 | "}\n"; |
| 9701 | char const *fsSource = |
| 9702 | "#version 450\n" |
| 9703 | "layout(location=0) out vec4 color;\n" |
| 9704 | "void main(){\n" |
| 9705 | " color = vec4(1);\n" |
| 9706 | "}\n"; |
| 9707 | |
| 9708 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9709 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9710 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9711 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9712 | |
| 9713 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9714 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9715 | nullptr, |
| 9716 | 0, |
| 9717 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9718 | VK_FALSE}; |
| 9719 | |
| 9720 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9721 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9722 | nullptr, |
| 9723 | 0, |
| 9724 | 3}; |
| 9725 | |
| 9726 | VkPipelineObj pipe(m_device); |
| 9727 | pipe.SetInputAssembly(&iasci); |
| 9728 | pipe.SetTessellation(&tsci); |
| 9729 | pipe.AddColorAttachment(); |
| 9730 | pipe.AddShader(&vs); |
| 9731 | pipe.AddShader(&tcs); |
| 9732 | pipe.AddShader(&tes); |
| 9733 | pipe.AddShader(&fs); |
| 9734 | |
| 9735 | VkDescriptorSetObj descriptorSet(m_device); |
| 9736 | descriptorSet.AppendDummy(); |
| 9737 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9738 | |
| 9739 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9740 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9741 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9742 | } |
| 9743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9744 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9745 | m_errorMonitor->SetDesiredFailureMsg( |
| 9746 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9747 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9748 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9751 | |
| 9752 | /* Two binding descriptions for binding 0 */ |
| 9753 | VkVertexInputBindingDescription input_bindings[2]; |
| 9754 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9755 | |
| 9756 | VkVertexInputAttributeDescription input_attrib; |
| 9757 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9758 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9759 | |
| 9760 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9761 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9762 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9763 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9764 | "out gl_PerVertex {\n" |
| 9765 | " vec4 gl_Position;\n" |
| 9766 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9767 | "void main(){\n" |
| 9768 | " gl_Position = vec4(x);\n" |
| 9769 | "}\n"; |
| 9770 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9771 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9772 | "\n" |
| 9773 | "layout(location=0) out vec4 color;\n" |
| 9774 | "void main(){\n" |
| 9775 | " color = vec4(1);\n" |
| 9776 | "}\n"; |
| 9777 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9778 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9779 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9780 | |
| 9781 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9782 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9783 | pipe.AddShader(&vs); |
| 9784 | pipe.AddShader(&fs); |
| 9785 | |
| 9786 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9787 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9788 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9789 | VkDescriptorSetObj descriptorSet(m_device); |
| 9790 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9791 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9792 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9793 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9794 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9795 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9796 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9797 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9798 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9799 | m_errorMonitor->ExpectSuccess(); |
| 9800 | |
| 9801 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9802 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9803 | |
| 9804 | if (!m_device->phy().features().tessellationShader) { |
| 9805 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9806 | return; |
| 9807 | } |
| 9808 | |
| 9809 | VkVertexInputBindingDescription input_bindings[1]; |
| 9810 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9811 | |
| 9812 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9813 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9814 | input_attribs[0].location = 0; |
| 9815 | input_attribs[0].offset = 0; |
| 9816 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9817 | input_attribs[1].location = 2; |
| 9818 | input_attribs[1].offset = 32; |
| 9819 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9820 | input_attribs[2].location = 4; |
| 9821 | input_attribs[2].offset = 64; |
| 9822 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9823 | input_attribs[3].location = 6; |
| 9824 | input_attribs[3].offset = 96; |
| 9825 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9826 | |
| 9827 | char const *vsSource = |
| 9828 | "#version 450\n" |
| 9829 | "\n" |
| 9830 | "layout(location=0) in dmat4 x;\n" |
| 9831 | "out gl_PerVertex {\n" |
| 9832 | " vec4 gl_Position;\n" |
| 9833 | "};\n" |
| 9834 | "void main(){\n" |
| 9835 | " gl_Position = vec4(x[0][0]);\n" |
| 9836 | "}\n"; |
| 9837 | char const *fsSource = |
| 9838 | "#version 450\n" |
| 9839 | "\n" |
| 9840 | "layout(location=0) out vec4 color;\n" |
| 9841 | "void main(){\n" |
| 9842 | " color = vec4(1);\n" |
| 9843 | "}\n"; |
| 9844 | |
| 9845 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9846 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9847 | |
| 9848 | VkPipelineObj pipe(m_device); |
| 9849 | pipe.AddColorAttachment(); |
| 9850 | pipe.AddShader(&vs); |
| 9851 | pipe.AddShader(&fs); |
| 9852 | |
| 9853 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9854 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9855 | |
| 9856 | VkDescriptorSetObj descriptorSet(m_device); |
| 9857 | descriptorSet.AppendDummy(); |
| 9858 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9859 | |
| 9860 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9861 | |
| 9862 | m_errorMonitor->VerifyNotFound(); |
| 9863 | } |
| 9864 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9865 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9866 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9867 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9868 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9870 | |
| 9871 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9872 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9873 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9874 | "out gl_PerVertex {\n" |
| 9875 | " vec4 gl_Position;\n" |
| 9876 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9877 | "void main(){\n" |
| 9878 | " gl_Position = vec4(1);\n" |
| 9879 | "}\n"; |
| 9880 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9881 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9882 | "\n" |
| 9883 | "void main(){\n" |
| 9884 | "}\n"; |
| 9885 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9886 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9887 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9888 | |
| 9889 | VkPipelineObj pipe(m_device); |
| 9890 | pipe.AddShader(&vs); |
| 9891 | pipe.AddShader(&fs); |
| 9892 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9893 | /* set up CB 0, not written */ |
| 9894 | pipe.AddColorAttachment(); |
| 9895 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9896 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9897 | VkDescriptorSetObj descriptorSet(m_device); |
| 9898 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9899 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9900 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9901 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9902 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9903 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9904 | } |
| 9905 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9906 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9907 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9908 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9909 | "FS writes to output location 1 with no matching attachment"); |
| 9910 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9911 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9912 | |
| 9913 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9914 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9915 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9916 | "out gl_PerVertex {\n" |
| 9917 | " vec4 gl_Position;\n" |
| 9918 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9919 | "void main(){\n" |
| 9920 | " gl_Position = vec4(1);\n" |
| 9921 | "}\n"; |
| 9922 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9923 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9924 | "\n" |
| 9925 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9926 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9927 | "void main(){\n" |
| 9928 | " x = vec4(1);\n" |
| 9929 | " y = vec4(1);\n" |
| 9930 | "}\n"; |
| 9931 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9932 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9933 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9934 | |
| 9935 | VkPipelineObj pipe(m_device); |
| 9936 | pipe.AddShader(&vs); |
| 9937 | pipe.AddShader(&fs); |
| 9938 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9939 | /* set up CB 0, not written */ |
| 9940 | pipe.AddColorAttachment(); |
| 9941 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9942 | /* FS writes CB 1, but we don't configure it */ |
| 9943 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9944 | VkDescriptorSetObj descriptorSet(m_device); |
| 9945 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9946 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9947 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9948 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9949 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9950 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9951 | } |
| 9952 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9953 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9954 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9955 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9956 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9957 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9958 | |
| 9959 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9960 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9961 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9962 | "out gl_PerVertex {\n" |
| 9963 | " vec4 gl_Position;\n" |
| 9964 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9965 | "void main(){\n" |
| 9966 | " gl_Position = vec4(1);\n" |
| 9967 | "}\n"; |
| 9968 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9969 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9970 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9971 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9972 | "void main(){\n" |
| 9973 | " x = ivec4(1);\n" |
| 9974 | "}\n"; |
| 9975 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9976 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9977 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9978 | |
| 9979 | VkPipelineObj pipe(m_device); |
| 9980 | pipe.AddShader(&vs); |
| 9981 | pipe.AddShader(&fs); |
| 9982 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9983 | /* set up CB 0; type is UNORM by default */ |
| 9984 | pipe.AddColorAttachment(); |
| 9985 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9986 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9987 | VkDescriptorSetObj descriptorSet(m_device); |
| 9988 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9989 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9990 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9991 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9992 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9993 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9994 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9996 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9998 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9999 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10001 | |
| 10002 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10003 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10004 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10005 | "out gl_PerVertex {\n" |
| 10006 | " vec4 gl_Position;\n" |
| 10007 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10008 | "void main(){\n" |
| 10009 | " gl_Position = vec4(1);\n" |
| 10010 | "}\n"; |
| 10011 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10012 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10013 | "\n" |
| 10014 | "layout(location=0) out vec4 x;\n" |
| 10015 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10016 | "void main(){\n" |
| 10017 | " x = vec4(bar.y);\n" |
| 10018 | "}\n"; |
| 10019 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10020 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10021 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10022 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10023 | VkPipelineObj pipe(m_device); |
| 10024 | pipe.AddShader(&vs); |
| 10025 | pipe.AddShader(&fs); |
| 10026 | |
| 10027 | /* set up CB 0; type is UNORM by default */ |
| 10028 | pipe.AddColorAttachment(); |
| 10029 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10030 | |
| 10031 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10032 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10033 | |
| 10034 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10035 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10036 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10037 | } |
| 10038 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10039 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10040 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10041 | "not declared in layout"); |
| 10042 | |
| 10043 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10044 | |
| 10045 | char const *vsSource = |
| 10046 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10047 | "\n" |
| 10048 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10049 | "out gl_PerVertex {\n" |
| 10050 | " vec4 gl_Position;\n" |
| 10051 | "};\n" |
| 10052 | "void main(){\n" |
| 10053 | " gl_Position = vec4(consts.x);\n" |
| 10054 | "}\n"; |
| 10055 | char const *fsSource = |
| 10056 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10057 | "\n" |
| 10058 | "layout(location=0) out vec4 x;\n" |
| 10059 | "void main(){\n" |
| 10060 | " x = vec4(1);\n" |
| 10061 | "}\n"; |
| 10062 | |
| 10063 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10064 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10065 | |
| 10066 | VkPipelineObj pipe(m_device); |
| 10067 | pipe.AddShader(&vs); |
| 10068 | pipe.AddShader(&fs); |
| 10069 | |
| 10070 | /* set up CB 0; type is UNORM by default */ |
| 10071 | pipe.AddColorAttachment(); |
| 10072 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10073 | |
| 10074 | VkDescriptorSetObj descriptorSet(m_device); |
| 10075 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10076 | |
| 10077 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10078 | |
| 10079 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10080 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10081 | } |
| 10082 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10083 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10084 | m_errorMonitor->SetDesiredFailureMsg( |
| 10085 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10086 | "Shader uses descriptor slot 0.0"); |
| 10087 | |
| 10088 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10089 | |
| 10090 | char const *csSource = |
| 10091 | "#version 450\n" |
| 10092 | "\n" |
| 10093 | "layout(local_size_x=1) in;\n" |
| 10094 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10095 | "void main(){\n" |
| 10096 | " x = vec4(1);\n" |
| 10097 | "}\n"; |
| 10098 | |
| 10099 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10100 | |
| 10101 | VkDescriptorSetObj descriptorSet(m_device); |
| 10102 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10103 | |
| 10104 | VkComputePipelineCreateInfo cpci = { |
| 10105 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10106 | nullptr, 0, { |
| 10107 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10108 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10109 | cs.handle(), "main", nullptr |
| 10110 | }, |
| 10111 | descriptorSet.GetPipelineLayout(), |
| 10112 | VK_NULL_HANDLE, -1 |
| 10113 | }; |
| 10114 | |
| 10115 | VkPipeline pipe; |
| 10116 | VkResult err = vkCreateComputePipelines( |
| 10117 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10118 | |
| 10119 | m_errorMonitor->VerifyFound(); |
| 10120 | |
| 10121 | if (err == VK_SUCCESS) { |
| 10122 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10123 | } |
| 10124 | } |
| 10125 | |
| 10126 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10127 | m_errorMonitor->ExpectSuccess(); |
| 10128 | |
| 10129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10130 | |
| 10131 | char const *csSource = |
| 10132 | "#version 450\n" |
| 10133 | "\n" |
| 10134 | "layout(local_size_x=1) in;\n" |
| 10135 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10136 | "void main(){\n" |
| 10137 | " // x is not used.\n" |
| 10138 | "}\n"; |
| 10139 | |
| 10140 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10141 | |
| 10142 | VkDescriptorSetObj descriptorSet(m_device); |
| 10143 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10144 | |
| 10145 | VkComputePipelineCreateInfo cpci = { |
| 10146 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10147 | nullptr, 0, { |
| 10148 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10149 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10150 | cs.handle(), "main", nullptr |
| 10151 | }, |
| 10152 | descriptorSet.GetPipelineLayout(), |
| 10153 | VK_NULL_HANDLE, -1 |
| 10154 | }; |
| 10155 | |
| 10156 | VkPipeline pipe; |
| 10157 | VkResult err = vkCreateComputePipelines( |
| 10158 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10159 | |
| 10160 | m_errorMonitor->VerifyNotFound(); |
| 10161 | |
| 10162 | if (err == VK_SUCCESS) { |
| 10163 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10164 | } |
| 10165 | } |
| 10166 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10167 | #endif // SHADER_CHECKER_TESTS |
| 10168 | |
| 10169 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10170 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10171 | m_errorMonitor->SetDesiredFailureMsg( |
| 10172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10173 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10174 | |
| 10175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10176 | |
| 10177 | // Create an image |
| 10178 | VkImage image; |
| 10179 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10180 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10181 | const int32_t tex_width = 32; |
| 10182 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10183 | |
| 10184 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10185 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10186 | image_create_info.pNext = NULL; |
| 10187 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10188 | image_create_info.format = tex_format; |
| 10189 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10190 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10191 | image_create_info.extent.depth = 1; |
| 10192 | image_create_info.mipLevels = 1; |
| 10193 | image_create_info.arrayLayers = 1; |
| 10194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10195 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10196 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10197 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10198 | |
| 10199 | // Introduce error by sending down a bogus width extent |
| 10200 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10201 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10202 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10203 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10204 | } |
| 10205 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10206 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10207 | m_errorMonitor->SetDesiredFailureMsg( |
| 10208 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10209 | "CreateImage extents is 0 for at least one required dimension"); |
| 10210 | |
| 10211 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10212 | |
| 10213 | // Create an image |
| 10214 | VkImage image; |
| 10215 | |
| 10216 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10217 | const int32_t tex_width = 32; |
| 10218 | const int32_t tex_height = 32; |
| 10219 | |
| 10220 | VkImageCreateInfo image_create_info = {}; |
| 10221 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10222 | image_create_info.pNext = NULL; |
| 10223 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10224 | image_create_info.format = tex_format; |
| 10225 | image_create_info.extent.width = tex_width; |
| 10226 | image_create_info.extent.height = tex_height; |
| 10227 | image_create_info.extent.depth = 1; |
| 10228 | image_create_info.mipLevels = 1; |
| 10229 | image_create_info.arrayLayers = 1; |
| 10230 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10231 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10232 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10233 | image_create_info.flags = 0; |
| 10234 | |
| 10235 | // Introduce error by sending down a bogus width extent |
| 10236 | image_create_info.extent.width = 0; |
| 10237 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10238 | |
| 10239 | m_errorMonitor->VerifyFound(); |
| 10240 | } |
| 10241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10242 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 10243 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10244 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10245 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10246 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10247 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10248 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10249 | |
| 10250 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10251 | vk_testing::Buffer buffer; |
| 10252 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10253 | |
| 10254 | BeginCommandBuffer(); |
| 10255 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10256 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10257 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10258 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10259 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10260 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10261 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10262 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10263 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10264 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10265 | EndCommandBuffer(); |
| 10266 | } |
| 10267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10268 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10269 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10270 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10271 | |
| 10272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10273 | |
| 10274 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10275 | vk_testing::Buffer buffer; |
| 10276 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10277 | |
| 10278 | BeginCommandBuffer(); |
| 10279 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10280 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10281 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10282 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10283 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10285 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10286 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10287 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10288 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10289 | m_errorMonitor->VerifyFound(); |
| 10290 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10291 | EndCommandBuffer(); |
| 10292 | } |
| 10293 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10294 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10295 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10296 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10297 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10298 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10300 | m_errorMonitor->SetDesiredFailureMsg( |
| 10301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10302 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10303 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10305 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10306 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10307 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10309 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10310 | const int32_t tex_width = 32; |
| 10311 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10312 | |
| 10313 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10314 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10315 | image_create_info.pNext = NULL; |
| 10316 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10317 | image_create_info.format = tex_format; |
| 10318 | image_create_info.extent.width = tex_width; |
| 10319 | image_create_info.extent.height = tex_height; |
| 10320 | image_create_info.extent.depth = 1; |
| 10321 | image_create_info.mipLevels = 1; |
| 10322 | image_create_info.arrayLayers = 1; |
| 10323 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10324 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10325 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10326 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10327 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10328 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10329 | ASSERT_VK_SUCCESS(err); |
| 10330 | |
| 10331 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10332 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10333 | image_view_create_info.image = image; |
| 10334 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10335 | image_view_create_info.format = tex_format; |
| 10336 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10337 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10338 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10339 | image_view_create_info.subresourceRange.aspectMask = |
| 10340 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10341 | |
| 10342 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10343 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10344 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10345 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10346 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10347 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10349 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10350 | TEST_DESCRIPTION( |
| 10351 | "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] | 10352 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10353 | "vkCreateImageView: Color image " |
| 10354 | "formats must have ONLY the " |
| 10355 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10356 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10357 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10358 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10359 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10360 | VkImageObj image(m_device); |
| 10361 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10362 | VK_IMAGE_TILING_LINEAR, 0); |
| 10363 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10364 | |
| 10365 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10366 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10367 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10368 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10369 | image_view_create_info.format = tex_format; |
| 10370 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10371 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10372 | // Cause an error by setting an invalid image aspect |
| 10373 | image_view_create_info.subresourceRange.aspectMask = |
| 10374 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10375 | |
| 10376 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10377 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10378 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10379 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10380 | } |
| 10381 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10382 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10383 | VkResult err; |
| 10384 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10386 | m_errorMonitor->SetDesiredFailureMsg( |
| 10387 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10388 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10389 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10390 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10391 | |
| 10392 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10393 | VkImage srcImage; |
| 10394 | VkImage dstImage; |
| 10395 | VkDeviceMemory srcMem; |
| 10396 | VkDeviceMemory destMem; |
| 10397 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10398 | |
| 10399 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10400 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10401 | image_create_info.pNext = NULL; |
| 10402 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10403 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10404 | image_create_info.extent.width = 32; |
| 10405 | image_create_info.extent.height = 32; |
| 10406 | image_create_info.extent.depth = 1; |
| 10407 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10408 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10409 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10410 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10411 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10412 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10414 | err = |
| 10415 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10416 | ASSERT_VK_SUCCESS(err); |
| 10417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10418 | err = |
| 10419 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10420 | ASSERT_VK_SUCCESS(err); |
| 10421 | |
| 10422 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10423 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10424 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10425 | memAlloc.pNext = NULL; |
| 10426 | memAlloc.allocationSize = 0; |
| 10427 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10428 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10429 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10430 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10431 | pass = |
| 10432 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10433 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10434 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10435 | ASSERT_VK_SUCCESS(err); |
| 10436 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10437 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10438 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10439 | pass = |
| 10440 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10441 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10442 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10443 | ASSERT_VK_SUCCESS(err); |
| 10444 | |
| 10445 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10446 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10447 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10448 | ASSERT_VK_SUCCESS(err); |
| 10449 | |
| 10450 | BeginCommandBuffer(); |
| 10451 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10452 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10453 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10454 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10455 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10456 | copyRegion.srcOffset.x = 0; |
| 10457 | copyRegion.srcOffset.y = 0; |
| 10458 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10459 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10460 | copyRegion.dstSubresource.mipLevel = 0; |
| 10461 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10462 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10463 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10464 | copyRegion.dstOffset.x = 0; |
| 10465 | copyRegion.dstOffset.y = 0; |
| 10466 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10467 | copyRegion.extent.width = 1; |
| 10468 | copyRegion.extent.height = 1; |
| 10469 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10470 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10471 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10472 | EndCommandBuffer(); |
| 10473 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10474 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10475 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10476 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10477 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10478 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10479 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10480 | } |
| 10481 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10482 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10483 | |
| 10484 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10485 | |
| 10486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10488 | VkImageObj image(m_device); |
| 10489 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10490 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10491 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10492 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10493 | ASSERT_TRUE(image.initialized()); |
| 10494 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10495 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10496 | VkImageCreateInfo image_create_info; |
| 10497 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10498 | image_create_info.pNext = NULL; |
| 10499 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10500 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10501 | image_create_info.extent.width = 32; |
| 10502 | image_create_info.extent.height = 32; |
| 10503 | image_create_info.extent.depth = 1; |
| 10504 | image_create_info.mipLevels = 1; |
| 10505 | image_create_info.arrayLayers = 1; |
| 10506 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10507 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10508 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10509 | image_create_info.flags = 0; |
| 10510 | |
| 10511 | m_errorMonitor->SetDesiredFailureMsg( |
| 10512 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10513 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10514 | |
| 10515 | VkImage localImage; |
| 10516 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10517 | m_errorMonitor->VerifyFound(); |
| 10518 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10519 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10520 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10521 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10522 | VkFormat format = static_cast<VkFormat>(f); |
| 10523 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10524 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10525 | fProps.optimalTilingFeatures == 0) { |
| 10526 | unsupported = format; |
| 10527 | break; |
| 10528 | } |
| 10529 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10530 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10531 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10532 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10533 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10534 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10535 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10536 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10537 | m_errorMonitor->VerifyFound(); |
| 10538 | } |
| 10539 | } |
| 10540 | |
| 10541 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10542 | VkResult ret; |
| 10543 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10544 | |
| 10545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10546 | |
| 10547 | VkImageObj image(m_device); |
| 10548 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10549 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10550 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10551 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10552 | ASSERT_TRUE(image.initialized()); |
| 10553 | |
| 10554 | VkImageView imgView; |
| 10555 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10556 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10557 | imgViewInfo.image = image.handle(); |
| 10558 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10559 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10560 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10561 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10562 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10563 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10564 | |
| 10565 | m_errorMonitor->SetDesiredFailureMsg( |
| 10566 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10567 | "vkCreateImageView called with baseMipLevel"); |
| 10568 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10569 | // VIEW_CREATE_ERROR |
| 10570 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10571 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10572 | m_errorMonitor->VerifyFound(); |
| 10573 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10574 | |
| 10575 | m_errorMonitor->SetDesiredFailureMsg( |
| 10576 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10577 | "vkCreateImageView called with baseArrayLayer"); |
| 10578 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10579 | // VIEW_CREATE_ERROR |
| 10580 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10581 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10582 | m_errorMonitor->VerifyFound(); |
| 10583 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10584 | |
| 10585 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10586 | "vkCreateImageView called with 0 in " |
| 10587 | "pCreateInfo->subresourceRange." |
| 10588 | "levelCount"); |
| 10589 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10590 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10591 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10592 | m_errorMonitor->VerifyFound(); |
| 10593 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10594 | |
| 10595 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10596 | "vkCreateImageView called with 0 in " |
| 10597 | "pCreateInfo->subresourceRange." |
| 10598 | "layerCount"); |
| 10599 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10600 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10601 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10602 | m_errorMonitor->VerifyFound(); |
| 10603 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10604 | |
| 10605 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10606 | "but both must be color formats"); |
| 10607 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10608 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10609 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10610 | m_errorMonitor->VerifyFound(); |
| 10611 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10612 | |
| 10613 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10614 | "Formats MUST be IDENTICAL unless " |
| 10615 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10616 | "was set on image creation."); |
| 10617 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10618 | // VIEW_CREATE_ERROR |
| 10619 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10620 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10621 | m_errorMonitor->VerifyFound(); |
| 10622 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10623 | |
| 10624 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10625 | "can support ImageViews with " |
| 10626 | "differing formats but they must be " |
| 10627 | "in the same compatibility class."); |
| 10628 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10629 | // VIEW_CREATE_ERROR |
| 10630 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10631 | VkImage mutImage; |
| 10632 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10633 | assert( |
| 10634 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10635 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10636 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10637 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10638 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10639 | ASSERT_VK_SUCCESS(ret); |
| 10640 | imgViewInfo.image = mutImage; |
| 10641 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10642 | m_errorMonitor->VerifyFound(); |
| 10643 | imgViewInfo.image = image.handle(); |
| 10644 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10645 | } |
| 10646 | |
| 10647 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10648 | |
| 10649 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10650 | |
| 10651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10652 | |
| 10653 | VkImageObj image(m_device); |
| 10654 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10655 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10656 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10657 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10658 | ASSERT_TRUE(image.initialized()); |
| 10659 | |
| 10660 | m_errorMonitor->SetDesiredFailureMsg( |
| 10661 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10662 | "number of layers in image subresource is zero"); |
| 10663 | vk_testing::Buffer buffer; |
| 10664 | VkMemoryPropertyFlags reqs = 0; |
| 10665 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10666 | VkBufferImageCopy region = {}; |
| 10667 | region.bufferRowLength = 128; |
| 10668 | region.bufferImageHeight = 128; |
| 10669 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10670 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10671 | region.imageSubresource.layerCount = 0; |
| 10672 | region.imageExtent.height = 4; |
| 10673 | region.imageExtent.width = 4; |
| 10674 | region.imageExtent.depth = 1; |
| 10675 | m_commandBuffer->BeginCommandBuffer(); |
| 10676 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10677 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10678 | 1, ®ion); |
| 10679 | m_errorMonitor->VerifyFound(); |
| 10680 | region.imageSubresource.layerCount = 1; |
| 10681 | |
| 10682 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10683 | "aspectMasks for each region must " |
| 10684 | "specify only COLOR or DEPTH or " |
| 10685 | "STENCIL"); |
| 10686 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10687 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10688 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10689 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10690 | 1, ®ion); |
| 10691 | m_errorMonitor->VerifyFound(); |
| 10692 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10693 | |
| 10694 | m_errorMonitor->SetDesiredFailureMsg( |
| 10695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10696 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10697 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10698 | // Expect INVALID_FILTER |
| 10699 | VkImageObj intImage1(m_device); |
| 10700 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10701 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10702 | 0); |
| 10703 | VkImageObj intImage2(m_device); |
| 10704 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10705 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10706 | 0); |
| 10707 | VkImageBlit blitRegion = {}; |
| 10708 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10709 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10710 | blitRegion.srcSubresource.layerCount = 1; |
| 10711 | blitRegion.srcSubresource.mipLevel = 0; |
| 10712 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10713 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10714 | blitRegion.dstSubresource.layerCount = 1; |
| 10715 | blitRegion.dstSubresource.mipLevel = 0; |
| 10716 | |
| 10717 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10718 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10719 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10720 | m_errorMonitor->VerifyFound(); |
| 10721 | |
| 10722 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10723 | "called with 0 in ppMemoryBarriers"); |
| 10724 | VkImageMemoryBarrier img_barrier; |
| 10725 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10726 | img_barrier.pNext = NULL; |
| 10727 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10728 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10729 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10730 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10731 | img_barrier.image = image.handle(); |
| 10732 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10733 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10734 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10735 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10736 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10737 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10738 | img_barrier.subresourceRange.layerCount = 0; |
| 10739 | img_barrier.subresourceRange.levelCount = 1; |
| 10740 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10741 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10742 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10743 | nullptr, 1, &img_barrier); |
| 10744 | m_errorMonitor->VerifyFound(); |
| 10745 | img_barrier.subresourceRange.layerCount = 1; |
| 10746 | } |
| 10747 | |
| 10748 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10749 | |
| 10750 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10751 | |
| 10752 | m_errorMonitor->SetDesiredFailureMsg( |
| 10753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10754 | "CreateImage extents exceed allowable limits for format"); |
| 10755 | VkImageCreateInfo image_create_info = {}; |
| 10756 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10757 | image_create_info.pNext = NULL; |
| 10758 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10759 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10760 | image_create_info.extent.width = 32; |
| 10761 | image_create_info.extent.height = 32; |
| 10762 | image_create_info.extent.depth = 1; |
| 10763 | image_create_info.mipLevels = 1; |
| 10764 | image_create_info.arrayLayers = 1; |
| 10765 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10766 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10767 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10768 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10769 | image_create_info.flags = 0; |
| 10770 | |
| 10771 | VkImage nullImg; |
| 10772 | VkImageFormatProperties imgFmtProps; |
| 10773 | vkGetPhysicalDeviceImageFormatProperties( |
| 10774 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10775 | image_create_info.tiling, image_create_info.usage, |
| 10776 | image_create_info.flags, &imgFmtProps); |
| 10777 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10778 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10779 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10780 | m_errorMonitor->VerifyFound(); |
| 10781 | image_create_info.extent.depth = 1; |
| 10782 | |
| 10783 | m_errorMonitor->SetDesiredFailureMsg( |
| 10784 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10785 | "exceeds allowable maximum supported by format of"); |
| 10786 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10787 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10788 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10789 | m_errorMonitor->VerifyFound(); |
| 10790 | image_create_info.mipLevels = 1; |
| 10791 | |
| 10792 | m_errorMonitor->SetDesiredFailureMsg( |
| 10793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10794 | "exceeds allowable maximum supported by format of"); |
| 10795 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10796 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10797 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10798 | m_errorMonitor->VerifyFound(); |
| 10799 | image_create_info.arrayLayers = 1; |
| 10800 | |
| 10801 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10802 | "is not supported by format"); |
| 10803 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10804 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10805 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10806 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10807 | m_errorMonitor->VerifyFound(); |
| 10808 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10809 | |
| 10810 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10811 | "pCreateInfo->initialLayout, must be " |
| 10812 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10813 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10814 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10815 | // Expect INVALID_LAYOUT |
| 10816 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10817 | m_errorMonitor->VerifyFound(); |
| 10818 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10819 | } |
| 10820 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10821 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10822 | VkResult err; |
| 10823 | bool pass; |
| 10824 | |
| 10825 | // Create color images with different format sizes and try to copy between them |
| 10826 | m_errorMonitor->SetDesiredFailureMsg( |
| 10827 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10828 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10829 | |
| 10830 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10831 | |
| 10832 | // Create two images of different types and try to copy between them |
| 10833 | VkImage srcImage; |
| 10834 | VkImage dstImage; |
| 10835 | VkDeviceMemory srcMem; |
| 10836 | VkDeviceMemory destMem; |
| 10837 | VkMemoryRequirements memReqs; |
| 10838 | |
| 10839 | VkImageCreateInfo image_create_info = {}; |
| 10840 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10841 | image_create_info.pNext = NULL; |
| 10842 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10843 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10844 | image_create_info.extent.width = 32; |
| 10845 | image_create_info.extent.height = 32; |
| 10846 | image_create_info.extent.depth = 1; |
| 10847 | image_create_info.mipLevels = 1; |
| 10848 | image_create_info.arrayLayers = 1; |
| 10849 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10850 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10851 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10852 | image_create_info.flags = 0; |
| 10853 | |
| 10854 | err = |
| 10855 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10856 | ASSERT_VK_SUCCESS(err); |
| 10857 | |
| 10858 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10859 | // Introduce failure by creating second image with a different-sized format. |
| 10860 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10861 | |
| 10862 | err = |
| 10863 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10864 | ASSERT_VK_SUCCESS(err); |
| 10865 | |
| 10866 | // Allocate memory |
| 10867 | VkMemoryAllocateInfo memAlloc = {}; |
| 10868 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10869 | memAlloc.pNext = NULL; |
| 10870 | memAlloc.allocationSize = 0; |
| 10871 | memAlloc.memoryTypeIndex = 0; |
| 10872 | |
| 10873 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10874 | memAlloc.allocationSize = memReqs.size; |
| 10875 | pass = |
| 10876 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10877 | ASSERT_TRUE(pass); |
| 10878 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10879 | ASSERT_VK_SUCCESS(err); |
| 10880 | |
| 10881 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10882 | memAlloc.allocationSize = memReqs.size; |
| 10883 | pass = |
| 10884 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10885 | ASSERT_TRUE(pass); |
| 10886 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10887 | ASSERT_VK_SUCCESS(err); |
| 10888 | |
| 10889 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10890 | ASSERT_VK_SUCCESS(err); |
| 10891 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10892 | ASSERT_VK_SUCCESS(err); |
| 10893 | |
| 10894 | BeginCommandBuffer(); |
| 10895 | VkImageCopy copyRegion; |
| 10896 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10897 | copyRegion.srcSubresource.mipLevel = 0; |
| 10898 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10899 | copyRegion.srcSubresource.layerCount = 0; |
| 10900 | copyRegion.srcOffset.x = 0; |
| 10901 | copyRegion.srcOffset.y = 0; |
| 10902 | copyRegion.srcOffset.z = 0; |
| 10903 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10904 | copyRegion.dstSubresource.mipLevel = 0; |
| 10905 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10906 | copyRegion.dstSubresource.layerCount = 0; |
| 10907 | copyRegion.dstOffset.x = 0; |
| 10908 | copyRegion.dstOffset.y = 0; |
| 10909 | copyRegion.dstOffset.z = 0; |
| 10910 | copyRegion.extent.width = 1; |
| 10911 | copyRegion.extent.height = 1; |
| 10912 | copyRegion.extent.depth = 1; |
| 10913 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10914 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10915 | EndCommandBuffer(); |
| 10916 | |
| 10917 | m_errorMonitor->VerifyFound(); |
| 10918 | |
| 10919 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10920 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10921 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10922 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10923 | } |
| 10924 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10925 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10926 | VkResult err; |
| 10927 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10928 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10929 | // 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] | 10930 | m_errorMonitor->SetDesiredFailureMsg( |
| 10931 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10932 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10933 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10935 | |
| 10936 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10937 | VkImage srcImage; |
| 10938 | VkImage dstImage; |
| 10939 | VkDeviceMemory srcMem; |
| 10940 | VkDeviceMemory destMem; |
| 10941 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10942 | |
| 10943 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10944 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10945 | image_create_info.pNext = NULL; |
| 10946 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10947 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10948 | image_create_info.extent.width = 32; |
| 10949 | image_create_info.extent.height = 32; |
| 10950 | image_create_info.extent.depth = 1; |
| 10951 | image_create_info.mipLevels = 1; |
| 10952 | image_create_info.arrayLayers = 1; |
| 10953 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10954 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10955 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10956 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10957 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10958 | err = |
| 10959 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10960 | ASSERT_VK_SUCCESS(err); |
| 10961 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10962 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10963 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10964 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10965 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10966 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10967 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10968 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10969 | err = |
| 10970 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10971 | ASSERT_VK_SUCCESS(err); |
| 10972 | |
| 10973 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10974 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10975 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10976 | memAlloc.pNext = NULL; |
| 10977 | memAlloc.allocationSize = 0; |
| 10978 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10979 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10980 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10981 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10982 | pass = |
| 10983 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10984 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10985 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10986 | ASSERT_VK_SUCCESS(err); |
| 10987 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10988 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10989 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10990 | pass = |
| 10991 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10992 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10993 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10994 | ASSERT_VK_SUCCESS(err); |
| 10995 | |
| 10996 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10997 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10998 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10999 | ASSERT_VK_SUCCESS(err); |
| 11000 | |
| 11001 | BeginCommandBuffer(); |
| 11002 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11003 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11004 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11005 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11006 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11007 | copyRegion.srcOffset.x = 0; |
| 11008 | copyRegion.srcOffset.y = 0; |
| 11009 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11010 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11011 | copyRegion.dstSubresource.mipLevel = 0; |
| 11012 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11013 | copyRegion.dstSubresource.layerCount = 0; |
| 11014 | copyRegion.dstOffset.x = 0; |
| 11015 | copyRegion.dstOffset.y = 0; |
| 11016 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11017 | copyRegion.extent.width = 1; |
| 11018 | copyRegion.extent.height = 1; |
| 11019 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11020 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11021 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11022 | EndCommandBuffer(); |
| 11023 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11024 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11025 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11026 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11027 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11028 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11029 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11030 | } |
| 11031 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11032 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11033 | VkResult err; |
| 11034 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11036 | m_errorMonitor->SetDesiredFailureMsg( |
| 11037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11038 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11039 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11040 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11041 | |
| 11042 | // 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] | 11043 | VkImage srcImage; |
| 11044 | VkImage dstImage; |
| 11045 | VkDeviceMemory srcMem; |
| 11046 | VkDeviceMemory destMem; |
| 11047 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11048 | |
| 11049 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11050 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11051 | image_create_info.pNext = NULL; |
| 11052 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11053 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11054 | image_create_info.extent.width = 32; |
| 11055 | image_create_info.extent.height = 1; |
| 11056 | image_create_info.extent.depth = 1; |
| 11057 | image_create_info.mipLevels = 1; |
| 11058 | image_create_info.arrayLayers = 1; |
| 11059 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11060 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11061 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11062 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11063 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11064 | err = |
| 11065 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11066 | ASSERT_VK_SUCCESS(err); |
| 11067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11068 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11069 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11070 | err = |
| 11071 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11072 | ASSERT_VK_SUCCESS(err); |
| 11073 | |
| 11074 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11075 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11076 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11077 | memAlloc.pNext = NULL; |
| 11078 | memAlloc.allocationSize = 0; |
| 11079 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11080 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11081 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11082 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11083 | pass = |
| 11084 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11085 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11086 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11087 | ASSERT_VK_SUCCESS(err); |
| 11088 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11089 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11090 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11091 | pass = |
| 11092 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11093 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11094 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11095 | ASSERT_VK_SUCCESS(err); |
| 11096 | |
| 11097 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11098 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11099 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11100 | ASSERT_VK_SUCCESS(err); |
| 11101 | |
| 11102 | BeginCommandBuffer(); |
| 11103 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11104 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11105 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11106 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11107 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11108 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11109 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11110 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11111 | resolveRegion.srcOffset.x = 0; |
| 11112 | resolveRegion.srcOffset.y = 0; |
| 11113 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11114 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11115 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11116 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11117 | resolveRegion.dstSubresource.layerCount = 0; |
| 11118 | resolveRegion.dstOffset.x = 0; |
| 11119 | resolveRegion.dstOffset.y = 0; |
| 11120 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11121 | resolveRegion.extent.width = 1; |
| 11122 | resolveRegion.extent.height = 1; |
| 11123 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11124 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11125 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11126 | EndCommandBuffer(); |
| 11127 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11128 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11130 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11131 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11132 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11133 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11134 | } |
| 11135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11136 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11137 | VkResult err; |
| 11138 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11140 | m_errorMonitor->SetDesiredFailureMsg( |
| 11141 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11142 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11143 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11145 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11146 | // 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] | 11147 | VkImage srcImage; |
| 11148 | VkImage dstImage; |
| 11149 | VkDeviceMemory srcMem; |
| 11150 | VkDeviceMemory destMem; |
| 11151 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11152 | |
| 11153 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11154 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11155 | image_create_info.pNext = NULL; |
| 11156 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11157 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11158 | image_create_info.extent.width = 32; |
| 11159 | image_create_info.extent.height = 1; |
| 11160 | image_create_info.extent.depth = 1; |
| 11161 | image_create_info.mipLevels = 1; |
| 11162 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11163 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11164 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11165 | // Note: Some implementations expect color attachment usage for any |
| 11166 | // multisample surface |
| 11167 | image_create_info.usage = |
| 11168 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11169 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11170 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11171 | err = |
| 11172 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11173 | ASSERT_VK_SUCCESS(err); |
| 11174 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11175 | // Note: Some implementations expect color attachment usage for any |
| 11176 | // multisample surface |
| 11177 | image_create_info.usage = |
| 11178 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11179 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11180 | err = |
| 11181 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11182 | ASSERT_VK_SUCCESS(err); |
| 11183 | |
| 11184 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11185 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11186 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11187 | memAlloc.pNext = NULL; |
| 11188 | memAlloc.allocationSize = 0; |
| 11189 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11190 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11191 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11192 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11193 | pass = |
| 11194 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11195 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11196 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11197 | ASSERT_VK_SUCCESS(err); |
| 11198 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11199 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11200 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11201 | pass = |
| 11202 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11203 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11204 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11205 | ASSERT_VK_SUCCESS(err); |
| 11206 | |
| 11207 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11208 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11209 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11210 | ASSERT_VK_SUCCESS(err); |
| 11211 | |
| 11212 | BeginCommandBuffer(); |
| 11213 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11214 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11215 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11216 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11217 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11218 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11219 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11220 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11221 | resolveRegion.srcOffset.x = 0; |
| 11222 | resolveRegion.srcOffset.y = 0; |
| 11223 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11224 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11225 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11226 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11227 | resolveRegion.dstSubresource.layerCount = 0; |
| 11228 | resolveRegion.dstOffset.x = 0; |
| 11229 | resolveRegion.dstOffset.y = 0; |
| 11230 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11231 | resolveRegion.extent.width = 1; |
| 11232 | resolveRegion.extent.height = 1; |
| 11233 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11234 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11235 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11236 | EndCommandBuffer(); |
| 11237 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11238 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11239 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11240 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11241 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11242 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11243 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11244 | } |
| 11245 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11246 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11247 | VkResult err; |
| 11248 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11249 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11250 | m_errorMonitor->SetDesiredFailureMsg( |
| 11251 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11252 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11253 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11254 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11255 | |
| 11256 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11257 | VkImage srcImage; |
| 11258 | VkImage dstImage; |
| 11259 | VkDeviceMemory srcMem; |
| 11260 | VkDeviceMemory destMem; |
| 11261 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11262 | |
| 11263 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11264 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11265 | image_create_info.pNext = NULL; |
| 11266 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11267 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11268 | image_create_info.extent.width = 32; |
| 11269 | image_create_info.extent.height = 1; |
| 11270 | image_create_info.extent.depth = 1; |
| 11271 | image_create_info.mipLevels = 1; |
| 11272 | image_create_info.arrayLayers = 1; |
| 11273 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11274 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11275 | // Note: Some implementations expect color attachment usage for any |
| 11276 | // multisample surface |
| 11277 | image_create_info.usage = |
| 11278 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11279 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11281 | err = |
| 11282 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11283 | ASSERT_VK_SUCCESS(err); |
| 11284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11285 | // Set format to something other than source image |
| 11286 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11287 | // Note: Some implementations expect color attachment usage for any |
| 11288 | // multisample surface |
| 11289 | image_create_info.usage = |
| 11290 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11291 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11293 | err = |
| 11294 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11295 | ASSERT_VK_SUCCESS(err); |
| 11296 | |
| 11297 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11298 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11299 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11300 | memAlloc.pNext = NULL; |
| 11301 | memAlloc.allocationSize = 0; |
| 11302 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11303 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11304 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11305 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11306 | pass = |
| 11307 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11308 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11309 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11310 | ASSERT_VK_SUCCESS(err); |
| 11311 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11312 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11313 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11314 | pass = |
| 11315 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11316 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11317 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11318 | ASSERT_VK_SUCCESS(err); |
| 11319 | |
| 11320 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11321 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11322 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11323 | ASSERT_VK_SUCCESS(err); |
| 11324 | |
| 11325 | BeginCommandBuffer(); |
| 11326 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11327 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11328 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11329 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11330 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11331 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11332 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11333 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11334 | resolveRegion.srcOffset.x = 0; |
| 11335 | resolveRegion.srcOffset.y = 0; |
| 11336 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11337 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11338 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11339 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11340 | resolveRegion.dstSubresource.layerCount = 0; |
| 11341 | resolveRegion.dstOffset.x = 0; |
| 11342 | resolveRegion.dstOffset.y = 0; |
| 11343 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11344 | resolveRegion.extent.width = 1; |
| 11345 | resolveRegion.extent.height = 1; |
| 11346 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11347 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11348 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11349 | EndCommandBuffer(); |
| 11350 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11351 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11352 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11353 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11354 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11355 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11356 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11357 | } |
| 11358 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11359 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11360 | VkResult err; |
| 11361 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11362 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11363 | m_errorMonitor->SetDesiredFailureMsg( |
| 11364 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11365 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11366 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11367 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11368 | |
| 11369 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11370 | VkImage srcImage; |
| 11371 | VkImage dstImage; |
| 11372 | VkDeviceMemory srcMem; |
| 11373 | VkDeviceMemory destMem; |
| 11374 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11375 | |
| 11376 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11377 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11378 | image_create_info.pNext = NULL; |
| 11379 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11380 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11381 | image_create_info.extent.width = 32; |
| 11382 | image_create_info.extent.height = 1; |
| 11383 | image_create_info.extent.depth = 1; |
| 11384 | image_create_info.mipLevels = 1; |
| 11385 | image_create_info.arrayLayers = 1; |
| 11386 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11387 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11388 | // Note: Some implementations expect color attachment usage for any |
| 11389 | // multisample surface |
| 11390 | image_create_info.usage = |
| 11391 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11392 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11394 | err = |
| 11395 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11396 | ASSERT_VK_SUCCESS(err); |
| 11397 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11398 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11399 | // Note: Some implementations expect color attachment usage for any |
| 11400 | // multisample surface |
| 11401 | image_create_info.usage = |
| 11402 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11403 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11405 | err = |
| 11406 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11407 | ASSERT_VK_SUCCESS(err); |
| 11408 | |
| 11409 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11410 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11411 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11412 | memAlloc.pNext = NULL; |
| 11413 | memAlloc.allocationSize = 0; |
| 11414 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11415 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11416 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11417 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11418 | pass = |
| 11419 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11420 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11421 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11422 | ASSERT_VK_SUCCESS(err); |
| 11423 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11424 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11425 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11426 | pass = |
| 11427 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11428 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11429 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11430 | ASSERT_VK_SUCCESS(err); |
| 11431 | |
| 11432 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11433 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11434 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11435 | ASSERT_VK_SUCCESS(err); |
| 11436 | |
| 11437 | BeginCommandBuffer(); |
| 11438 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11439 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11440 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11441 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11442 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11443 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11444 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11445 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11446 | resolveRegion.srcOffset.x = 0; |
| 11447 | resolveRegion.srcOffset.y = 0; |
| 11448 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11449 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11450 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11451 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11452 | resolveRegion.dstSubresource.layerCount = 0; |
| 11453 | resolveRegion.dstOffset.x = 0; |
| 11454 | resolveRegion.dstOffset.y = 0; |
| 11455 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11456 | resolveRegion.extent.width = 1; |
| 11457 | resolveRegion.extent.height = 1; |
| 11458 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11459 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11460 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11461 | EndCommandBuffer(); |
| 11462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11463 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11464 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11465 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11466 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11467 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11468 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11469 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11471 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11472 | // 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] | 11473 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11474 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11475 | // The image format check comes 2nd in validation so we trigger it first, |
| 11476 | // 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] | 11477 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11478 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11479 | m_errorMonitor->SetDesiredFailureMsg( |
| 11480 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11481 | "Combination depth/stencil image formats can have only the "); |
| 11482 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11483 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11484 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11485 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11486 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11487 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11488 | |
| 11489 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11490 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11491 | ds_pool_ci.pNext = NULL; |
| 11492 | ds_pool_ci.maxSets = 1; |
| 11493 | ds_pool_ci.poolSizeCount = 1; |
| 11494 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11495 | |
| 11496 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11497 | err = |
| 11498 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11499 | ASSERT_VK_SUCCESS(err); |
| 11500 | |
| 11501 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11502 | dsl_binding.binding = 0; |
| 11503 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11504 | dsl_binding.descriptorCount = 1; |
| 11505 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11506 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11507 | |
| 11508 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11509 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11510 | ds_layout_ci.pNext = NULL; |
| 11511 | ds_layout_ci.bindingCount = 1; |
| 11512 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11513 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11514 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11515 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11516 | ASSERT_VK_SUCCESS(err); |
| 11517 | |
| 11518 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11519 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11520 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11521 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11522 | alloc_info.descriptorPool = ds_pool; |
| 11523 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11524 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11525 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11526 | ASSERT_VK_SUCCESS(err); |
| 11527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11528 | VkImage image_bad; |
| 11529 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11530 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11531 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11532 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11533 | const int32_t tex_width = 32; |
| 11534 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11535 | |
| 11536 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11537 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11538 | image_create_info.pNext = NULL; |
| 11539 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11540 | image_create_info.format = tex_format_bad; |
| 11541 | image_create_info.extent.width = tex_width; |
| 11542 | image_create_info.extent.height = tex_height; |
| 11543 | image_create_info.extent.depth = 1; |
| 11544 | image_create_info.mipLevels = 1; |
| 11545 | image_create_info.arrayLayers = 1; |
| 11546 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11547 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11548 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11549 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11550 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11552 | err = |
| 11553 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11554 | ASSERT_VK_SUCCESS(err); |
| 11555 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11556 | image_create_info.usage = |
| 11557 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11558 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11559 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11560 | ASSERT_VK_SUCCESS(err); |
| 11561 | |
| 11562 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11563 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11564 | image_view_create_info.image = image_bad; |
| 11565 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11566 | image_view_create_info.format = tex_format_bad; |
| 11567 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11568 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11569 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11570 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11571 | image_view_create_info.subresourceRange.aspectMask = |
| 11572 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11573 | |
| 11574 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11575 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11576 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11577 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11578 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11579 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11580 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11581 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11582 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11583 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11584 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11585 | |
| 11586 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11587 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11588 | "ClearDepthStencilImage with a color image."); |
| 11589 | |
| 11590 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11591 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11592 | |
| 11593 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11594 | BeginCommandBuffer(); |
| 11595 | m_commandBuffer->EndRenderPass(); |
| 11596 | |
| 11597 | // Color image |
| 11598 | VkClearColorValue clear_color; |
| 11599 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11600 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11601 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11602 | const int32_t img_width = 32; |
| 11603 | const int32_t img_height = 32; |
| 11604 | VkImageCreateInfo image_create_info = {}; |
| 11605 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11606 | image_create_info.pNext = NULL; |
| 11607 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11608 | image_create_info.format = color_format; |
| 11609 | image_create_info.extent.width = img_width; |
| 11610 | image_create_info.extent.height = img_height; |
| 11611 | image_create_info.extent.depth = 1; |
| 11612 | image_create_info.mipLevels = 1; |
| 11613 | image_create_info.arrayLayers = 1; |
| 11614 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11615 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11616 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11617 | |
| 11618 | vk_testing::Image color_image; |
| 11619 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11620 | reqs); |
| 11621 | |
| 11622 | const VkImageSubresourceRange color_range = |
| 11623 | vk_testing::Image::subresource_range(image_create_info, |
| 11624 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11625 | |
| 11626 | // Depth/Stencil image |
| 11627 | VkClearDepthStencilValue clear_value = {0}; |
| 11628 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11629 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11630 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11631 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11632 | ds_image_create_info.extent.width = 64; |
| 11633 | ds_image_create_info.extent.height = 64; |
| 11634 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11635 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11636 | |
| 11637 | vk_testing::Image ds_image; |
| 11638 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11639 | reqs); |
| 11640 | |
| 11641 | const VkImageSubresourceRange ds_range = |
| 11642 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11643 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11644 | |
| 11645 | m_errorMonitor->SetDesiredFailureMsg( |
| 11646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11647 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11648 | |
| 11649 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11650 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11651 | &color_range); |
| 11652 | |
| 11653 | m_errorMonitor->VerifyFound(); |
| 11654 | |
| 11655 | // Call CmdClearDepthStencilImage with color image |
| 11656 | m_errorMonitor->SetDesiredFailureMsg( |
| 11657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11658 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11659 | |
| 11660 | vkCmdClearDepthStencilImage( |
| 11661 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11662 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11663 | &ds_range); |
| 11664 | |
| 11665 | m_errorMonitor->VerifyFound(); |
| 11666 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11667 | #endif // IMAGE_TESTS |
| 11668 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11669 | int main(int argc, char **argv) { |
| 11670 | int result; |
| 11671 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11672 | #ifdef ANDROID |
| 11673 | int vulkanSupport = InitVulkan(); |
| 11674 | if (vulkanSupport == 0) |
| 11675 | return 1; |
| 11676 | #endif |
| 11677 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11678 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11679 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11680 | |
| 11681 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11682 | |
| 11683 | result = RUN_ALL_TESTS(); |
| 11684 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11685 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11686 | return result; |
| 11687 | } |