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(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 824 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 825 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 826 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 827 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 828 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 829 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 830 | |
| 831 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 832 | TEST_DESCRIPTION( |
| 833 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 834 | |
| 835 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 836 | |
| 837 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 838 | "does not fall within the begin..end " |
| 839 | "range of the core VkFormat " |
| 840 | "enumeration tokens"); |
| 841 | // Specify an invalid VkFormat value |
| 842 | // Expected to trigger an error with |
| 843 | // parameter_validation::validate_ranged_enum |
| 844 | VkFormatProperties format_properties; |
| 845 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 846 | &format_properties); |
| 847 | m_errorMonitor->VerifyFound(); |
| 848 | |
| 849 | m_errorMonitor->SetDesiredFailureMsg( |
| 850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 851 | "contains flag bits that are not recognized members of"); |
| 852 | // Specify an invalid VkFlags bitmask value |
| 853 | // Expected to trigger an error with parameter_validation::validate_flags |
| 854 | VkImageFormatProperties image_format_properties; |
| 855 | vkGetPhysicalDeviceImageFormatProperties( |
| 856 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 857 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 858 | &image_format_properties); |
| 859 | m_errorMonitor->VerifyFound(); |
| 860 | |
| 861 | m_errorMonitor->SetDesiredFailureMsg( |
| 862 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 863 | "contains flag bits that are not recognized members of"); |
| 864 | // Specify an invalid VkFlags array entry |
| 865 | // Expected to trigger an error with |
| 866 | // parameter_validation::validate_flags_array |
| 867 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 868 | VkPipelineStageFlags stage_flags = |
| 869 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 870 | VkSubmitInfo submit_info = {}; |
| 871 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 872 | submit_info.waitSemaphoreCount = 1; |
| 873 | submit_info.pWaitSemaphores = &semaphore; |
| 874 | submit_info.pWaitDstStageMask = &stage_flags; |
| 875 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 876 | m_errorMonitor->VerifyFound(); |
| 877 | |
| 878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 879 | "is neither VK_TRUE nor VK_FALSE"); |
| 880 | // Specify an invalid VkBool32 value |
| 881 | // Expected to trigger a warning with |
| 882 | // parameter_validation::validate_bool32 |
| 883 | VkSampler sampler = VK_NULL_HANDLE; |
| 884 | VkSamplerCreateInfo sampler_info = {}; |
| 885 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 886 | sampler_info.pNext = NULL; |
| 887 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 888 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 889 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 890 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 891 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 892 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 893 | sampler_info.mipLodBias = 1.0; |
| 894 | sampler_info.maxAnisotropy = 1; |
| 895 | sampler_info.compareEnable = VK_FALSE; |
| 896 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 897 | sampler_info.minLod = 1.0; |
| 898 | sampler_info.maxLod = 1.0; |
| 899 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 900 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 901 | // Not VK_TRUE or VK_FALSE |
| 902 | sampler_info.anisotropyEnable = 3; |
| 903 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 904 | m_errorMonitor->VerifyFound(); |
| 905 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 906 | |
| 907 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 908 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 909 | |
| 910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 911 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 912 | // Find an unsupported image format |
| 913 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 914 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 915 | VkFormat format = static_cast<VkFormat>(f); |
| 916 | VkFormatProperties fProps = m_device->format_properties(format); |
| 917 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 918 | fProps.optimalTilingFeatures == 0) { |
| 919 | unsupported = format; |
| 920 | break; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 925 | m_errorMonitor->SetDesiredFailureMsg( |
| 926 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 927 | "the requested format is not supported on this device"); |
| 928 | // Specify an unsupported VkFormat value to generate a |
| 929 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 930 | // Expected to trigger a warning from |
| 931 | // parameter_validation::validate_result |
| 932 | VkImageFormatProperties image_format_properties; |
| 933 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 934 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 935 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 936 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 937 | m_errorMonitor->VerifyFound(); |
| 938 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 939 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 940 | |
| 941 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 942 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); |
| 943 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 944 | |
| 945 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 946 | |
| 947 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 948 | vk_testing::Buffer buffer; |
| 949 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 950 | |
| 951 | BeginCommandBuffer(); |
| 952 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 953 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 954 | " is not a multiple of 4"); |
| 955 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
| 956 | m_errorMonitor->VerifyFound(); |
| 957 | |
| 958 | // Introduce failure by using dataSize that is not multiple of 4 |
| 959 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 960 | " is not a multiple of 4"); |
| 961 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
| 962 | m_errorMonitor->VerifyFound(); |
| 963 | |
| 964 | // Introduce failure by using dataSize that is < 0 |
| 965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 966 | "must be greater than zero and less than or equal to 65536"); |
| 967 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); |
| 968 | m_errorMonitor->VerifyFound(); |
| 969 | |
| 970 | // Introduce failure by using dataSize that is > 65536 |
| 971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 972 | "must be greater than zero and less than or equal to 65536"); |
| 973 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); |
| 974 | m_errorMonitor->VerifyFound(); |
| 975 | |
| 976 | EndCommandBuffer(); |
| 977 | } |
| 978 | |
| 979 | TEST_F(VkLayerTest, FillBufferAlignment) { |
| 980 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); |
| 981 | |
| 982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 983 | |
| 984 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 985 | vk_testing::Buffer buffer; |
| 986 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 987 | |
| 988 | BeginCommandBuffer(); |
| 989 | |
| 990 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 991 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 992 | " is not a multiple of 4"); |
| 993 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
| 994 | m_errorMonitor->VerifyFound(); |
| 995 | |
| 996 | // Introduce failure by using size that is not multiple of 4 |
| 997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 998 | " is not a multiple of 4"); |
| 999 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
| 1000 | m_errorMonitor->VerifyFound(); |
| 1001 | |
| 1002 | // Introduce failure by using size that is zero |
| 1003 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1004 | "must be greater than zero"); |
| 1005 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); |
| 1006 | m_errorMonitor->VerifyFound(); |
| 1007 | |
| 1008 | EndCommandBuffer(); |
| 1009 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1010 | #endif // PARAMETER_VALIDATION_TESTS |
| 1011 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1012 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1013 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1014 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1015 | { |
| 1016 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1017 | VkFenceCreateInfo fenceInfo = {}; |
| 1018 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1019 | fenceInfo.pNext = NULL; |
| 1020 | fenceInfo.flags = 0; |
| 1021 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1022 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1023 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1025 | |
| 1026 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1027 | vk_testing::Buffer buffer; |
| 1028 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1029 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1030 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1031 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1032 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1033 | |
| 1034 | testFence.init(*m_device, fenceInfo); |
| 1035 | |
| 1036 | // Bypass framework since it does the waits automatically |
| 1037 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1038 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1039 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1040 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1041 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1042 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1043 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1044 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1045 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1046 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1047 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1048 | |
| 1049 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1050 | ASSERT_VK_SUCCESS( err ); |
| 1051 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1052 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1053 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1054 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1055 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1056 | } |
| 1057 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1058 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1059 | { |
| 1060 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1061 | VkFenceCreateInfo fenceInfo = {}; |
| 1062 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1063 | fenceInfo.pNext = NULL; |
| 1064 | fenceInfo.flags = 0; |
| 1065 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1066 | 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] | 1067 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1068 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1069 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1070 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1071 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1072 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1073 | 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] | 1074 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1075 | |
| 1076 | testFence.init(*m_device, fenceInfo); |
| 1077 | |
| 1078 | // Bypass framework since it does the waits automatically |
| 1079 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1080 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1081 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1082 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1083 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1084 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1085 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1086 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1087 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1088 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1089 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1090 | |
| 1091 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1092 | ASSERT_VK_SUCCESS( err ); |
| 1093 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1094 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1095 | VkCommandBufferBeginInfo info = {}; |
| 1096 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1097 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1098 | info.renderPass = VK_NULL_HANDLE; |
| 1099 | info.subpass = 0; |
| 1100 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1101 | info.occlusionQueryEnable = VK_FALSE; |
| 1102 | info.queryFlags = 0; |
| 1103 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1104 | |
| 1105 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1106 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1107 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1108 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1109 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1110 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1111 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1112 | // This is a positive test. No failures are expected. |
| 1113 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1114 | VkResult err; |
| 1115 | bool pass; |
| 1116 | |
| 1117 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1118 | "the buffer, create an image, and bind the same memory to " |
| 1119 | "it"); |
| 1120 | |
| 1121 | m_errorMonitor->ExpectSuccess(); |
| 1122 | |
| 1123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1124 | |
| 1125 | VkBuffer buffer; |
| 1126 | VkImage image; |
| 1127 | VkDeviceMemory mem; |
| 1128 | VkMemoryRequirements mem_reqs; |
| 1129 | |
| 1130 | VkBufferCreateInfo buf_info = {}; |
| 1131 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1132 | buf_info.pNext = NULL; |
| 1133 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1134 | buf_info.size = 256; |
| 1135 | buf_info.queueFamilyIndexCount = 0; |
| 1136 | buf_info.pQueueFamilyIndices = NULL; |
| 1137 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1138 | buf_info.flags = 0; |
| 1139 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1140 | ASSERT_VK_SUCCESS(err); |
| 1141 | |
| 1142 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1143 | |
| 1144 | VkMemoryAllocateInfo alloc_info = {}; |
| 1145 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1146 | alloc_info.pNext = NULL; |
| 1147 | alloc_info.memoryTypeIndex = 0; |
| 1148 | |
| 1149 | // Ensure memory is big enough for both bindings |
| 1150 | alloc_info.allocationSize = 0x10000; |
| 1151 | |
| 1152 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1153 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1154 | if (!pass) { |
| 1155 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1156 | return; |
| 1157 | } |
| 1158 | |
| 1159 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1160 | ASSERT_VK_SUCCESS(err); |
| 1161 | |
| 1162 | uint8_t *pData; |
| 1163 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1164 | (void **)&pData); |
| 1165 | ASSERT_VK_SUCCESS(err); |
| 1166 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1167 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1168 | |
| 1169 | vkUnmapMemory(m_device->device(), mem); |
| 1170 | |
| 1171 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1172 | ASSERT_VK_SUCCESS(err); |
| 1173 | |
| 1174 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1175 | // memory. In fact, it was never used by the GPU. |
| 1176 | // Just be be sure, wait for idle. |
| 1177 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1178 | vkDeviceWaitIdle(m_device->device()); |
| 1179 | |
| 1180 | VkImageCreateInfo image_create_info = {}; |
| 1181 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1182 | image_create_info.pNext = NULL; |
| 1183 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1184 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1185 | image_create_info.extent.width = 64; |
| 1186 | image_create_info.extent.height = 64; |
| 1187 | image_create_info.extent.depth = 1; |
| 1188 | image_create_info.mipLevels = 1; |
| 1189 | image_create_info.arrayLayers = 1; |
| 1190 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1191 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1192 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1193 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1194 | image_create_info.queueFamilyIndexCount = 0; |
| 1195 | image_create_info.pQueueFamilyIndices = NULL; |
| 1196 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1197 | image_create_info.flags = 0; |
| 1198 | |
| 1199 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1200 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1201 | mem_alloc.pNext = NULL; |
| 1202 | mem_alloc.allocationSize = 0; |
| 1203 | mem_alloc.memoryTypeIndex = 0; |
| 1204 | |
| 1205 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1206 | * to be textures or it will be the staging image if they are not. |
| 1207 | */ |
| 1208 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1209 | ASSERT_VK_SUCCESS(err); |
| 1210 | |
| 1211 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1212 | |
| 1213 | mem_alloc.allocationSize = mem_reqs.size; |
| 1214 | |
| 1215 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1216 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1217 | if (!pass) { |
| 1218 | vkDestroyImage(m_device->device(), image, NULL); |
| 1219 | return; |
| 1220 | } |
| 1221 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1222 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1223 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1224 | ASSERT_VK_SUCCESS(err); |
| 1225 | |
| 1226 | m_errorMonitor->VerifyNotFound(); |
| 1227 | |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1228 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1229 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1230 | vkDestroyImage(m_device->device(), image, NULL); |
| 1231 | } |
| 1232 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1233 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1234 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1235 | "buffer and image to memory such that they will alias."); |
| 1236 | VkResult err; |
| 1237 | bool pass; |
| 1238 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1239 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1240 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1241 | VkImage image; |
| 1242 | VkDeviceMemory mem; // buffer will be bound first |
| 1243 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1244 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1245 | |
| 1246 | VkBufferCreateInfo buf_info = {}; |
| 1247 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1248 | buf_info.pNext = NULL; |
| 1249 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1250 | buf_info.size = 256; |
| 1251 | buf_info.queueFamilyIndexCount = 0; |
| 1252 | buf_info.pQueueFamilyIndices = NULL; |
| 1253 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1254 | buf_info.flags = 0; |
| 1255 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1256 | ASSERT_VK_SUCCESS(err); |
| 1257 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1258 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1259 | |
| 1260 | VkImageCreateInfo image_create_info = {}; |
| 1261 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1262 | image_create_info.pNext = NULL; |
| 1263 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1264 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1265 | image_create_info.extent.width = 64; |
| 1266 | image_create_info.extent.height = 64; |
| 1267 | image_create_info.extent.depth = 1; |
| 1268 | image_create_info.mipLevels = 1; |
| 1269 | image_create_info.arrayLayers = 1; |
| 1270 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1271 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1272 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1273 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1274 | image_create_info.queueFamilyIndexCount = 0; |
| 1275 | image_create_info.pQueueFamilyIndices = NULL; |
| 1276 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1277 | image_create_info.flags = 0; |
| 1278 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1279 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1280 | ASSERT_VK_SUCCESS(err); |
| 1281 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1282 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1283 | |
| 1284 | VkMemoryAllocateInfo alloc_info = {}; |
| 1285 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1286 | alloc_info.pNext = NULL; |
| 1287 | alloc_info.memoryTypeIndex = 0; |
| 1288 | // Ensure memory is big enough for both bindings |
| 1289 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1290 | pass = m_device->phy().set_memory_type( |
| 1291 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1292 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1293 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1294 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1295 | vkDestroyImage(m_device->device(), image, NULL); |
| 1296 | return; |
| 1297 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1298 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1299 | ASSERT_VK_SUCCESS(err); |
| 1300 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1301 | ASSERT_VK_SUCCESS(err); |
| 1302 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1303 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1304 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1305 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1306 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1307 | m_errorMonitor->VerifyFound(); |
| 1308 | |
| 1309 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1310 | // aliasing buffer2 |
| 1311 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1312 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1313 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1314 | ASSERT_VK_SUCCESS(err); |
| 1315 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1316 | ASSERT_VK_SUCCESS(err); |
| 1317 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1318 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1319 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1320 | m_errorMonitor->VerifyFound(); |
| 1321 | |
| 1322 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1323 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1324 | vkDestroyImage(m_device->device(), image, NULL); |
| 1325 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1326 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1327 | } |
| 1328 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1329 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1330 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1331 | VkResult err; |
| 1332 | bool pass; |
| 1333 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1334 | |
| 1335 | VkBuffer buffer; |
| 1336 | VkDeviceMemory mem; |
| 1337 | VkMemoryRequirements mem_reqs; |
| 1338 | |
| 1339 | VkBufferCreateInfo buf_info = {}; |
| 1340 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1341 | buf_info.pNext = NULL; |
| 1342 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1343 | buf_info.size = 256; |
| 1344 | buf_info.queueFamilyIndexCount = 0; |
| 1345 | buf_info.pQueueFamilyIndices = NULL; |
| 1346 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1347 | buf_info.flags = 0; |
| 1348 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1349 | ASSERT_VK_SUCCESS(err); |
| 1350 | |
| 1351 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1352 | VkMemoryAllocateInfo alloc_info = {}; |
| 1353 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1354 | alloc_info.pNext = NULL; |
| 1355 | alloc_info.memoryTypeIndex = 0; |
| 1356 | |
| 1357 | // Ensure memory is big enough for both bindings |
| 1358 | static const VkDeviceSize allocation_size = 0x10000; |
| 1359 | alloc_info.allocationSize = allocation_size; |
| 1360 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1361 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1362 | if (!pass) { |
| 1363 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1364 | return; |
| 1365 | } |
| 1366 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1367 | ASSERT_VK_SUCCESS(err); |
| 1368 | |
| 1369 | uint8_t *pData; |
| 1370 | // Attempt to map memory size 0 is invalid |
| 1371 | m_errorMonitor->SetDesiredFailureMsg( |
| 1372 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1373 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1374 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1375 | m_errorMonitor->VerifyFound(); |
| 1376 | // Map memory twice |
| 1377 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1378 | (void **)&pData); |
| 1379 | ASSERT_VK_SUCCESS(err); |
| 1380 | m_errorMonitor->SetDesiredFailureMsg( |
| 1381 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1382 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1383 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1384 | (void **)&pData); |
| 1385 | m_errorMonitor->VerifyFound(); |
| 1386 | |
| 1387 | // Unmap the memory to avoid re-map error |
| 1388 | vkUnmapMemory(m_device->device(), mem); |
| 1389 | // overstep allocation with VK_WHOLE_SIZE |
| 1390 | m_errorMonitor->SetDesiredFailureMsg( |
| 1391 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1392 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1393 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1394 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1395 | m_errorMonitor->VerifyFound(); |
| 1396 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1397 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1398 | " oversteps total array size 0x"); |
| 1399 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1400 | (void **)&pData); |
| 1401 | m_errorMonitor->VerifyFound(); |
| 1402 | // Now error due to unmapping memory that's not mapped |
| 1403 | m_errorMonitor->SetDesiredFailureMsg( |
| 1404 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1405 | "Unmapping Memory without memory being mapped: "); |
| 1406 | vkUnmapMemory(m_device->device(), mem); |
| 1407 | m_errorMonitor->VerifyFound(); |
| 1408 | // Now map memory and cause errors due to flushing invalid ranges |
| 1409 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1410 | (void **)&pData); |
| 1411 | ASSERT_VK_SUCCESS(err); |
| 1412 | VkMappedMemoryRange mmr = {}; |
| 1413 | mmr.memory = mem; |
| 1414 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1415 | m_errorMonitor->SetDesiredFailureMsg( |
| 1416 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1417 | ") is less than Memory Object's offset ("); |
| 1418 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1419 | m_errorMonitor->VerifyFound(); |
| 1420 | // Now flush range that oversteps mapped range |
| 1421 | vkUnmapMemory(m_device->device(), mem); |
| 1422 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1423 | ASSERT_VK_SUCCESS(err); |
| 1424 | mmr.offset = 16; |
| 1425 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1426 | m_errorMonitor->SetDesiredFailureMsg( |
| 1427 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1428 | ") exceeds the Memory Object's upper-bound ("); |
| 1429 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1430 | m_errorMonitor->VerifyFound(); |
| 1431 | |
| 1432 | pass = |
| 1433 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1434 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1435 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1436 | if (!pass) { |
| 1437 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1438 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1439 | return; |
| 1440 | } |
| 1441 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1442 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1443 | |
| 1444 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1445 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1446 | } |
| 1447 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1448 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1449 | VkResult err; |
| 1450 | bool pass; |
| 1451 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1452 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1453 | // following declaration (which is temporarily being moved below): |
| 1454 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1455 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1456 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1457 | uint32_t swapchain_image_count = 0; |
| 1458 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1459 | uint32_t image_index = 0; |
| 1460 | // VkPresentInfoKHR present_info = {}; |
| 1461 | |
| 1462 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1463 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1464 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1465 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1466 | // Use the functions from the VK_KHR_android_surface extension without |
| 1467 | // enabling that extension: |
| 1468 | |
| 1469 | // Create a surface: |
| 1470 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1471 | m_errorMonitor->SetDesiredFailureMsg( |
| 1472 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1473 | "extension was not enabled for this"); |
| 1474 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1475 | &surface); |
| 1476 | pass = (err != VK_SUCCESS); |
| 1477 | ASSERT_TRUE(pass); |
| 1478 | m_errorMonitor->VerifyFound(); |
| 1479 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1480 | |
| 1481 | |
| 1482 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1483 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1484 | // that extension: |
| 1485 | |
| 1486 | // Create a surface: |
| 1487 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1488 | m_errorMonitor->SetDesiredFailureMsg( |
| 1489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1490 | "extension was not enabled for this"); |
| 1491 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1492 | pass = (err != VK_SUCCESS); |
| 1493 | ASSERT_TRUE(pass); |
| 1494 | m_errorMonitor->VerifyFound(); |
| 1495 | |
| 1496 | // Tell whether an mir_connection supports presentation: |
| 1497 | MirConnection *mir_connection = NULL; |
| 1498 | m_errorMonitor->SetDesiredFailureMsg( |
| 1499 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1500 | "extension was not enabled for this"); |
| 1501 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1502 | visual_id); |
| 1503 | m_errorMonitor->VerifyFound(); |
| 1504 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1505 | |
| 1506 | |
| 1507 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1508 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1509 | // enabling that extension: |
| 1510 | |
| 1511 | // Create a surface: |
| 1512 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1513 | m_errorMonitor->SetDesiredFailureMsg( |
| 1514 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1515 | "extension was not enabled for this"); |
| 1516 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1517 | &surface); |
| 1518 | pass = (err != VK_SUCCESS); |
| 1519 | ASSERT_TRUE(pass); |
| 1520 | m_errorMonitor->VerifyFound(); |
| 1521 | |
| 1522 | // Tell whether an wayland_display supports presentation: |
| 1523 | struct wl_display wayland_display = {}; |
| 1524 | m_errorMonitor->SetDesiredFailureMsg( |
| 1525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1526 | "extension was not enabled for this"); |
| 1527 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1528 | &wayland_display); |
| 1529 | m_errorMonitor->VerifyFound(); |
| 1530 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1531 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1532 | |
| 1533 | |
| 1534 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1535 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1536 | // TO NON-LINUX PLATFORMS: |
| 1537 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1538 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1539 | // enabling that extension: |
| 1540 | |
| 1541 | // Create a surface: |
| 1542 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1543 | m_errorMonitor->SetDesiredFailureMsg( |
| 1544 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1545 | "extension was not enabled for this"); |
| 1546 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1547 | &surface); |
| 1548 | pass = (err != VK_SUCCESS); |
| 1549 | ASSERT_TRUE(pass); |
| 1550 | m_errorMonitor->VerifyFound(); |
| 1551 | |
| 1552 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1553 | m_errorMonitor->SetDesiredFailureMsg( |
| 1554 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1555 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1556 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1557 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1558 | // Set this (for now, until all platforms are supported and tested): |
| 1559 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1560 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1561 | |
| 1562 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1563 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1564 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1565 | // TO NON-LINUX PLATFORMS: |
| 1566 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1567 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1568 | // that extension: |
| 1569 | |
| 1570 | // Create a surface: |
| 1571 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1572 | m_errorMonitor->SetDesiredFailureMsg( |
| 1573 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1574 | "extension was not enabled for this"); |
| 1575 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1576 | pass = (err != VK_SUCCESS); |
| 1577 | ASSERT_TRUE(pass); |
| 1578 | m_errorMonitor->VerifyFound(); |
| 1579 | |
| 1580 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1581 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1582 | xcb_visualid_t visual_id = 0; |
| 1583 | m_errorMonitor->SetDesiredFailureMsg( |
| 1584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1585 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1586 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1587 | visual_id); |
| 1588 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1589 | // Set this (for now, until all platforms are supported and tested): |
| 1590 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1591 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1592 | |
| 1593 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1594 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1595 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1596 | // that extension: |
| 1597 | |
| 1598 | // Create a surface: |
| 1599 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1600 | m_errorMonitor->SetDesiredFailureMsg( |
| 1601 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1602 | "extension was not enabled for this"); |
| 1603 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1604 | pass = (err != VK_SUCCESS); |
| 1605 | ASSERT_TRUE(pass); |
| 1606 | m_errorMonitor->VerifyFound(); |
| 1607 | |
| 1608 | // Tell whether an Xlib VisualID supports presentation: |
| 1609 | Display *dpy = NULL; |
| 1610 | VisualID visual = 0; |
| 1611 | m_errorMonitor->SetDesiredFailureMsg( |
| 1612 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1613 | "extension was not enabled for this"); |
| 1614 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1615 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1616 | // Set this (for now, until all platforms are supported and tested): |
| 1617 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1618 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1619 | |
| 1620 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1621 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1622 | // that extension: |
| 1623 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1624 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1625 | // Destroy a surface: |
| 1626 | m_errorMonitor->SetDesiredFailureMsg( |
| 1627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1628 | "extension was not enabled for this"); |
| 1629 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1630 | m_errorMonitor->VerifyFound(); |
| 1631 | |
| 1632 | // Check if surface supports presentation: |
| 1633 | VkBool32 supported = false; |
| 1634 | m_errorMonitor->SetDesiredFailureMsg( |
| 1635 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1636 | "extension was not enabled for this"); |
| 1637 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1638 | pass = (err != VK_SUCCESS); |
| 1639 | ASSERT_TRUE(pass); |
| 1640 | m_errorMonitor->VerifyFound(); |
| 1641 | |
| 1642 | // Check surface capabilities: |
| 1643 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1644 | m_errorMonitor->SetDesiredFailureMsg( |
| 1645 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1646 | "extension was not enabled for this"); |
| 1647 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1648 | &capabilities); |
| 1649 | pass = (err != VK_SUCCESS); |
| 1650 | ASSERT_TRUE(pass); |
| 1651 | m_errorMonitor->VerifyFound(); |
| 1652 | |
| 1653 | // Check surface formats: |
| 1654 | uint32_t format_count = 0; |
| 1655 | VkSurfaceFormatKHR *formats = NULL; |
| 1656 | m_errorMonitor->SetDesiredFailureMsg( |
| 1657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1658 | "extension was not enabled for this"); |
| 1659 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1660 | &format_count, formats); |
| 1661 | pass = (err != VK_SUCCESS); |
| 1662 | ASSERT_TRUE(pass); |
| 1663 | m_errorMonitor->VerifyFound(); |
| 1664 | |
| 1665 | // Check surface present modes: |
| 1666 | uint32_t present_mode_count = 0; |
| 1667 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1668 | m_errorMonitor->SetDesiredFailureMsg( |
| 1669 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1670 | "extension was not enabled for this"); |
| 1671 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1672 | &present_mode_count, present_modes); |
| 1673 | pass = (err != VK_SUCCESS); |
| 1674 | ASSERT_TRUE(pass); |
| 1675 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1676 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1677 | |
| 1678 | |
| 1679 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1680 | // that extension: |
| 1681 | |
| 1682 | // Create a swapchain: |
| 1683 | m_errorMonitor->SetDesiredFailureMsg( |
| 1684 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1685 | "extension was not enabled for this"); |
| 1686 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1687 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1688 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1689 | NULL, &swapchain); |
| 1690 | pass = (err != VK_SUCCESS); |
| 1691 | ASSERT_TRUE(pass); |
| 1692 | m_errorMonitor->VerifyFound(); |
| 1693 | |
| 1694 | // Get the images from the swapchain: |
| 1695 | m_errorMonitor->SetDesiredFailureMsg( |
| 1696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1697 | "extension was not enabled for this"); |
| 1698 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1699 | &swapchain_image_count, NULL); |
| 1700 | pass = (err != VK_SUCCESS); |
| 1701 | ASSERT_TRUE(pass); |
| 1702 | m_errorMonitor->VerifyFound(); |
| 1703 | |
| 1704 | // Try to acquire an image: |
| 1705 | m_errorMonitor->SetDesiredFailureMsg( |
| 1706 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1707 | "extension was not enabled for this"); |
| 1708 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1709 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1710 | pass = (err != VK_SUCCESS); |
| 1711 | ASSERT_TRUE(pass); |
| 1712 | m_errorMonitor->VerifyFound(); |
| 1713 | |
| 1714 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1715 | // |
| 1716 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1717 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1718 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1719 | |
| 1720 | // Destroy the swapchain: |
| 1721 | m_errorMonitor->SetDesiredFailureMsg( |
| 1722 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1723 | "extension was not enabled for this"); |
| 1724 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1725 | m_errorMonitor->VerifyFound(); |
| 1726 | } |
| 1727 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1728 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1729 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1730 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1731 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1732 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1733 | VkResult err; |
| 1734 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1735 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1736 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1737 | // uint32_t swapchain_image_count = 0; |
| 1738 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1739 | // uint32_t image_index = 0; |
| 1740 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1741 | |
| 1742 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1743 | |
| 1744 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1745 | // order to create a surface, testing all known errors in the process, |
| 1746 | // before successfully creating a surface: |
| 1747 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1748 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1749 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1750 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1751 | pass = (err != VK_SUCCESS); |
| 1752 | ASSERT_TRUE(pass); |
| 1753 | m_errorMonitor->VerifyFound(); |
| 1754 | |
| 1755 | // Next, try to create a surface with the wrong |
| 1756 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1757 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1758 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1760 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1761 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1762 | pass = (err != VK_SUCCESS); |
| 1763 | ASSERT_TRUE(pass); |
| 1764 | m_errorMonitor->VerifyFound(); |
| 1765 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1766 | // Create a native window, and then correctly create a surface: |
| 1767 | xcb_connection_t *connection; |
| 1768 | xcb_screen_t *screen; |
| 1769 | xcb_window_t xcb_window; |
| 1770 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1771 | |
| 1772 | const xcb_setup_t *setup; |
| 1773 | xcb_screen_iterator_t iter; |
| 1774 | int scr; |
| 1775 | uint32_t value_mask, value_list[32]; |
| 1776 | int width = 1; |
| 1777 | int height = 1; |
| 1778 | |
| 1779 | connection = xcb_connect(NULL, &scr); |
| 1780 | ASSERT_TRUE(connection != NULL); |
| 1781 | setup = xcb_get_setup(connection); |
| 1782 | iter = xcb_setup_roots_iterator(setup); |
| 1783 | while (scr-- > 0) |
| 1784 | xcb_screen_next(&iter); |
| 1785 | screen = iter.data; |
| 1786 | |
| 1787 | xcb_window = xcb_generate_id(connection); |
| 1788 | |
| 1789 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1790 | value_list[0] = screen->black_pixel; |
| 1791 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1792 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1793 | |
| 1794 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1795 | screen->root, 0, 0, width, height, 0, |
| 1796 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1797 | value_mask, value_list); |
| 1798 | |
| 1799 | /* Magic code that will send notification when window is destroyed */ |
| 1800 | xcb_intern_atom_cookie_t cookie = |
| 1801 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1802 | xcb_intern_atom_reply_t *reply = |
| 1803 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1804 | |
| 1805 | xcb_intern_atom_cookie_t cookie2 = |
| 1806 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1807 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1808 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1809 | (*reply).atom, 4, 32, 1, |
| 1810 | &(*atom_wm_delete_window).atom); |
| 1811 | free(reply); |
| 1812 | |
| 1813 | xcb_map_window(connection, xcb_window); |
| 1814 | |
| 1815 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1816 | // runs |
| 1817 | const uint32_t coords[] = {100, 100}; |
| 1818 | xcb_configure_window(connection, xcb_window, |
| 1819 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1820 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1821 | // Finally, try to correctly create a surface: |
| 1822 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1823 | xcb_create_info.pNext = NULL; |
| 1824 | xcb_create_info.flags = 0; |
| 1825 | xcb_create_info.connection = connection; |
| 1826 | xcb_create_info.window = xcb_window; |
| 1827 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1828 | pass = (err == VK_SUCCESS); |
| 1829 | ASSERT_TRUE(pass); |
| 1830 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1831 | // Check if surface supports presentation: |
| 1832 | |
| 1833 | // 1st, do so without having queried the queue families: |
| 1834 | VkBool32 supported = false; |
| 1835 | // TODO: Get the following error to come out: |
| 1836 | m_errorMonitor->SetDesiredFailureMsg( |
| 1837 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1838 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1839 | "function"); |
| 1840 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1841 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1842 | // ASSERT_TRUE(pass); |
| 1843 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1844 | |
| 1845 | // Next, query a queue family index that's too large: |
| 1846 | m_errorMonitor->SetDesiredFailureMsg( |
| 1847 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1848 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1849 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1850 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1851 | pass = (err != VK_SUCCESS); |
| 1852 | ASSERT_TRUE(pass); |
| 1853 | m_errorMonitor->VerifyFound(); |
| 1854 | |
| 1855 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1856 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1857 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1858 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1859 | pass = (err == VK_SUCCESS); |
| 1860 | ASSERT_TRUE(pass); |
| 1861 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1862 | // Before proceeding, try to create a swapchain without having called |
| 1863 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1864 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1865 | swapchain_create_info.pNext = NULL; |
| 1866 | swapchain_create_info.flags = 0; |
| 1867 | m_errorMonitor->SetDesiredFailureMsg( |
| 1868 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1869 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1870 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1871 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1872 | pass = (err != VK_SUCCESS); |
| 1873 | ASSERT_TRUE(pass); |
| 1874 | m_errorMonitor->VerifyFound(); |
| 1875 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1876 | // Get the surface capabilities: |
| 1877 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1878 | |
| 1879 | // Do so correctly (only error logged by this entrypoint is if the |
| 1880 | // extension isn't enabled): |
| 1881 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1882 | &surface_capabilities); |
| 1883 | pass = (err == VK_SUCCESS); |
| 1884 | ASSERT_TRUE(pass); |
| 1885 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1886 | // Get the surface formats: |
| 1887 | uint32_t surface_format_count; |
| 1888 | |
| 1889 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1890 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1891 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1892 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1893 | pass = (err == VK_SUCCESS); |
| 1894 | ASSERT_TRUE(pass); |
| 1895 | m_errorMonitor->VerifyFound(); |
| 1896 | |
| 1897 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1898 | // correctly done a 1st try (to get the count): |
| 1899 | m_errorMonitor->SetDesiredFailureMsg( |
| 1900 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1901 | "but no prior positive value has been seen for"); |
| 1902 | surface_format_count = 0; |
| 1903 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1904 | gpu(), surface, &surface_format_count, |
| 1905 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1906 | pass = (err == VK_SUCCESS); |
| 1907 | ASSERT_TRUE(pass); |
| 1908 | m_errorMonitor->VerifyFound(); |
| 1909 | |
| 1910 | // 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] | 1911 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1912 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1913 | pass = (err == VK_SUCCESS); |
| 1914 | ASSERT_TRUE(pass); |
| 1915 | |
| 1916 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1917 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1918 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1919 | |
| 1920 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1921 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1922 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1923 | "that is greater than the value"); |
| 1924 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1925 | surface_formats); |
| 1926 | pass = (err == VK_SUCCESS); |
| 1927 | ASSERT_TRUE(pass); |
| 1928 | m_errorMonitor->VerifyFound(); |
| 1929 | |
| 1930 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1931 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1932 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1933 | pass = (err == VK_SUCCESS); |
| 1934 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1935 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1936 | surface_formats); |
| 1937 | pass = (err == VK_SUCCESS); |
| 1938 | ASSERT_TRUE(pass); |
| 1939 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1940 | // Get the surface present modes: |
| 1941 | uint32_t surface_present_mode_count; |
| 1942 | |
| 1943 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1944 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1945 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1946 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1947 | pass = (err == VK_SUCCESS); |
| 1948 | ASSERT_TRUE(pass); |
| 1949 | m_errorMonitor->VerifyFound(); |
| 1950 | |
| 1951 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1952 | // correctly done a 1st try (to get the count): |
| 1953 | m_errorMonitor->SetDesiredFailureMsg( |
| 1954 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1955 | "but no prior positive value has been seen for"); |
| 1956 | surface_present_mode_count = 0; |
| 1957 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1958 | gpu(), surface, &surface_present_mode_count, |
| 1959 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1960 | pass = (err == VK_SUCCESS); |
| 1961 | ASSERT_TRUE(pass); |
| 1962 | m_errorMonitor->VerifyFound(); |
| 1963 | |
| 1964 | // 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] | 1965 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1966 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1967 | pass = (err == VK_SUCCESS); |
| 1968 | ASSERT_TRUE(pass); |
| 1969 | |
| 1970 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1971 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1972 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1973 | |
| 1974 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1975 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1976 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1977 | "that is greater than the value"); |
| 1978 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1979 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1980 | pass = (err == VK_SUCCESS); |
| 1981 | ASSERT_TRUE(pass); |
| 1982 | m_errorMonitor->VerifyFound(); |
| 1983 | |
| 1984 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1985 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1986 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1987 | pass = (err == VK_SUCCESS); |
| 1988 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1989 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1990 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1991 | pass = (err == VK_SUCCESS); |
| 1992 | ASSERT_TRUE(pass); |
| 1993 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1994 | // Create a swapchain: |
| 1995 | |
| 1996 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1998 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1999 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 2000 | pass = (err != VK_SUCCESS); |
| 2001 | ASSERT_TRUE(pass); |
| 2002 | m_errorMonitor->VerifyFound(); |
| 2003 | |
| 2004 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 2005 | // sType: |
| 2006 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2007 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2008 | "called with the wrong value for"); |
| 2009 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2010 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2011 | pass = (err != VK_SUCCESS); |
| 2012 | ASSERT_TRUE(pass); |
| 2013 | m_errorMonitor->VerifyFound(); |
| 2014 | |
| 2015 | // Next, call with a NULL swapchain pointer: |
| 2016 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 2017 | swapchain_create_info.pNext = NULL; |
| 2018 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2020 | "called with NULL pointer"); |
| 2021 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2022 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2023 | pass = (err != VK_SUCCESS); |
| 2024 | ASSERT_TRUE(pass); |
| 2025 | m_errorMonitor->VerifyFound(); |
| 2026 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2027 | // TODO: Enhance swapchain layer so that |
| 2028 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2029 | |
| 2030 | // Next, call with a queue family index that's too large: |
| 2031 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 2032 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2033 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 2034 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 2035 | m_errorMonitor->SetDesiredFailureMsg( |
| 2036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2037 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2038 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2039 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2040 | pass = (err != VK_SUCCESS); |
| 2041 | ASSERT_TRUE(pass); |
| 2042 | m_errorMonitor->VerifyFound(); |
| 2043 | |
| 2044 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 2045 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2046 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2047 | m_errorMonitor->SetDesiredFailureMsg( |
| 2048 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2049 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 2050 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2051 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2052 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2053 | pass = (err != VK_SUCCESS); |
| 2054 | ASSERT_TRUE(pass); |
| 2055 | m_errorMonitor->VerifyFound(); |
| 2056 | |
| 2057 | // Next, call with an invalid imageSharingMode: |
| 2058 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 2059 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2060 | m_errorMonitor->SetDesiredFailureMsg( |
| 2061 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2062 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2063 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2064 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2065 | pass = (err != VK_SUCCESS); |
| 2066 | ASSERT_TRUE(pass); |
| 2067 | m_errorMonitor->VerifyFound(); |
| 2068 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2069 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 2070 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2071 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2072 | queueFamilyIndex[0] = 0; |
| 2073 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2074 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2075 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2076 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2077 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2078 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2079 | // Destroy the swapchain: |
| 2080 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2081 | // TODOs: |
| 2082 | // |
| 2083 | // - Try destroying the device without first destroying the swapchain |
| 2084 | // |
| 2085 | // - Try destroying the device without first destroying the surface |
| 2086 | // |
| 2087 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2088 | |
| 2089 | // Destroy the surface: |
| 2090 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2091 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2092 | // Tear down the window: |
| 2093 | xcb_destroy_window(connection, xcb_window); |
| 2094 | xcb_disconnect(connection); |
| 2095 | |
| 2096 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2097 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2098 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2099 | } |
| 2100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2101 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2102 | VkResult err; |
| 2103 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -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 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2108 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -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 mem; |
| 2114 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2115 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2116 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2117 | const int32_t tex_width = 32; |
| 2118 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2119 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2120 | VkImageCreateInfo image_create_info = {}; |
| 2121 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2122 | image_create_info.pNext = NULL; |
| 2123 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2124 | image_create_info.format = tex_format; |
| 2125 | image_create_info.extent.width = tex_width; |
| 2126 | image_create_info.extent.height = tex_height; |
| 2127 | image_create_info.extent.depth = 1; |
| 2128 | image_create_info.mipLevels = 1; |
| 2129 | image_create_info.arrayLayers = 1; |
| 2130 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2131 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2132 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2133 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2134 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2135 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2136 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2137 | mem_alloc.pNext = NULL; |
| 2138 | mem_alloc.allocationSize = 0; |
| 2139 | // Introduce failure, do NOT set memProps to |
| 2140 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2141 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2142 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2143 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2144 | ASSERT_VK_SUCCESS(err); |
| 2145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2146 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2147 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2148 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2149 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2150 | pass = |
| 2151 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2152 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2153 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2154 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2155 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2156 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2157 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2158 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2159 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2160 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2161 | ASSERT_VK_SUCCESS(err); |
| 2162 | |
| 2163 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2164 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
| 2166 | |
| 2167 | // Map memory as if to initialize the image |
| 2168 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2169 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2170 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2171 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2172 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2173 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2174 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2175 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2176 | } |
| 2177 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2178 | TEST_F(VkLayerTest, RebindMemory) { |
| 2179 | VkResult err; |
| 2180 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2181 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2182 | m_errorMonitor->SetDesiredFailureMsg( |
| 2183 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2184 | "which has already been bound to mem object"); |
| 2185 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2187 | |
| 2188 | // 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] | 2189 | VkImage image; |
| 2190 | VkDeviceMemory mem1; |
| 2191 | VkDeviceMemory mem2; |
| 2192 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2194 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2195 | const int32_t tex_width = 32; |
| 2196 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2197 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2198 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2199 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2200 | image_create_info.pNext = NULL; |
| 2201 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2202 | image_create_info.format = tex_format; |
| 2203 | image_create_info.extent.width = tex_width; |
| 2204 | image_create_info.extent.height = tex_height; |
| 2205 | image_create_info.extent.depth = 1; |
| 2206 | image_create_info.mipLevels = 1; |
| 2207 | image_create_info.arrayLayers = 1; |
| 2208 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2209 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2210 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2211 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2212 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2213 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2214 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2215 | mem_alloc.pNext = NULL; |
| 2216 | mem_alloc.allocationSize = 0; |
| 2217 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2219 | // Introduce failure, do NOT set memProps to |
| 2220 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2221 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2222 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2223 | ASSERT_VK_SUCCESS(err); |
| 2224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2226 | |
| 2227 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2228 | pass = |
| 2229 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2230 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2231 | |
| 2232 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2233 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2234 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2235 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2236 | ASSERT_VK_SUCCESS(err); |
| 2237 | |
| 2238 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2239 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2240 | ASSERT_VK_SUCCESS(err); |
| 2241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2242 | // Introduce validation failure, try to bind a different memory object to |
| 2243 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2244 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2245 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2246 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2247 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2248 | vkDestroyImage(m_device->device(), image, NULL); |
| 2249 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2250 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2251 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2252 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2253 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2254 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2256 | m_errorMonitor->SetDesiredFailureMsg( |
| 2257 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2258 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2259 | |
| 2260 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2261 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2262 | fenceInfo.pNext = NULL; |
| 2263 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2264 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2265 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2266 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2267 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2268 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2269 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2270 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2271 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2272 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2273 | |
| 2274 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2275 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2276 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2277 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2278 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2279 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2280 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2281 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2282 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2283 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2284 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2285 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2286 | |
| 2287 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2288 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2289 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2290 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2291 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2292 | // This is a positive test. We used to expect error in this case but spec now |
| 2293 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2294 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2295 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2296 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2297 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2298 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2299 | fenceInfo.pNext = NULL; |
| 2300 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2302 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2303 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2304 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2305 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2306 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2307 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2308 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2309 | |
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 2310 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
| 2311 | { |
| 2312 | m_errorMonitor->ExpectSuccess(); |
| 2313 | |
| 2314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2315 | VkResult err; |
| 2316 | |
| 2317 | // Record (empty!) command buffer that can be submitted multiple times |
| 2318 | // simultaneously. |
| 2319 | VkCommandBufferBeginInfo cbbi = { |
| 2320 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 2321 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr |
| 2322 | }; |
| 2323 | m_commandBuffer->BeginCommandBuffer(&cbbi); |
| 2324 | m_commandBuffer->EndCommandBuffer(); |
| 2325 | |
| 2326 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; |
| 2327 | VkFence fence; |
| 2328 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); |
| 2329 | ASSERT_VK_SUCCESS(err); |
| 2330 | |
| 2331 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; |
| 2332 | VkSemaphore s1, s2; |
| 2333 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); |
| 2334 | ASSERT_VK_SUCCESS(err); |
| 2335 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); |
| 2336 | ASSERT_VK_SUCCESS(err); |
| 2337 | |
| 2338 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. |
| 2339 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, |
| 2340 | 1, &m_commandBuffer->handle(), 1, &s1 }; |
| 2341 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); |
| 2342 | ASSERT_VK_SUCCESS(err); |
| 2343 | |
| 2344 | // Submit CB again, signaling s2. |
| 2345 | si.pSignalSemaphores = &s2; |
| 2346 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); |
| 2347 | ASSERT_VK_SUCCESS(err); |
| 2348 | |
| 2349 | // Wait for fence. |
| 2350 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2351 | ASSERT_VK_SUCCESS(err); |
| 2352 | |
| 2353 | // CB is still in flight from second submission, but semaphore s1 is no |
| 2354 | // longer in flight. delete it. |
| 2355 | vkDestroySemaphore(m_device->device(), s1, nullptr); |
| 2356 | |
| 2357 | m_errorMonitor->VerifyNotFound(); |
| 2358 | |
| 2359 | // Force device idle and clean up remaining objects |
| 2360 | vkDeviceWaitIdle(m_device->device()); |
| 2361 | vkDestroySemaphore(m_device->device(), s2, nullptr); |
| 2362 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2363 | } |
| 2364 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2365 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2366 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2367 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2368 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2369 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2370 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2371 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2372 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2373 | |
| 2374 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2375 | VkImageObj image(m_device); |
| 2376 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2377 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2378 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2379 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2380 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2381 | VkImageView dsv; |
| 2382 | VkImageViewCreateInfo dsvci = {}; |
| 2383 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2384 | dsvci.image = image.handle(); |
| 2385 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2386 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2387 | dsvci.subresourceRange.layerCount = 1; |
| 2388 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2389 | dsvci.subresourceRange.levelCount = 1; |
| 2390 | dsvci.subresourceRange.aspectMask = |
| 2391 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2392 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2393 | // Create a view with depth / stencil aspect for image with different usage |
| 2394 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2395 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2396 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2397 | |
| 2398 | // Initialize buffer with TRANSFER_DST usage |
| 2399 | vk_testing::Buffer buffer; |
| 2400 | VkMemoryPropertyFlags reqs = 0; |
| 2401 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2402 | VkBufferImageCopy region = {}; |
| 2403 | region.bufferRowLength = 128; |
| 2404 | region.bufferImageHeight = 128; |
| 2405 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2406 | region.imageSubresource.layerCount = 1; |
| 2407 | region.imageExtent.height = 16; |
| 2408 | region.imageExtent.width = 16; |
| 2409 | region.imageExtent.depth = 1; |
| 2410 | |
| 2411 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2412 | "Invalid usage flag for buffer "); |
| 2413 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2414 | // TRANSFER_DST |
| 2415 | BeginCommandBuffer(); |
| 2416 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2417 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2418 | 1, ®ion); |
| 2419 | m_errorMonitor->VerifyFound(); |
| 2420 | |
| 2421 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2422 | "Invalid usage flag for image "); |
| 2423 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2424 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2425 | 1, ®ion); |
| 2426 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2427 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2428 | #endif // MEM_TRACKER_TESTS |
| 2429 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2430 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2431 | |
| 2432 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2433 | VkResult err; |
| 2434 | |
| 2435 | TEST_DESCRIPTION( |
| 2436 | "Create a fence and destroy its device without first destroying the fence."); |
| 2437 | |
| 2438 | // Note that we have to create a new device since destroying the |
| 2439 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2440 | // will destroy the errorMonitor. |
| 2441 | |
| 2442 | m_errorMonitor->SetDesiredFailureMsg( |
| 2443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2444 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2445 | |
| 2446 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2447 | |
| 2448 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2449 | m_device->queue_props; |
| 2450 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2451 | queue_info.reserve(queue_props.size()); |
| 2452 | std::vector<std::vector<float>> queue_priorities; |
| 2453 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2454 | VkDeviceQueueCreateInfo qi = {}; |
| 2455 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2456 | qi.pNext = NULL; |
| 2457 | qi.queueFamilyIndex = i; |
| 2458 | qi.queueCount = queue_props[i].queueCount; |
| 2459 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2460 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2461 | queue_info.push_back(qi); |
| 2462 | } |
| 2463 | |
| 2464 | std::vector<const char *> device_layer_names; |
| 2465 | std::vector<const char *> device_extension_names; |
| 2466 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2467 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2468 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2469 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2470 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2471 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2472 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2473 | |
| 2474 | // The sacrificial device object |
| 2475 | VkDevice testDevice; |
| 2476 | VkDeviceCreateInfo device_create_info = {}; |
| 2477 | auto features = m_device->phy().features(); |
| 2478 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2479 | device_create_info.pNext = NULL; |
| 2480 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2481 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2482 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2483 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2484 | device_create_info.pEnabledFeatures = &features; |
| 2485 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2486 | ASSERT_VK_SUCCESS(err); |
| 2487 | |
| 2488 | VkFence fence; |
| 2489 | VkFenceCreateInfo fence_create_info = {}; |
| 2490 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2491 | fence_create_info.pNext = NULL; |
| 2492 | fence_create_info.flags = 0; |
| 2493 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2494 | ASSERT_VK_SUCCESS(err); |
| 2495 | |
| 2496 | // Induce failure by not calling vkDestroyFence |
| 2497 | vkDestroyDevice(testDevice, NULL); |
| 2498 | m_errorMonitor->VerifyFound(); |
| 2499 | } |
| 2500 | |
| 2501 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2502 | |
| 2503 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2504 | "attempt to delete them from another."); |
| 2505 | |
| 2506 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2507 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2508 | |
| 2509 | VkCommandPool command_pool_one; |
| 2510 | VkCommandPool command_pool_two; |
| 2511 | |
| 2512 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2513 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2514 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2515 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2516 | |
| 2517 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2518 | &command_pool_one); |
| 2519 | |
| 2520 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2521 | &command_pool_two); |
| 2522 | |
| 2523 | VkCommandBuffer command_buffer[9]; |
| 2524 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2525 | command_buffer_allocate_info.sType = |
| 2526 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2527 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2528 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2529 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2530 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2531 | command_buffer); |
| 2532 | |
| 2533 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2534 | &command_buffer[3]); |
| 2535 | |
| 2536 | m_errorMonitor->VerifyFound(); |
| 2537 | |
| 2538 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2539 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2540 | } |
| 2541 | |
| 2542 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2543 | VkResult err; |
| 2544 | |
| 2545 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2546 | "attempt to delete them from another."); |
| 2547 | |
| 2548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2549 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2550 | |
| 2551 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2552 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2553 | |
| 2554 | VkDescriptorPoolSize ds_type_count = {}; |
| 2555 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2556 | ds_type_count.descriptorCount = 1; |
| 2557 | |
| 2558 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2559 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2560 | ds_pool_ci.pNext = NULL; |
| 2561 | ds_pool_ci.flags = 0; |
| 2562 | ds_pool_ci.maxSets = 1; |
| 2563 | ds_pool_ci.poolSizeCount = 1; |
| 2564 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2565 | |
| 2566 | VkDescriptorPool ds_pool_one; |
| 2567 | err = |
| 2568 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2569 | ASSERT_VK_SUCCESS(err); |
| 2570 | |
| 2571 | // Create a second descriptor pool |
| 2572 | VkDescriptorPool ds_pool_two; |
| 2573 | err = |
| 2574 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2575 | ASSERT_VK_SUCCESS(err); |
| 2576 | |
| 2577 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2578 | dsl_binding.binding = 0; |
| 2579 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2580 | dsl_binding.descriptorCount = 1; |
| 2581 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2582 | dsl_binding.pImmutableSamplers = NULL; |
| 2583 | |
| 2584 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2585 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2586 | ds_layout_ci.pNext = NULL; |
| 2587 | ds_layout_ci.bindingCount = 1; |
| 2588 | ds_layout_ci.pBindings = &dsl_binding; |
| 2589 | |
| 2590 | VkDescriptorSetLayout ds_layout; |
| 2591 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2592 | &ds_layout); |
| 2593 | ASSERT_VK_SUCCESS(err); |
| 2594 | |
| 2595 | VkDescriptorSet descriptorSet; |
| 2596 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2597 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2598 | alloc_info.descriptorSetCount = 1; |
| 2599 | alloc_info.descriptorPool = ds_pool_one; |
| 2600 | alloc_info.pSetLayouts = &ds_layout; |
| 2601 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2602 | &descriptorSet); |
| 2603 | ASSERT_VK_SUCCESS(err); |
| 2604 | |
| 2605 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2606 | |
| 2607 | m_errorMonitor->VerifyFound(); |
| 2608 | |
| 2609 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2610 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2611 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2612 | } |
| 2613 | |
| 2614 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2615 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2616 | "Invalid VkImage Object "); |
| 2617 | |
| 2618 | TEST_DESCRIPTION( |
| 2619 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2620 | |
| 2621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2622 | |
| 2623 | // Pass bogus handle into GetImageMemoryRequirements |
| 2624 | VkMemoryRequirements mem_reqs; |
| 2625 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2626 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2627 | |
| 2628 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2629 | |
| 2630 | m_errorMonitor->VerifyFound(); |
| 2631 | } |
| 2632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2633 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2634 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2635 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2636 | TEST_DESCRIPTION( |
| 2637 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2638 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2639 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2640 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2641 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2642 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2643 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2644 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2645 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2647 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2648 | |
| 2649 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2650 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2651 | ds_pool_ci.pNext = NULL; |
| 2652 | ds_pool_ci.maxSets = 1; |
| 2653 | ds_pool_ci.poolSizeCount = 1; |
| 2654 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2655 | |
| 2656 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | err = |
| 2658 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2659 | ASSERT_VK_SUCCESS(err); |
| 2660 | |
| 2661 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2662 | dsl_binding.binding = 0; |
| 2663 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2664 | dsl_binding.descriptorCount = 1; |
| 2665 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2666 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2667 | |
| 2668 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2669 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2670 | ds_layout_ci.pNext = NULL; |
| 2671 | ds_layout_ci.bindingCount = 1; |
| 2672 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2673 | |
| 2674 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2675 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2676 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2677 | ASSERT_VK_SUCCESS(err); |
| 2678 | |
| 2679 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2680 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2681 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2682 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2683 | alloc_info.descriptorPool = ds_pool; |
| 2684 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2685 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2686 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2687 | ASSERT_VK_SUCCESS(err); |
| 2688 | |
| 2689 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2690 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2691 | pipeline_layout_ci.pNext = NULL; |
| 2692 | pipeline_layout_ci.setLayoutCount = 1; |
| 2693 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2694 | |
| 2695 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2696 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2697 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2698 | ASSERT_VK_SUCCESS(err); |
| 2699 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2700 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2701 | |
| 2702 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2703 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2704 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2705 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2706 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2707 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2708 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2709 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2710 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2711 | } |
| 2712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2713 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2714 | VkResult err; |
| 2715 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2716 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2717 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2718 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2719 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2721 | |
| 2722 | // 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] | 2723 | VkImage image; |
| 2724 | VkDeviceMemory mem; |
| 2725 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2727 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2728 | const int32_t tex_width = 32; |
| 2729 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2730 | |
| 2731 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2732 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2733 | image_create_info.pNext = NULL; |
| 2734 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2735 | image_create_info.format = tex_format; |
| 2736 | image_create_info.extent.width = tex_width; |
| 2737 | image_create_info.extent.height = tex_height; |
| 2738 | image_create_info.extent.depth = 1; |
| 2739 | image_create_info.mipLevels = 1; |
| 2740 | image_create_info.arrayLayers = 1; |
| 2741 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2742 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2743 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2744 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2745 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2746 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2747 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2748 | mem_alloc.pNext = NULL; |
| 2749 | mem_alloc.allocationSize = 0; |
| 2750 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2751 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2752 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2753 | ASSERT_VK_SUCCESS(err); |
| 2754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2755 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2756 | |
| 2757 | mem_alloc.allocationSize = mem_reqs.size; |
| 2758 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | pass = |
| 2760 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2761 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2762 | |
| 2763 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2764 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2765 | ASSERT_VK_SUCCESS(err); |
| 2766 | |
| 2767 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2768 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2769 | |
| 2770 | // Try to bind free memory that has been freed |
| 2771 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2772 | // This may very well return an error. |
| 2773 | (void)err; |
| 2774 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2775 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2776 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2777 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2778 | } |
| 2779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2780 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2781 | VkResult err; |
| 2782 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2784 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2785 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2786 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2787 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2788 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2789 | // Create an image object, allocate memory, destroy the object and then try |
| 2790 | // to bind it |
| 2791 | VkImage image; |
| 2792 | VkDeviceMemory mem; |
| 2793 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2795 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2796 | const int32_t tex_width = 32; |
| 2797 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2798 | |
| 2799 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2801 | image_create_info.pNext = NULL; |
| 2802 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2803 | image_create_info.format = tex_format; |
| 2804 | image_create_info.extent.width = tex_width; |
| 2805 | image_create_info.extent.height = tex_height; |
| 2806 | image_create_info.extent.depth = 1; |
| 2807 | image_create_info.mipLevels = 1; |
| 2808 | image_create_info.arrayLayers = 1; |
| 2809 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2810 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2811 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2812 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2813 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2814 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2815 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2816 | mem_alloc.pNext = NULL; |
| 2817 | mem_alloc.allocationSize = 0; |
| 2818 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2819 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2820 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2821 | ASSERT_VK_SUCCESS(err); |
| 2822 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2823 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2824 | |
| 2825 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2826 | pass = |
| 2827 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2828 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2829 | |
| 2830 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2831 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2832 | ASSERT_VK_SUCCESS(err); |
| 2833 | |
| 2834 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2835 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2836 | ASSERT_VK_SUCCESS(err); |
| 2837 | |
| 2838 | // Now Try to bind memory to this destroyed object |
| 2839 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2840 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2841 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2842 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2843 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2844 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2845 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2846 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2847 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2848 | #endif // OBJ_TRACKER_TESTS |
| 2849 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2850 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2851 | |
| 2852 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2853 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 2854 | TEST_DESCRIPTION( |
| 2855 | "Wait on a event then set it after the wait has been submitted."); |
| 2856 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2857 | m_errorMonitor->ExpectSuccess(); |
| 2858 | |
| 2859 | VkEvent event; |
| 2860 | VkEventCreateInfo event_create_info{}; |
| 2861 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2862 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2863 | |
| 2864 | VkCommandPool command_pool; |
| 2865 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2866 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2867 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2868 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2869 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2870 | &command_pool); |
| 2871 | |
| 2872 | VkCommandBuffer command_buffer; |
| 2873 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2874 | command_buffer_allocate_info.sType = |
| 2875 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2876 | command_buffer_allocate_info.commandPool = command_pool; |
| 2877 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2878 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2879 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2880 | &command_buffer); |
| 2881 | |
| 2882 | VkQueue queue = VK_NULL_HANDLE; |
| 2883 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 2884 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2885 | |
| 2886 | { |
| 2887 | VkCommandBufferBeginInfo begin_info{}; |
| 2888 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2889 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2890 | |
| 2891 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2892 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2893 | nullptr, 0, nullptr); |
| 2894 | vkCmdResetEvent(command_buffer, event, |
| 2895 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2896 | vkEndCommandBuffer(command_buffer); |
| 2897 | } |
| 2898 | { |
| 2899 | VkSubmitInfo submit_info{}; |
| 2900 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2901 | submit_info.commandBufferCount = 1; |
| 2902 | submit_info.pCommandBuffers = &command_buffer; |
| 2903 | submit_info.signalSemaphoreCount = 0; |
| 2904 | submit_info.pSignalSemaphores = nullptr; |
| 2905 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2906 | } |
| 2907 | { vkSetEvent(m_device->device(), event); } |
| 2908 | |
| 2909 | vkQueueWaitIdle(queue); |
| 2910 | |
| 2911 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2912 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2913 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2914 | |
| 2915 | m_errorMonitor->VerifyNotFound(); |
| 2916 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2917 | // This is a positive test. No errors should be generated. |
| 2918 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2919 | TEST_DESCRIPTION( |
| 2920 | "Issue a query and copy from it on a second command buffer."); |
| 2921 | |
| 2922 | if ((m_device->queue_props.empty()) || |
| 2923 | (m_device->queue_props[0].queueCount < 2)) |
| 2924 | return; |
| 2925 | |
| 2926 | m_errorMonitor->ExpectSuccess(); |
| 2927 | |
| 2928 | VkQueryPool query_pool; |
| 2929 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2930 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2931 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2932 | query_pool_create_info.queryCount = 1; |
| 2933 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2934 | &query_pool); |
| 2935 | |
| 2936 | VkCommandPool command_pool; |
| 2937 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2938 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2939 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2940 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2941 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2942 | &command_pool); |
| 2943 | |
| 2944 | VkCommandBuffer command_buffer[2]; |
| 2945 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2946 | command_buffer_allocate_info.sType = |
| 2947 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2948 | command_buffer_allocate_info.commandPool = command_pool; |
| 2949 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2950 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2951 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2952 | command_buffer); |
| 2953 | |
| 2954 | VkQueue queue = VK_NULL_HANDLE; |
| 2955 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2956 | 1, &queue); |
| 2957 | |
| 2958 | uint32_t qfi = 0; |
| 2959 | VkBufferCreateInfo buff_create_info = {}; |
| 2960 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2961 | buff_create_info.size = 1024; |
| 2962 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2963 | buff_create_info.queueFamilyIndexCount = 1; |
| 2964 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2965 | |
| 2966 | VkResult err; |
| 2967 | VkBuffer buffer; |
| 2968 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2969 | ASSERT_VK_SUCCESS(err); |
| 2970 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2971 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2972 | mem_alloc.pNext = NULL; |
| 2973 | mem_alloc.allocationSize = 1024; |
| 2974 | mem_alloc.memoryTypeIndex = 0; |
| 2975 | |
| 2976 | VkMemoryRequirements memReqs; |
| 2977 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2978 | bool pass = |
| 2979 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2980 | if (!pass) { |
| 2981 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2982 | return; |
| 2983 | } |
| 2984 | |
| 2985 | VkDeviceMemory mem; |
| 2986 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2987 | ASSERT_VK_SUCCESS(err); |
| 2988 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2989 | ASSERT_VK_SUCCESS(err); |
| 2990 | |
| 2991 | { |
| 2992 | VkCommandBufferBeginInfo begin_info{}; |
| 2993 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2994 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2995 | |
| 2996 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2997 | vkCmdWriteTimestamp(command_buffer[0], |
| 2998 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2999 | |
| 3000 | vkEndCommandBuffer(command_buffer[0]); |
| 3001 | |
| 3002 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3003 | |
| 3004 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 3005 | 0, 0, 0); |
| 3006 | |
| 3007 | vkEndCommandBuffer(command_buffer[1]); |
| 3008 | } |
| 3009 | { |
| 3010 | VkSubmitInfo submit_info{}; |
| 3011 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3012 | submit_info.commandBufferCount = 2; |
| 3013 | submit_info.pCommandBuffers = command_buffer; |
| 3014 | submit_info.signalSemaphoreCount = 0; |
| 3015 | submit_info.pSignalSemaphores = nullptr; |
| 3016 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3017 | } |
| 3018 | |
| 3019 | vkQueueWaitIdle(queue); |
| 3020 | |
| 3021 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 3022 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 3023 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3024 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3025 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3026 | |
| 3027 | m_errorMonitor->VerifyNotFound(); |
| 3028 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3029 | |
| 3030 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 3031 | TEST_DESCRIPTION( |
| 3032 | "Reset an event then set it after the reset has been submitted."); |
| 3033 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3034 | m_errorMonitor->ExpectSuccess(); |
| 3035 | |
| 3036 | VkEvent event; |
| 3037 | VkEventCreateInfo event_create_info{}; |
| 3038 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3039 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3040 | |
| 3041 | VkCommandPool command_pool; |
| 3042 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3043 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3044 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3045 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3046 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3047 | &command_pool); |
| 3048 | |
| 3049 | VkCommandBuffer command_buffer; |
| 3050 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3051 | command_buffer_allocate_info.sType = |
| 3052 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3053 | command_buffer_allocate_info.commandPool = command_pool; |
| 3054 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3055 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3056 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3057 | &command_buffer); |
| 3058 | |
| 3059 | VkQueue queue = VK_NULL_HANDLE; |
| 3060 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3061 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3062 | |
| 3063 | { |
| 3064 | VkCommandBufferBeginInfo begin_info{}; |
| 3065 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3066 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3067 | |
| 3068 | vkCmdResetEvent(command_buffer, event, |
| 3069 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3070 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 3071 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3072 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3073 | nullptr, 0, nullptr); |
| 3074 | vkEndCommandBuffer(command_buffer); |
| 3075 | } |
| 3076 | { |
| 3077 | VkSubmitInfo submit_info{}; |
| 3078 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3079 | submit_info.commandBufferCount = 1; |
| 3080 | submit_info.pCommandBuffers = &command_buffer; |
| 3081 | submit_info.signalSemaphoreCount = 0; |
| 3082 | submit_info.pSignalSemaphores = nullptr; |
| 3083 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3084 | } |
| 3085 | { |
| 3086 | m_errorMonitor->SetDesiredFailureMsg( |
| 3087 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 3088 | "0x1 that is already in use by a " |
| 3089 | "command buffer."); |
| 3090 | vkSetEvent(m_device->device(), event); |
| 3091 | m_errorMonitor->VerifyFound(); |
| 3092 | } |
| 3093 | |
| 3094 | vkQueueWaitIdle(queue); |
| 3095 | |
| 3096 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3097 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3098 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3099 | } |
| 3100 | |
| 3101 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3102 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 3103 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 3104 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 3105 | "previously revealed a bug so running this positive test " |
| 3106 | "to prevent a regression."); |
| 3107 | m_errorMonitor->ExpectSuccess(); |
| 3108 | |
| 3109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3110 | VkQueue queue = VK_NULL_HANDLE; |
| 3111 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3112 | 0, &queue); |
| 3113 | |
| 3114 | static const uint32_t NUM_OBJECTS = 2; |
| 3115 | static const uint32_t NUM_FRAMES = 3; |
| 3116 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 3117 | VkFence fences[NUM_OBJECTS] = {}; |
| 3118 | |
| 3119 | VkCommandPool cmd_pool; |
| 3120 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 3121 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3122 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3123 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3124 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3125 | nullptr, &cmd_pool); |
| 3126 | ASSERT_VK_SUCCESS(err); |
| 3127 | |
| 3128 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3129 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3130 | cmd_buf_info.commandPool = cmd_pool; |
| 3131 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3132 | cmd_buf_info.commandBufferCount = 1; |
| 3133 | |
| 3134 | VkFenceCreateInfo fence_ci = {}; |
| 3135 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3136 | fence_ci.pNext = nullptr; |
| 3137 | fence_ci.flags = 0; |
| 3138 | |
| 3139 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3140 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3141 | &cmd_buffers[i]); |
| 3142 | ASSERT_VK_SUCCESS(err); |
| 3143 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3144 | ASSERT_VK_SUCCESS(err); |
| 3145 | } |
| 3146 | |
| 3147 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3148 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3149 | // Create empty cmd buffer |
| 3150 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3151 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3152 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3153 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3154 | ASSERT_VK_SUCCESS(err); |
| 3155 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3156 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3157 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3158 | VkSubmitInfo submit_info = {}; |
| 3159 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3160 | submit_info.commandBufferCount = 1; |
| 3161 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3162 | // Submit cmd buffer and wait for fence |
| 3163 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3164 | ASSERT_VK_SUCCESS(err); |
| 3165 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3166 | UINT64_MAX); |
| 3167 | ASSERT_VK_SUCCESS(err); |
| 3168 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3169 | ASSERT_VK_SUCCESS(err); |
| 3170 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3171 | } |
| 3172 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3173 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3174 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3175 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3176 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3177 | } |
| 3178 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3179 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3180 | |
| 3181 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3182 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3183 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3184 | if ((m_device->queue_props.empty()) || |
| 3185 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3186 | return; |
| 3187 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3188 | m_errorMonitor->ExpectSuccess(); |
| 3189 | |
| 3190 | VkSemaphore semaphore; |
| 3191 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3192 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3193 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3194 | &semaphore); |
| 3195 | |
| 3196 | VkCommandPool command_pool; |
| 3197 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3198 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3199 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3200 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3201 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3202 | &command_pool); |
| 3203 | |
| 3204 | VkCommandBuffer command_buffer[2]; |
| 3205 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3206 | command_buffer_allocate_info.sType = |
| 3207 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3208 | command_buffer_allocate_info.commandPool = command_pool; |
| 3209 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3210 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3211 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3212 | command_buffer); |
| 3213 | |
| 3214 | VkQueue queue = VK_NULL_HANDLE; |
| 3215 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3216 | 1, &queue); |
| 3217 | |
| 3218 | { |
| 3219 | VkCommandBufferBeginInfo begin_info{}; |
| 3220 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3221 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3222 | |
| 3223 | vkCmdPipelineBarrier(command_buffer[0], |
| 3224 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3225 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3226 | 0, nullptr, 0, nullptr); |
| 3227 | |
| 3228 | VkViewport viewport{}; |
| 3229 | viewport.maxDepth = 1.0f; |
| 3230 | viewport.minDepth = 0.0f; |
| 3231 | viewport.width = 512; |
| 3232 | viewport.height = 512; |
| 3233 | viewport.x = 0; |
| 3234 | viewport.y = 0; |
| 3235 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3236 | vkEndCommandBuffer(command_buffer[0]); |
| 3237 | } |
| 3238 | { |
| 3239 | VkCommandBufferBeginInfo begin_info{}; |
| 3240 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3241 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3242 | |
| 3243 | VkViewport viewport{}; |
| 3244 | viewport.maxDepth = 1.0f; |
| 3245 | viewport.minDepth = 0.0f; |
| 3246 | viewport.width = 512; |
| 3247 | viewport.height = 512; |
| 3248 | viewport.x = 0; |
| 3249 | viewport.y = 0; |
| 3250 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3251 | vkEndCommandBuffer(command_buffer[1]); |
| 3252 | } |
| 3253 | { |
| 3254 | VkSubmitInfo submit_info{}; |
| 3255 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3256 | submit_info.commandBufferCount = 1; |
| 3257 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3258 | submit_info.signalSemaphoreCount = 1; |
| 3259 | submit_info.pSignalSemaphores = &semaphore; |
| 3260 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3261 | } |
| 3262 | { |
| 3263 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3264 | VkSubmitInfo submit_info{}; |
| 3265 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3266 | submit_info.commandBufferCount = 1; |
| 3267 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3268 | submit_info.waitSemaphoreCount = 1; |
| 3269 | submit_info.pWaitSemaphores = &semaphore; |
| 3270 | submit_info.pWaitDstStageMask = flags; |
| 3271 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3272 | } |
| 3273 | |
| 3274 | vkQueueWaitIdle(m_device->m_queue); |
| 3275 | |
| 3276 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3277 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3278 | &command_buffer[0]); |
| 3279 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3280 | |
| 3281 | m_errorMonitor->VerifyNotFound(); |
| 3282 | } |
| 3283 | |
| 3284 | // This is a positive test. No errors should be generated. |
| 3285 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3286 | |
| 3287 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3288 | "submitted on separate queues, the second having a fence" |
| 3289 | "followed by a QueueWaitIdle."); |
| 3290 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3291 | if ((m_device->queue_props.empty()) || |
| 3292 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3293 | return; |
| 3294 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3295 | m_errorMonitor->ExpectSuccess(); |
| 3296 | |
| 3297 | VkFence fence; |
| 3298 | VkFenceCreateInfo fence_create_info{}; |
| 3299 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3300 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3301 | |
| 3302 | VkSemaphore semaphore; |
| 3303 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3304 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3305 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3306 | &semaphore); |
| 3307 | |
| 3308 | VkCommandPool command_pool; |
| 3309 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3310 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3311 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3312 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3313 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3314 | &command_pool); |
| 3315 | |
| 3316 | VkCommandBuffer command_buffer[2]; |
| 3317 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3318 | command_buffer_allocate_info.sType = |
| 3319 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3320 | command_buffer_allocate_info.commandPool = command_pool; |
| 3321 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3322 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3323 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3324 | command_buffer); |
| 3325 | |
| 3326 | VkQueue queue = VK_NULL_HANDLE; |
| 3327 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3328 | 1, &queue); |
| 3329 | |
| 3330 | { |
| 3331 | VkCommandBufferBeginInfo begin_info{}; |
| 3332 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3333 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3334 | |
| 3335 | vkCmdPipelineBarrier(command_buffer[0], |
| 3336 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3337 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3338 | 0, nullptr, 0, nullptr); |
| 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[0], 0, 1, &viewport); |
| 3348 | vkEndCommandBuffer(command_buffer[0]); |
| 3349 | } |
| 3350 | { |
| 3351 | VkCommandBufferBeginInfo begin_info{}; |
| 3352 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3353 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3354 | |
| 3355 | VkViewport viewport{}; |
| 3356 | viewport.maxDepth = 1.0f; |
| 3357 | viewport.minDepth = 0.0f; |
| 3358 | viewport.width = 512; |
| 3359 | viewport.height = 512; |
| 3360 | viewport.x = 0; |
| 3361 | viewport.y = 0; |
| 3362 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3363 | vkEndCommandBuffer(command_buffer[1]); |
| 3364 | } |
| 3365 | { |
| 3366 | VkSubmitInfo submit_info{}; |
| 3367 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3368 | submit_info.commandBufferCount = 1; |
| 3369 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3370 | submit_info.signalSemaphoreCount = 1; |
| 3371 | submit_info.pSignalSemaphores = &semaphore; |
| 3372 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3373 | } |
| 3374 | { |
| 3375 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3376 | VkSubmitInfo submit_info{}; |
| 3377 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3378 | submit_info.commandBufferCount = 1; |
| 3379 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3380 | submit_info.waitSemaphoreCount = 1; |
| 3381 | submit_info.pWaitSemaphores = &semaphore; |
| 3382 | submit_info.pWaitDstStageMask = flags; |
| 3383 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3384 | } |
| 3385 | |
| 3386 | vkQueueWaitIdle(m_device->m_queue); |
| 3387 | |
| 3388 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3389 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3390 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3391 | &command_buffer[0]); |
| 3392 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3393 | |
| 3394 | m_errorMonitor->VerifyNotFound(); |
| 3395 | } |
| 3396 | |
| 3397 | // This is a positive test. No errors should be generated. |
| 3398 | TEST_F(VkLayerTest, |
| 3399 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3400 | |
| 3401 | TEST_DESCRIPTION( |
| 3402 | "Two command buffers, each in a separate QueueSubmit call " |
| 3403 | "submitted on separate queues, the second having a fence" |
| 3404 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3405 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3406 | if ((m_device->queue_props.empty()) || |
| 3407 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3408 | return; |
| 3409 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3410 | m_errorMonitor->ExpectSuccess(); |
| 3411 | |
| 3412 | VkFence fence; |
| 3413 | VkFenceCreateInfo fence_create_info{}; |
| 3414 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3415 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3416 | |
| 3417 | VkSemaphore semaphore; |
| 3418 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3419 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3420 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3421 | &semaphore); |
| 3422 | |
| 3423 | VkCommandPool command_pool; |
| 3424 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3425 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3426 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3427 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3428 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3429 | &command_pool); |
| 3430 | |
| 3431 | VkCommandBuffer command_buffer[2]; |
| 3432 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3433 | command_buffer_allocate_info.sType = |
| 3434 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3435 | command_buffer_allocate_info.commandPool = command_pool; |
| 3436 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3437 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3438 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3439 | command_buffer); |
| 3440 | |
| 3441 | VkQueue queue = VK_NULL_HANDLE; |
| 3442 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3443 | 1, &queue); |
| 3444 | |
| 3445 | { |
| 3446 | VkCommandBufferBeginInfo begin_info{}; |
| 3447 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3448 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3449 | |
| 3450 | vkCmdPipelineBarrier(command_buffer[0], |
| 3451 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3452 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3453 | 0, nullptr, 0, nullptr); |
| 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[0], 0, 1, &viewport); |
| 3463 | vkEndCommandBuffer(command_buffer[0]); |
| 3464 | } |
| 3465 | { |
| 3466 | VkCommandBufferBeginInfo begin_info{}; |
| 3467 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3468 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3469 | |
| 3470 | VkViewport viewport{}; |
| 3471 | viewport.maxDepth = 1.0f; |
| 3472 | viewport.minDepth = 0.0f; |
| 3473 | viewport.width = 512; |
| 3474 | viewport.height = 512; |
| 3475 | viewport.x = 0; |
| 3476 | viewport.y = 0; |
| 3477 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3478 | vkEndCommandBuffer(command_buffer[1]); |
| 3479 | } |
| 3480 | { |
| 3481 | VkSubmitInfo submit_info{}; |
| 3482 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3483 | submit_info.commandBufferCount = 1; |
| 3484 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3485 | submit_info.signalSemaphoreCount = 1; |
| 3486 | submit_info.pSignalSemaphores = &semaphore; |
| 3487 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3488 | } |
| 3489 | { |
| 3490 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3491 | VkSubmitInfo submit_info{}; |
| 3492 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3493 | submit_info.commandBufferCount = 1; |
| 3494 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3495 | submit_info.waitSemaphoreCount = 1; |
| 3496 | submit_info.pWaitSemaphores = &semaphore; |
| 3497 | submit_info.pWaitDstStageMask = flags; |
| 3498 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3499 | } |
| 3500 | |
| 3501 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3502 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3503 | |
| 3504 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3505 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3506 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3507 | &command_buffer[0]); |
| 3508 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3509 | |
| 3510 | m_errorMonitor->VerifyNotFound(); |
| 3511 | } |
| 3512 | |
| 3513 | // This is a positive test. No errors should be generated. |
| 3514 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3515 | |
| 3516 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3517 | "submitted on separate queues, the second having a fence, " |
| 3518 | "followed by a WaitForFences call."); |
| 3519 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3520 | if ((m_device->queue_props.empty()) || |
| 3521 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3522 | return; |
| 3523 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3524 | m_errorMonitor->ExpectSuccess(); |
| 3525 | |
| 3526 | VkFence fence; |
| 3527 | VkFenceCreateInfo fence_create_info{}; |
| 3528 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3529 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3530 | |
| 3531 | VkSemaphore semaphore; |
| 3532 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3533 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3534 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3535 | &semaphore); |
| 3536 | |
| 3537 | VkCommandPool command_pool; |
| 3538 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3539 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3540 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3541 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3542 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3543 | &command_pool); |
| 3544 | |
| 3545 | VkCommandBuffer command_buffer[2]; |
| 3546 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3547 | command_buffer_allocate_info.sType = |
| 3548 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3549 | command_buffer_allocate_info.commandPool = command_pool; |
| 3550 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3551 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3552 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3553 | command_buffer); |
| 3554 | |
| 3555 | VkQueue queue = VK_NULL_HANDLE; |
| 3556 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3557 | 1, &queue); |
| 3558 | |
| 3559 | |
| 3560 | { |
| 3561 | VkCommandBufferBeginInfo begin_info{}; |
| 3562 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3563 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3564 | |
| 3565 | vkCmdPipelineBarrier(command_buffer[0], |
| 3566 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3567 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3568 | 0, nullptr, 0, nullptr); |
| 3569 | |
| 3570 | VkViewport viewport{}; |
| 3571 | viewport.maxDepth = 1.0f; |
| 3572 | viewport.minDepth = 0.0f; |
| 3573 | viewport.width = 512; |
| 3574 | viewport.height = 512; |
| 3575 | viewport.x = 0; |
| 3576 | viewport.y = 0; |
| 3577 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3578 | vkEndCommandBuffer(command_buffer[0]); |
| 3579 | } |
| 3580 | { |
| 3581 | VkCommandBufferBeginInfo begin_info{}; |
| 3582 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3583 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3584 | |
| 3585 | VkViewport viewport{}; |
| 3586 | viewport.maxDepth = 1.0f; |
| 3587 | viewport.minDepth = 0.0f; |
| 3588 | viewport.width = 512; |
| 3589 | viewport.height = 512; |
| 3590 | viewport.x = 0; |
| 3591 | viewport.y = 0; |
| 3592 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3593 | vkEndCommandBuffer(command_buffer[1]); |
| 3594 | } |
| 3595 | { |
| 3596 | VkSubmitInfo submit_info{}; |
| 3597 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3598 | submit_info.commandBufferCount = 1; |
| 3599 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3600 | submit_info.signalSemaphoreCount = 1; |
| 3601 | submit_info.pSignalSemaphores = &semaphore; |
| 3602 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3603 | } |
| 3604 | { |
| 3605 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3606 | VkSubmitInfo submit_info{}; |
| 3607 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3608 | submit_info.commandBufferCount = 1; |
| 3609 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3610 | submit_info.waitSemaphoreCount = 1; |
| 3611 | submit_info.pWaitSemaphores = &semaphore; |
| 3612 | submit_info.pWaitDstStageMask = flags; |
| 3613 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3614 | } |
| 3615 | |
| 3616 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3617 | |
| 3618 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3619 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3620 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3621 | &command_buffer[0]); |
| 3622 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3623 | |
| 3624 | m_errorMonitor->VerifyNotFound(); |
| 3625 | } |
| 3626 | |
| 3627 | // This is a positive test. No errors should be generated. |
| 3628 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3629 | |
| 3630 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3631 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3632 | "second having a fence, " |
| 3633 | "followed by a WaitForFences call."); |
| 3634 | |
| 3635 | m_errorMonitor->ExpectSuccess(); |
| 3636 | |
| 3637 | VkFence fence; |
| 3638 | VkFenceCreateInfo fence_create_info{}; |
| 3639 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3640 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3641 | |
| 3642 | VkSemaphore semaphore; |
| 3643 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3644 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3645 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3646 | &semaphore); |
| 3647 | |
| 3648 | VkCommandPool command_pool; |
| 3649 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3650 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3651 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3652 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3653 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3654 | &command_pool); |
| 3655 | |
| 3656 | VkCommandBuffer command_buffer[2]; |
| 3657 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3658 | command_buffer_allocate_info.sType = |
| 3659 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3660 | command_buffer_allocate_info.commandPool = command_pool; |
| 3661 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3662 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3663 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3664 | command_buffer); |
| 3665 | |
| 3666 | { |
| 3667 | VkCommandBufferBeginInfo begin_info{}; |
| 3668 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3669 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3670 | |
| 3671 | vkCmdPipelineBarrier(command_buffer[0], |
| 3672 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3673 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3674 | 0, nullptr, 0, nullptr); |
| 3675 | |
| 3676 | VkViewport viewport{}; |
| 3677 | viewport.maxDepth = 1.0f; |
| 3678 | viewport.minDepth = 0.0f; |
| 3679 | viewport.width = 512; |
| 3680 | viewport.height = 512; |
| 3681 | viewport.x = 0; |
| 3682 | viewport.y = 0; |
| 3683 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3684 | vkEndCommandBuffer(command_buffer[0]); |
| 3685 | } |
| 3686 | { |
| 3687 | VkCommandBufferBeginInfo begin_info{}; |
| 3688 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3689 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3690 | |
| 3691 | VkViewport viewport{}; |
| 3692 | viewport.maxDepth = 1.0f; |
| 3693 | viewport.minDepth = 0.0f; |
| 3694 | viewport.width = 512; |
| 3695 | viewport.height = 512; |
| 3696 | viewport.x = 0; |
| 3697 | viewport.y = 0; |
| 3698 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3699 | vkEndCommandBuffer(command_buffer[1]); |
| 3700 | } |
| 3701 | { |
| 3702 | VkSubmitInfo submit_info{}; |
| 3703 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3704 | submit_info.commandBufferCount = 1; |
| 3705 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3706 | submit_info.signalSemaphoreCount = 1; |
| 3707 | submit_info.pSignalSemaphores = &semaphore; |
| 3708 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3709 | } |
| 3710 | { |
| 3711 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3712 | VkSubmitInfo submit_info{}; |
| 3713 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3714 | submit_info.commandBufferCount = 1; |
| 3715 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3716 | submit_info.waitSemaphoreCount = 1; |
| 3717 | submit_info.pWaitSemaphores = &semaphore; |
| 3718 | submit_info.pWaitDstStageMask = flags; |
| 3719 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3720 | } |
| 3721 | |
| 3722 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3723 | |
| 3724 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3725 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3726 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3727 | &command_buffer[0]); |
| 3728 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3729 | |
| 3730 | m_errorMonitor->VerifyNotFound(); |
| 3731 | } |
| 3732 | |
| 3733 | // This is a positive test. No errors should be generated. |
| 3734 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3735 | |
| 3736 | TEST_DESCRIPTION( |
| 3737 | "Two command buffers, each in a separate QueueSubmit call " |
| 3738 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3739 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3740 | |
| 3741 | m_errorMonitor->ExpectSuccess(); |
| 3742 | |
| 3743 | VkFence fence; |
| 3744 | VkFenceCreateInfo fence_create_info{}; |
| 3745 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3746 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3747 | |
| 3748 | VkCommandPool command_pool; |
| 3749 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3750 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3751 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3752 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3753 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3754 | &command_pool); |
| 3755 | |
| 3756 | VkCommandBuffer command_buffer[2]; |
| 3757 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3758 | command_buffer_allocate_info.sType = |
| 3759 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3760 | command_buffer_allocate_info.commandPool = command_pool; |
| 3761 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3762 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3763 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3764 | command_buffer); |
| 3765 | |
| 3766 | { |
| 3767 | VkCommandBufferBeginInfo begin_info{}; |
| 3768 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3769 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3770 | |
| 3771 | vkCmdPipelineBarrier(command_buffer[0], |
| 3772 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3773 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3774 | 0, nullptr, 0, nullptr); |
| 3775 | |
| 3776 | VkViewport viewport{}; |
| 3777 | viewport.maxDepth = 1.0f; |
| 3778 | viewport.minDepth = 0.0f; |
| 3779 | viewport.width = 512; |
| 3780 | viewport.height = 512; |
| 3781 | viewport.x = 0; |
| 3782 | viewport.y = 0; |
| 3783 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3784 | vkEndCommandBuffer(command_buffer[0]); |
| 3785 | } |
| 3786 | { |
| 3787 | VkCommandBufferBeginInfo begin_info{}; |
| 3788 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3789 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3790 | |
| 3791 | VkViewport viewport{}; |
| 3792 | viewport.maxDepth = 1.0f; |
| 3793 | viewport.minDepth = 0.0f; |
| 3794 | viewport.width = 512; |
| 3795 | viewport.height = 512; |
| 3796 | viewport.x = 0; |
| 3797 | viewport.y = 0; |
| 3798 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3799 | vkEndCommandBuffer(command_buffer[1]); |
| 3800 | } |
| 3801 | { |
| 3802 | VkSubmitInfo submit_info{}; |
| 3803 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3804 | submit_info.commandBufferCount = 1; |
| 3805 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3806 | submit_info.signalSemaphoreCount = 0; |
| 3807 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3808 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3809 | } |
| 3810 | { |
| 3811 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3812 | VkSubmitInfo submit_info{}; |
| 3813 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3814 | submit_info.commandBufferCount = 1; |
| 3815 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3816 | submit_info.waitSemaphoreCount = 0; |
| 3817 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3818 | submit_info.pWaitDstStageMask = flags; |
| 3819 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3820 | } |
| 3821 | |
| 3822 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3823 | |
| 3824 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3825 | |
| 3826 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3827 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3828 | &command_buffer[0]); |
| 3829 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3830 | |
| 3831 | m_errorMonitor->VerifyNotFound(); |
| 3832 | } |
| 3833 | |
| 3834 | // This is a positive test. No errors should be generated. |
| 3835 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3836 | |
| 3837 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3838 | "on the same queue, the second having a fence, followed " |
| 3839 | "by a WaitForFences call."); |
| 3840 | |
| 3841 | m_errorMonitor->ExpectSuccess(); |
| 3842 | |
| 3843 | VkFence fence; |
| 3844 | VkFenceCreateInfo fence_create_info{}; |
| 3845 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3846 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3847 | |
| 3848 | VkCommandPool command_pool; |
| 3849 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3850 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3851 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3852 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3853 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3854 | &command_pool); |
| 3855 | |
| 3856 | VkCommandBuffer command_buffer[2]; |
| 3857 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3858 | command_buffer_allocate_info.sType = |
| 3859 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3860 | command_buffer_allocate_info.commandPool = command_pool; |
| 3861 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3862 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3863 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3864 | command_buffer); |
| 3865 | |
| 3866 | { |
| 3867 | VkCommandBufferBeginInfo begin_info{}; |
| 3868 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3869 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3870 | |
| 3871 | vkCmdPipelineBarrier(command_buffer[0], |
| 3872 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3873 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3874 | 0, nullptr, 0, nullptr); |
| 3875 | |
| 3876 | VkViewport viewport{}; |
| 3877 | viewport.maxDepth = 1.0f; |
| 3878 | viewport.minDepth = 0.0f; |
| 3879 | viewport.width = 512; |
| 3880 | viewport.height = 512; |
| 3881 | viewport.x = 0; |
| 3882 | viewport.y = 0; |
| 3883 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3884 | vkEndCommandBuffer(command_buffer[0]); |
| 3885 | } |
| 3886 | { |
| 3887 | VkCommandBufferBeginInfo begin_info{}; |
| 3888 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3889 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3890 | |
| 3891 | VkViewport viewport{}; |
| 3892 | viewport.maxDepth = 1.0f; |
| 3893 | viewport.minDepth = 0.0f; |
| 3894 | viewport.width = 512; |
| 3895 | viewport.height = 512; |
| 3896 | viewport.x = 0; |
| 3897 | viewport.y = 0; |
| 3898 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3899 | vkEndCommandBuffer(command_buffer[1]); |
| 3900 | } |
| 3901 | { |
| 3902 | VkSubmitInfo submit_info{}; |
| 3903 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3904 | submit_info.commandBufferCount = 1; |
| 3905 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3906 | submit_info.signalSemaphoreCount = 0; |
| 3907 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3908 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3909 | } |
| 3910 | { |
| 3911 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3912 | VkSubmitInfo submit_info{}; |
| 3913 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3914 | submit_info.commandBufferCount = 1; |
| 3915 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3916 | submit_info.waitSemaphoreCount = 0; |
| 3917 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3918 | submit_info.pWaitDstStageMask = flags; |
| 3919 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3920 | } |
| 3921 | |
| 3922 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3923 | |
| 3924 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3925 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3926 | &command_buffer[0]); |
| 3927 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3928 | |
| 3929 | m_errorMonitor->VerifyNotFound(); |
| 3930 | } |
| 3931 | |
| 3932 | // This is a positive test. No errors should be generated. |
| 3933 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3934 | |
| 3935 | TEST_DESCRIPTION( |
| 3936 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3937 | "QueueSubmit call followed by a WaitForFences call."); |
| 3938 | |
| 3939 | m_errorMonitor->ExpectSuccess(); |
| 3940 | |
| 3941 | VkFence fence; |
| 3942 | VkFenceCreateInfo fence_create_info{}; |
| 3943 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3944 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3945 | |
| 3946 | VkSemaphore semaphore; |
| 3947 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3948 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3949 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3950 | &semaphore); |
| 3951 | |
| 3952 | VkCommandPool command_pool; |
| 3953 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3954 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3955 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3956 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3957 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3958 | &command_pool); |
| 3959 | |
| 3960 | VkCommandBuffer command_buffer[2]; |
| 3961 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3962 | command_buffer_allocate_info.sType = |
| 3963 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3964 | command_buffer_allocate_info.commandPool = command_pool; |
| 3965 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3966 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3967 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3968 | command_buffer); |
| 3969 | |
| 3970 | { |
| 3971 | VkCommandBufferBeginInfo begin_info{}; |
| 3972 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3973 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3974 | |
| 3975 | vkCmdPipelineBarrier(command_buffer[0], |
| 3976 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3977 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3978 | 0, nullptr, 0, nullptr); |
| 3979 | |
| 3980 | VkViewport viewport{}; |
| 3981 | viewport.maxDepth = 1.0f; |
| 3982 | viewport.minDepth = 0.0f; |
| 3983 | viewport.width = 512; |
| 3984 | viewport.height = 512; |
| 3985 | viewport.x = 0; |
| 3986 | viewport.y = 0; |
| 3987 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3988 | vkEndCommandBuffer(command_buffer[0]); |
| 3989 | } |
| 3990 | { |
| 3991 | VkCommandBufferBeginInfo begin_info{}; |
| 3992 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3993 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3994 | |
| 3995 | VkViewport viewport{}; |
| 3996 | viewport.maxDepth = 1.0f; |
| 3997 | viewport.minDepth = 0.0f; |
| 3998 | viewport.width = 512; |
| 3999 | viewport.height = 512; |
| 4000 | viewport.x = 0; |
| 4001 | viewport.y = 0; |
| 4002 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4003 | vkEndCommandBuffer(command_buffer[1]); |
| 4004 | } |
| 4005 | { |
| 4006 | VkSubmitInfo submit_info[2]; |
| 4007 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4008 | |
| 4009 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4010 | submit_info[0].pNext = NULL; |
| 4011 | submit_info[0].commandBufferCount = 1; |
| 4012 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 4013 | submit_info[0].signalSemaphoreCount = 1; |
| 4014 | submit_info[0].pSignalSemaphores = &semaphore; |
| 4015 | submit_info[0].waitSemaphoreCount = 0; |
| 4016 | submit_info[0].pWaitSemaphores = NULL; |
| 4017 | submit_info[0].pWaitDstStageMask = 0; |
| 4018 | |
| 4019 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4020 | submit_info[1].pNext = NULL; |
| 4021 | submit_info[1].commandBufferCount = 1; |
| 4022 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 4023 | submit_info[1].waitSemaphoreCount = 1; |
| 4024 | submit_info[1].pWaitSemaphores = &semaphore; |
| 4025 | submit_info[1].pWaitDstStageMask = flags; |
| 4026 | submit_info[1].signalSemaphoreCount = 0; |
| 4027 | submit_info[1].pSignalSemaphores = NULL; |
| 4028 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 4029 | } |
| 4030 | |
| 4031 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4032 | |
| 4033 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4034 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4035 | &command_buffer[0]); |
| 4036 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4037 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4038 | |
| 4039 | m_errorMonitor->VerifyNotFound(); |
| 4040 | } |
| 4041 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4042 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4043 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4044 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 4045 | "state is required but not correctly bound."); |
| 4046 | |
| 4047 | // Dynamic depth bias |
| 4048 | m_errorMonitor->SetDesiredFailureMsg( |
| 4049 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4050 | "Dynamic depth bias state not set for this command buffer"); |
| 4051 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4052 | BsoFailDepthBias); |
| 4053 | m_errorMonitor->VerifyFound(); |
| 4054 | } |
| 4055 | |
| 4056 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 4057 | TEST_DESCRIPTION( |
| 4058 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 4059 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4060 | |
| 4061 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4062 | m_errorMonitor->SetDesiredFailureMsg( |
| 4063 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4064 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4065 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4066 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4067 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4068 | } |
| 4069 | |
| 4070 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 4071 | TEST_DESCRIPTION( |
| 4072 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 4073 | "state is required but not correctly bound."); |
| 4074 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4075 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4076 | m_errorMonitor->SetDesiredFailureMsg( |
| 4077 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4078 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4079 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4080 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4081 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4082 | } |
| 4083 | |
| 4084 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 4085 | TEST_DESCRIPTION( |
| 4086 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 4087 | "state is required but not correctly bound."); |
| 4088 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4089 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | m_errorMonitor->SetDesiredFailureMsg( |
| 4091 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4092 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4093 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4094 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4095 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4096 | } |
| 4097 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4098 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4099 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4100 | "Run a simple draw calls to validate failure when Blend Constants " |
| 4101 | "dynamic state is required but not correctly bound."); |
| 4102 | // Dynamic blend constant state |
| 4103 | m_errorMonitor->SetDesiredFailureMsg( |
| 4104 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4105 | "Dynamic blend constants state not set for this command buffer"); |
| 4106 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4107 | BsoFailBlend); |
| 4108 | m_errorMonitor->VerifyFound(); |
| 4109 | } |
| 4110 | |
| 4111 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 4112 | TEST_DESCRIPTION( |
| 4113 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4114 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4115 | if (!m_device->phy().features().depthBounds) { |
| 4116 | printf("Device does not support depthBounds test; skipped.\n"); |
| 4117 | return; |
| 4118 | } |
| 4119 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4120 | m_errorMonitor->SetDesiredFailureMsg( |
| 4121 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4122 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4123 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4124 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4125 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4129 | TEST_DESCRIPTION( |
| 4130 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4131 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4132 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | m_errorMonitor->SetDesiredFailureMsg( |
| 4134 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4135 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4136 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4137 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4138 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4139 | } |
| 4140 | |
| 4141 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4142 | TEST_DESCRIPTION( |
| 4143 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4144 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4145 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4146 | m_errorMonitor->SetDesiredFailureMsg( |
| 4147 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4148 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4149 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4150 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4151 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4152 | } |
| 4153 | |
| 4154 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4155 | TEST_DESCRIPTION( |
| 4156 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4157 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4158 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4159 | m_errorMonitor->SetDesiredFailureMsg( |
| 4160 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4161 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4162 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4163 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4164 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4165 | } |
| 4166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4168 | m_errorMonitor->SetDesiredFailureMsg( |
| 4169 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4170 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4171 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4172 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4174 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4175 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4177 | // We luck out b/c by default the framework creates CB w/ the |
| 4178 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4179 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4180 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4181 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4182 | EndCommandBuffer(); |
| 4183 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4184 | // Bypass framework since it does the waits automatically |
| 4185 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4186 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4187 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4188 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4189 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4190 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4191 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4192 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4193 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4194 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4195 | submit_info.pSignalSemaphores = NULL; |
| 4196 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame^] | 4197 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4198 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4199 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4200 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4201 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame^] | 4202 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4203 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4204 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4205 | } |
| 4206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4208 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4209 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4210 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4211 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4212 | "Unable to allocate 1 descriptors of " |
| 4213 | "type " |
| 4214 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4215 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4216 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4217 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4219 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4220 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4221 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4222 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4223 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4224 | |
| 4225 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4226 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4227 | ds_pool_ci.pNext = NULL; |
| 4228 | ds_pool_ci.flags = 0; |
| 4229 | ds_pool_ci.maxSets = 1; |
| 4230 | ds_pool_ci.poolSizeCount = 1; |
| 4231 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4232 | |
| 4233 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4234 | err = |
| 4235 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4236 | ASSERT_VK_SUCCESS(err); |
| 4237 | |
| 4238 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | dsl_binding.binding = 0; |
| 4240 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4241 | dsl_binding.descriptorCount = 1; |
| 4242 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4243 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4244 | |
| 4245 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4246 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4247 | ds_layout_ci.pNext = NULL; |
| 4248 | ds_layout_ci.bindingCount = 1; |
| 4249 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4250 | |
| 4251 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4252 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4253 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4254 | ASSERT_VK_SUCCESS(err); |
| 4255 | |
| 4256 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4257 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4258 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4259 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4260 | alloc_info.descriptorPool = ds_pool; |
| 4261 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4262 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4263 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4264 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4265 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4266 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4267 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4268 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4269 | } |
| 4270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4271 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4272 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4273 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4274 | m_errorMonitor->SetDesiredFailureMsg( |
| 4275 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4276 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4277 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4278 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4279 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4280 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4281 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4282 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4283 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4284 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4285 | |
| 4286 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4287 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4288 | ds_pool_ci.pNext = NULL; |
| 4289 | ds_pool_ci.maxSets = 1; |
| 4290 | ds_pool_ci.poolSizeCount = 1; |
| 4291 | ds_pool_ci.flags = 0; |
| 4292 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4293 | // app can only call vkResetDescriptorPool on this pool.; |
| 4294 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4295 | |
| 4296 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4297 | err = |
| 4298 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4299 | ASSERT_VK_SUCCESS(err); |
| 4300 | |
| 4301 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4302 | dsl_binding.binding = 0; |
| 4303 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4304 | dsl_binding.descriptorCount = 1; |
| 4305 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4306 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4307 | |
| 4308 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4309 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4310 | ds_layout_ci.pNext = NULL; |
| 4311 | ds_layout_ci.bindingCount = 1; |
| 4312 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4313 | |
| 4314 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4316 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4317 | ASSERT_VK_SUCCESS(err); |
| 4318 | |
| 4319 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4320 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4321 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4322 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4323 | alloc_info.descriptorPool = ds_pool; |
| 4324 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4325 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4326 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4327 | ASSERT_VK_SUCCESS(err); |
| 4328 | |
| 4329 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4330 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4331 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4332 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4333 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4334 | } |
| 4335 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4336 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4337 | // Attempt to clear Descriptor Pool with bad object. |
| 4338 | // ObjectTracker should catch this. |
| 4339 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4340 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4341 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4342 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4343 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4344 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4345 | } |
| 4346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4347 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4348 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4349 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4350 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4351 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4352 | |
| 4353 | uint64_t fake_set_handle = 0xbaad6001; |
| 4354 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4355 | VkResult err; |
| 4356 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4357 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4358 | |
| 4359 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4360 | |
| 4361 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4362 | layout_bindings[0].binding = 0; |
| 4363 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4364 | layout_bindings[0].descriptorCount = 1; |
| 4365 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4366 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4367 | |
| 4368 | VkDescriptorSetLayout descriptor_set_layout; |
| 4369 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4370 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4371 | dslci.pNext = NULL; |
| 4372 | dslci.bindingCount = 1; |
| 4373 | dslci.pBindings = layout_bindings; |
| 4374 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4375 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4376 | |
| 4377 | VkPipelineLayout pipeline_layout; |
| 4378 | VkPipelineLayoutCreateInfo plci = {}; |
| 4379 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4380 | plci.pNext = NULL; |
| 4381 | plci.setLayoutCount = 1; |
| 4382 | plci.pSetLayouts = &descriptor_set_layout; |
| 4383 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4384 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4385 | |
| 4386 | BeginCommandBuffer(); |
| 4387 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4388 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4389 | m_errorMonitor->VerifyFound(); |
| 4390 | EndCommandBuffer(); |
| 4391 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4392 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4393 | } |
| 4394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4395 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4396 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4397 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4398 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4399 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4400 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4401 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4402 | |
| 4403 | VkPipelineLayout pipeline_layout; |
| 4404 | VkPipelineLayoutCreateInfo plci = {}; |
| 4405 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4406 | plci.pNext = NULL; |
| 4407 | plci.setLayoutCount = 1; |
| 4408 | plci.pSetLayouts = &bad_layout; |
| 4409 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4410 | |
| 4411 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4412 | } |
| 4413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4414 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4415 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4416 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4417 | // Create a valid cmd buffer |
| 4418 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4419 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4420 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4421 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4422 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4424 | BeginCommandBuffer(); |
| 4425 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4426 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4427 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4428 | // Now issue a draw call with no pipeline bound |
| 4429 | m_errorMonitor->SetDesiredFailureMsg( |
| 4430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4431 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4432 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4433 | BeginCommandBuffer(); |
| 4434 | Draw(1, 0, 0, 0); |
| 4435 | m_errorMonitor->VerifyFound(); |
| 4436 | // Finally same check once more but with Dispatch/Compute |
| 4437 | m_errorMonitor->SetDesiredFailureMsg( |
| 4438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4439 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4440 | BeginCommandBuffer(); |
| 4441 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4442 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4443 | } |
| 4444 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4445 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4446 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4447 | // CommandBuffer |
| 4448 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4449 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4450 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4451 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4452 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4453 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4454 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4455 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4456 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4457 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4458 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4459 | |
| 4460 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4461 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4462 | ds_pool_ci.pNext = NULL; |
| 4463 | ds_pool_ci.maxSets = 1; |
| 4464 | ds_pool_ci.poolSizeCount = 1; |
| 4465 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4466 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4467 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4468 | err = |
| 4469 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4470 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4471 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4472 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4473 | dsl_binding.binding = 0; |
| 4474 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4475 | dsl_binding.descriptorCount = 1; |
| 4476 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4477 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4478 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4479 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4480 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4481 | ds_layout_ci.pNext = NULL; |
| 4482 | ds_layout_ci.bindingCount = 1; |
| 4483 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4484 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4485 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4486 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4487 | ASSERT_VK_SUCCESS(err); |
| 4488 | |
| 4489 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4490 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4491 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4492 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4493 | alloc_info.descriptorPool = ds_pool; |
| 4494 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4495 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4496 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4497 | ASSERT_VK_SUCCESS(err); |
| 4498 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4499 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4500 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4501 | pipeline_layout_ci.pNext = NULL; |
| 4502 | pipeline_layout_ci.setLayoutCount = 1; |
| 4503 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4504 | |
| 4505 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4506 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4507 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4508 | ASSERT_VK_SUCCESS(err); |
| 4509 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4510 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4511 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4512 | // 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] | 4513 | // on more devices |
| 4514 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4515 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4516 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4517 | VkPipelineObj pipe(m_device); |
| 4518 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4519 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4520 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4521 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4522 | |
| 4523 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4524 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4525 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4526 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4527 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4528 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4529 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4530 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4531 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4532 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4533 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4534 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4535 | } |
| 4536 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4537 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4538 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4539 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4540 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4541 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4542 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4543 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4544 | |
| 4545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4546 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4547 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4548 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4549 | |
| 4550 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4551 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4552 | ds_pool_ci.pNext = NULL; |
| 4553 | ds_pool_ci.maxSets = 1; |
| 4554 | ds_pool_ci.poolSizeCount = 1; |
| 4555 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4556 | |
| 4557 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4558 | err = |
| 4559 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4560 | ASSERT_VK_SUCCESS(err); |
| 4561 | |
| 4562 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | dsl_binding.binding = 0; |
| 4564 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4565 | dsl_binding.descriptorCount = 1; |
| 4566 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4567 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4568 | |
| 4569 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4570 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4571 | ds_layout_ci.pNext = NULL; |
| 4572 | ds_layout_ci.bindingCount = 1; |
| 4573 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4574 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4575 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4576 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4577 | ASSERT_VK_SUCCESS(err); |
| 4578 | |
| 4579 | VkDescriptorSet descriptorSet; |
| 4580 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4581 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4582 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4583 | alloc_info.descriptorPool = ds_pool; |
| 4584 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4585 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4586 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4587 | ASSERT_VK_SUCCESS(err); |
| 4588 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | VkBufferView view = |
| 4590 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4591 | VkWriteDescriptorSet descriptor_write; |
| 4592 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4593 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4594 | descriptor_write.dstSet = descriptorSet; |
| 4595 | descriptor_write.dstBinding = 0; |
| 4596 | descriptor_write.descriptorCount = 1; |
| 4597 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4598 | descriptor_write.pTexelBufferView = &view; |
| 4599 | |
| 4600 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4601 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4602 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4603 | |
| 4604 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4605 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4606 | } |
| 4607 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4608 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4609 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4610 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4611 | // 1. No dynamicOffset supplied |
| 4612 | // 2. Too many dynamicOffsets supplied |
| 4613 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4614 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4615 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4616 | " requires 1 dynamicOffsets, but only " |
| 4617 | "0 dynamicOffsets are left in " |
| 4618 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4619 | |
| 4620 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4621 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4623 | |
| 4624 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4625 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4626 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4627 | |
| 4628 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4629 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4630 | ds_pool_ci.pNext = NULL; |
| 4631 | ds_pool_ci.maxSets = 1; |
| 4632 | ds_pool_ci.poolSizeCount = 1; |
| 4633 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4634 | |
| 4635 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4636 | err = |
| 4637 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4638 | ASSERT_VK_SUCCESS(err); |
| 4639 | |
| 4640 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4641 | dsl_binding.binding = 0; |
| 4642 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4643 | dsl_binding.descriptorCount = 1; |
| 4644 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4645 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4646 | |
| 4647 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4648 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4649 | ds_layout_ci.pNext = NULL; |
| 4650 | ds_layout_ci.bindingCount = 1; |
| 4651 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4652 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4653 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4654 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4655 | ASSERT_VK_SUCCESS(err); |
| 4656 | |
| 4657 | VkDescriptorSet descriptorSet; |
| 4658 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4659 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4660 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4661 | alloc_info.descriptorPool = ds_pool; |
| 4662 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4663 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4664 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4665 | ASSERT_VK_SUCCESS(err); |
| 4666 | |
| 4667 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4668 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4669 | pipeline_layout_ci.pNext = NULL; |
| 4670 | pipeline_layout_ci.setLayoutCount = 1; |
| 4671 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4672 | |
| 4673 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4674 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4675 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4676 | ASSERT_VK_SUCCESS(err); |
| 4677 | |
| 4678 | // Create a buffer to update the descriptor with |
| 4679 | uint32_t qfi = 0; |
| 4680 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4681 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4682 | buffCI.size = 1024; |
| 4683 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4684 | buffCI.queueFamilyIndexCount = 1; |
| 4685 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4686 | |
| 4687 | VkBuffer dyub; |
| 4688 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4689 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4690 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4691 | // error |
| 4692 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4693 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4694 | mem_alloc.pNext = NULL; |
| 4695 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4696 | mem_alloc.memoryTypeIndex = 0; |
| 4697 | |
| 4698 | VkMemoryRequirements memReqs; |
| 4699 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4700 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4701 | 0); |
| 4702 | if (!pass) { |
| 4703 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4704 | return; |
| 4705 | } |
| 4706 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4707 | VkDeviceMemory mem; |
| 4708 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4709 | ASSERT_VK_SUCCESS(err); |
| 4710 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4711 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4712 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4713 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4714 | buffInfo.buffer = dyub; |
| 4715 | buffInfo.offset = 0; |
| 4716 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4717 | |
| 4718 | VkWriteDescriptorSet descriptor_write; |
| 4719 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4720 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4721 | descriptor_write.dstSet = descriptorSet; |
| 4722 | descriptor_write.dstBinding = 0; |
| 4723 | descriptor_write.descriptorCount = 1; |
| 4724 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4725 | descriptor_write.pBufferInfo = &buffInfo; |
| 4726 | |
| 4727 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4728 | |
| 4729 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4730 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4731 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4732 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4733 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4734 | uint32_t pDynOff[2] = {512, 756}; |
| 4735 | // 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] | 4736 | m_errorMonitor->SetDesiredFailureMsg( |
| 4737 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4738 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4739 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4740 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4741 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4742 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4743 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4744 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4745 | " dynamic offset 512 combined with " |
| 4746 | "offset 0 and range 1024 that " |
| 4747 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4748 | // Create PSO to be used for draw-time errors below |
| 4749 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4750 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4751 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4752 | "out gl_PerVertex { \n" |
| 4753 | " vec4 gl_Position;\n" |
| 4754 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4755 | "void main(){\n" |
| 4756 | " gl_Position = vec4(1);\n" |
| 4757 | "}\n"; |
| 4758 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4759 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4760 | "\n" |
| 4761 | "layout(location=0) out vec4 x;\n" |
| 4762 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4763 | "void main(){\n" |
| 4764 | " x = vec4(bar.y);\n" |
| 4765 | "}\n"; |
| 4766 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4767 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4768 | VkPipelineObj pipe(m_device); |
| 4769 | pipe.AddShader(&vs); |
| 4770 | pipe.AddShader(&fs); |
| 4771 | pipe.AddColorAttachment(); |
| 4772 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4774 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4775 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4776 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4777 | // /w range 1024 & size 1024 |
| 4778 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4779 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4780 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4781 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4782 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4783 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4784 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4785 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4786 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4787 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4788 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4789 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4790 | } |
| 4791 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4792 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4793 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4795 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4796 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4797 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4798 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4799 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4800 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4801 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4802 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4803 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4804 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4805 | // |
| 4806 | // Check for invalid push constant ranges in pipeline layouts. |
| 4807 | // |
| 4808 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4809 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4810 | char const *msg; |
| 4811 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4812 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4813 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4814 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4815 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4816 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4817 | "size 0."}, |
| 4818 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4819 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4820 | "size 1."}, |
| 4821 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4822 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4823 | "size 1."}, |
| 4824 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4825 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4826 | "size 0."}, |
| 4827 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4828 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4829 | "offset 1. Offset must"}, |
| 4830 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4831 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4832 | "with offset "}, |
| 4833 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4834 | "vkCreatePipelineLayout() call has push constants " |
| 4835 | "index 0 with offset "}, |
| 4836 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4837 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4838 | "with offset "}, |
| 4839 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4840 | "vkCreatePipelineLayout() call has push " |
| 4841 | "constants index 0 with offset "}, |
| 4842 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4843 | "vkCreatePipelineLayout() call has push " |
| 4844 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4845 | }}; |
| 4846 | |
| 4847 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4848 | for (const auto &iter : range_tests) { |
| 4849 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4851 | iter.msg); |
| 4852 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4853 | NULL, &pipeline_layout); |
| 4854 | m_errorMonitor->VerifyFound(); |
| 4855 | if (VK_SUCCESS == err) { |
| 4856 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4857 | } |
| 4858 | } |
| 4859 | |
| 4860 | // Check for invalid stage flag |
| 4861 | pc_range.offset = 0; |
| 4862 | pc_range.size = 16; |
| 4863 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4864 | m_errorMonitor->SetDesiredFailureMsg( |
| 4865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4866 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4867 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4868 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4869 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4870 | if (VK_SUCCESS == err) { |
| 4871 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4872 | } |
| 4873 | |
| 4874 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4875 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4876 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4877 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4878 | char const *msg; |
| 4879 | }; |
| 4880 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4881 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4882 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4883 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4884 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4885 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4886 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4887 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4888 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4889 | { |
| 4890 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4891 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4892 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4893 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4894 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4895 | "vkCreatePipelineLayout() call has push constants with " |
| 4896 | "overlapping " |
| 4897 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4898 | }, |
| 4899 | { |
| 4900 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4901 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4902 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4903 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4904 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4905 | "vkCreatePipelineLayout() call has push constants with " |
| 4906 | "overlapping " |
| 4907 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4908 | }, |
| 4909 | { |
| 4910 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4911 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4912 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4913 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4914 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4915 | "vkCreatePipelineLayout() call has push constants with " |
| 4916 | "overlapping " |
| 4917 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4918 | }, |
| 4919 | { |
| 4920 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4921 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4922 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4923 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4924 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4925 | "vkCreatePipelineLayout() call has push constants with " |
| 4926 | "overlapping " |
| 4927 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4928 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4929 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4930 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4931 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4932 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4933 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4934 | iter.msg); |
| 4935 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4936 | NULL, &pipeline_layout); |
| 4937 | m_errorMonitor->VerifyFound(); |
| 4938 | if (VK_SUCCESS == err) { |
| 4939 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4940 | } |
| 4941 | } |
| 4942 | |
| 4943 | // 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] | 4944 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4945 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4946 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4947 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4948 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4949 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4950 | ""}, |
| 4951 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4952 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4953 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4954 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4955 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4956 | ""}}}; |
| 4957 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4958 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4959 | m_errorMonitor->ExpectSuccess(); |
| 4960 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4961 | NULL, &pipeline_layout); |
| 4962 | m_errorMonitor->VerifyNotFound(); |
| 4963 | if (VK_SUCCESS == err) { |
| 4964 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4965 | } |
| 4966 | } |
| 4967 | |
| 4968 | // |
| 4969 | // CmdPushConstants tests |
| 4970 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4971 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4972 | |
| 4973 | // 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] | 4974 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4975 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4976 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4977 | "must be greater than zero and a multiple of 4."}, |
| 4978 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4979 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4980 | "must be greater than zero and a multiple of 4."}, |
| 4981 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4982 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4983 | "must be greater than zero and a multiple of 4."}, |
| 4984 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4985 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4986 | "Offset must be a multiple of 4."}, |
| 4987 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4988 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4989 | "Offset must be a multiple of 4."}, |
| 4990 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4991 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4992 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4993 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4994 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4995 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4996 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4997 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4998 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4999 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 5000 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 5001 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5002 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 5003 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 5004 | "any of the ranges in pipeline layout"}, |
| 5005 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5006 | 0, 16}, |
| 5007 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 5008 | "any of the ranges in pipeline layout"}, |
| 5009 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5010 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5011 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5012 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5013 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5014 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5015 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5016 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5017 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5018 | "vkCmdPushConstants() call has push constants with offset "}, |
| 5019 | }}; |
| 5020 | |
| 5021 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5022 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5023 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5024 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5025 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5026 | pipeline_layout_ci.pushConstantRangeCount = |
| 5027 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5028 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5029 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5030 | &pipeline_layout); |
| 5031 | ASSERT_VK_SUCCESS(err); |
| 5032 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5033 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5034 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5035 | iter.msg); |
| 5036 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5037 | iter.range.stageFlags, iter.range.offset, |
| 5038 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5039 | m_errorMonitor->VerifyFound(); |
| 5040 | } |
| 5041 | |
| 5042 | // Check for invalid stage flag |
| 5043 | m_errorMonitor->SetDesiredFailureMsg( |
| 5044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5045 | "vkCmdPushConstants() call has no stageFlags set."); |
| 5046 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5047 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5048 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5049 | EndCommandBuffer(); |
| 5050 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5051 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5052 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5053 | // overlapping range tests with cmd |
| 5054 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 5055 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5056 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5057 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5058 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5059 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 5060 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5061 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 5062 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 5063 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5064 | }}; |
| 5065 | const VkPushConstantRange pc_range3[] = { |
| 5066 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5067 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5068 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5069 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5070 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5071 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5072 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5073 | }; |
| 5074 | pipeline_layout_ci.pushConstantRangeCount = |
| 5075 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 5076 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 5077 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5078 | &pipeline_layout); |
| 5079 | ASSERT_VK_SUCCESS(err); |
| 5080 | BeginCommandBuffer(); |
| 5081 | for (const auto &iter : cmd_overlap_tests) { |
| 5082 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5083 | iter.msg); |
| 5084 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5085 | iter.range.stageFlags, iter.range.offset, |
| 5086 | iter.range.size, dummy_values); |
| 5087 | m_errorMonitor->VerifyFound(); |
| 5088 | } |
| 5089 | EndCommandBuffer(); |
| 5090 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5091 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5092 | |
| 5093 | // positive overlapping range tests with cmd |
| 5094 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 5095 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 5096 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 5097 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 5098 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 5099 | }}; |
| 5100 | const VkPushConstantRange pc_range4[] = { |
| 5101 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 5102 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5103 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5104 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5105 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5106 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5107 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5108 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5109 | }; |
| 5110 | pipeline_layout_ci.pushConstantRangeCount = |
| 5111 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 5112 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 5113 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5114 | &pipeline_layout); |
| 5115 | ASSERT_VK_SUCCESS(err); |
| 5116 | BeginCommandBuffer(); |
| 5117 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5118 | m_errorMonitor->ExpectSuccess(); |
| 5119 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5120 | iter.range.stageFlags, iter.range.offset, |
| 5121 | iter.range.size, dummy_values); |
| 5122 | m_errorMonitor->VerifyNotFound(); |
| 5123 | } |
| 5124 | EndCommandBuffer(); |
| 5125 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5126 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5127 | } |
| 5128 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5129 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5130 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5131 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5132 | |
| 5133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5134 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5135 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5136 | |
| 5137 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5138 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5139 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5140 | ds_type_count[0].descriptorCount = 10; |
| 5141 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5142 | ds_type_count[1].descriptorCount = 2; |
| 5143 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5144 | ds_type_count[2].descriptorCount = 2; |
| 5145 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5146 | ds_type_count[3].descriptorCount = 5; |
| 5147 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5148 | // type |
| 5149 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5150 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5151 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5152 | |
| 5153 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5154 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5155 | ds_pool_ci.pNext = NULL; |
| 5156 | ds_pool_ci.maxSets = 5; |
| 5157 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5158 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5159 | |
| 5160 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5161 | err = |
| 5162 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5163 | ASSERT_VK_SUCCESS(err); |
| 5164 | |
| 5165 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5166 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5167 | dsl_binding[0].binding = 0; |
| 5168 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5169 | dsl_binding[0].descriptorCount = 5; |
| 5170 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5171 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5172 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5173 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5174 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5175 | dsl_fs_stage_only.binding = 0; |
| 5176 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5177 | dsl_fs_stage_only.descriptorCount = 5; |
| 5178 | dsl_fs_stage_only.stageFlags = |
| 5179 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5180 | // bind time |
| 5181 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5182 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5183 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5184 | ds_layout_ci.pNext = NULL; |
| 5185 | ds_layout_ci.bindingCount = 1; |
| 5186 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5187 | static const uint32_t NUM_LAYOUTS = 4; |
| 5188 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5189 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5190 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5191 | // layout for error case |
| 5192 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5193 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5194 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5195 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5196 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5197 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5198 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5199 | dsl_binding[0].binding = 0; |
| 5200 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5201 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5202 | dsl_binding[1].binding = 1; |
| 5203 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5204 | dsl_binding[1].descriptorCount = 2; |
| 5205 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5206 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5207 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5208 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5209 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5210 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5211 | ASSERT_VK_SUCCESS(err); |
| 5212 | dsl_binding[0].binding = 0; |
| 5213 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5214 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5215 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5216 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5217 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5218 | ASSERT_VK_SUCCESS(err); |
| 5219 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5220 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5221 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5222 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5223 | ASSERT_VK_SUCCESS(err); |
| 5224 | |
| 5225 | static const uint32_t NUM_SETS = 4; |
| 5226 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5227 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5228 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5229 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5230 | alloc_info.descriptorPool = ds_pool; |
| 5231 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5232 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5233 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5234 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5235 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5236 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5237 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5238 | err = |
| 5239 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5240 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5241 | |
| 5242 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5243 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5244 | pipeline_layout_ci.pNext = NULL; |
| 5245 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5246 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5247 | |
| 5248 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5249 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5250 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5251 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5252 | // Create pipelineLayout with only one setLayout |
| 5253 | pipeline_layout_ci.setLayoutCount = 1; |
| 5254 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5255 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5256 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5257 | ASSERT_VK_SUCCESS(err); |
| 5258 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5259 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5260 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5261 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5262 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5263 | ASSERT_VK_SUCCESS(err); |
| 5264 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5265 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5266 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5267 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5268 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5269 | ASSERT_VK_SUCCESS(err); |
| 5270 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5271 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5272 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5273 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5274 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5275 | ASSERT_VK_SUCCESS(err); |
| 5276 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5277 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5278 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5279 | pl_bad_s0[1] = ds_layout[1]; |
| 5280 | pipeline_layout_ci.setLayoutCount = 2; |
| 5281 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5282 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5283 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5284 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5285 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5286 | |
| 5287 | // Create a buffer to update the descriptor with |
| 5288 | uint32_t qfi = 0; |
| 5289 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5290 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5291 | buffCI.size = 1024; |
| 5292 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5293 | buffCI.queueFamilyIndexCount = 1; |
| 5294 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5295 | |
| 5296 | VkBuffer dyub; |
| 5297 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5298 | ASSERT_VK_SUCCESS(err); |
| 5299 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5300 | static const uint32_t NUM_BUFFS = 5; |
| 5301 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5302 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5303 | buffInfo[i].buffer = dyub; |
| 5304 | buffInfo[i].offset = 0; |
| 5305 | buffInfo[i].range = 1024; |
| 5306 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5307 | VkImage image; |
| 5308 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5309 | const int32_t tex_width = 32; |
| 5310 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5311 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5312 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5313 | image_create_info.pNext = NULL; |
| 5314 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5315 | image_create_info.format = tex_format; |
| 5316 | image_create_info.extent.width = tex_width; |
| 5317 | image_create_info.extent.height = tex_height; |
| 5318 | image_create_info.extent.depth = 1; |
| 5319 | image_create_info.mipLevels = 1; |
| 5320 | image_create_info.arrayLayers = 1; |
| 5321 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5322 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5323 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5324 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5325 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5326 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5328 | VkMemoryRequirements memReqs; |
| 5329 | VkDeviceMemory imageMem; |
| 5330 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5331 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5332 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5333 | memAlloc.pNext = NULL; |
| 5334 | memAlloc.allocationSize = 0; |
| 5335 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5336 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5337 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5338 | pass = |
| 5339 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5340 | ASSERT_TRUE(pass); |
| 5341 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5342 | ASSERT_VK_SUCCESS(err); |
| 5343 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5344 | ASSERT_VK_SUCCESS(err); |
| 5345 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5346 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5347 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5348 | image_view_create_info.image = image; |
| 5349 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5350 | image_view_create_info.format = tex_format; |
| 5351 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5352 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5353 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5354 | image_view_create_info.subresourceRange.aspectMask = |
| 5355 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5356 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5357 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5358 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5359 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5360 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5361 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5362 | imageInfo[0].imageView = view; |
| 5363 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5364 | imageInfo[1].imageView = view; |
| 5365 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5366 | imageInfo[2].imageView = view; |
| 5367 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5368 | imageInfo[3].imageView = view; |
| 5369 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5370 | |
| 5371 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5372 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5373 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5374 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5375 | descriptor_write[0].dstBinding = 0; |
| 5376 | descriptor_write[0].descriptorCount = 5; |
| 5377 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5378 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5379 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5380 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5381 | descriptor_write[1].dstBinding = 0; |
| 5382 | descriptor_write[1].descriptorCount = 2; |
| 5383 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5384 | descriptor_write[1].pImageInfo = imageInfo; |
| 5385 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5386 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5387 | descriptor_write[2].dstBinding = 1; |
| 5388 | descriptor_write[2].descriptorCount = 2; |
| 5389 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5390 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5391 | |
| 5392 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5393 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5394 | // Create PSO to be used for draw-time errors below |
| 5395 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5396 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5397 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5398 | "out gl_PerVertex {\n" |
| 5399 | " vec4 gl_Position;\n" |
| 5400 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5401 | "void main(){\n" |
| 5402 | " gl_Position = vec4(1);\n" |
| 5403 | "}\n"; |
| 5404 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5405 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5406 | "\n" |
| 5407 | "layout(location=0) out vec4 x;\n" |
| 5408 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5409 | "void main(){\n" |
| 5410 | " x = vec4(bar.y);\n" |
| 5411 | "}\n"; |
| 5412 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5413 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5414 | VkPipelineObj pipe(m_device); |
| 5415 | pipe.AddShader(&vs); |
| 5416 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5417 | pipe.AddColorAttachment(); |
| 5418 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5419 | |
| 5420 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5422 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5423 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5424 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5425 | // of PSO |
| 5426 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5427 | // cmd_pipeline.c |
| 5428 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5429 | // cmd_bind_graphics_pipeline() |
| 5430 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5431 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5432 | // First cause various verify_layout_compatibility() fails |
| 5433 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5434 | // verify_set_layout_compatibility fail cases: |
| 5435 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5436 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5437 | " due to: invalid VkPipelineLayout "); |
| 5438 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5439 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5440 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5441 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5442 | m_errorMonitor->VerifyFound(); |
| 5443 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5444 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5445 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5446 | " attempting to bind set to index 1"); |
| 5447 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5448 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5449 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5450 | m_errorMonitor->VerifyFound(); |
| 5451 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5452 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5453 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5454 | // descriptors |
| 5455 | m_errorMonitor->SetDesiredFailureMsg( |
| 5456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5457 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | vkCmdBindDescriptorSets( |
| 5459 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5460 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5461 | m_errorMonitor->VerifyFound(); |
| 5462 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5463 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5464 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5465 | m_errorMonitor->SetDesiredFailureMsg( |
| 5466 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5467 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5468 | vkCmdBindDescriptorSets( |
| 5469 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5470 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5471 | m_errorMonitor->VerifyFound(); |
| 5472 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5473 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5474 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5475 | m_errorMonitor->SetDesiredFailureMsg( |
| 5476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5477 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | vkCmdBindDescriptorSets( |
| 5479 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5480 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5481 | m_errorMonitor->VerifyFound(); |
| 5482 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5483 | // Cause INFO messages due to disturbing previously bound Sets |
| 5484 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5485 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5486 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5487 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5488 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5489 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5490 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | " previously bound as set #0 was disturbed "); |
| 5492 | vkCmdBindDescriptorSets( |
| 5493 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5494 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5495 | m_errorMonitor->VerifyFound(); |
| 5496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5497 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5498 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5499 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5500 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5501 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5502 | " newly bound as set #0 so set #1 and " |
| 5503 | "any subsequent sets were disturbed "); |
| 5504 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5505 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5506 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5507 | m_errorMonitor->VerifyFound(); |
| 5508 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5509 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5510 | // 1. Error due to not binding required set (we actually use same code as |
| 5511 | // above to disturb set0) |
| 5512 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5513 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5514 | 2, &descriptorSet[0], 0, NULL); |
| 5515 | vkCmdBindDescriptorSets( |
| 5516 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5517 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5518 | m_errorMonitor->SetDesiredFailureMsg( |
| 5519 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5520 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5521 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5522 | m_errorMonitor->VerifyFound(); |
| 5523 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5524 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | // 2. Error due to bound set not being compatible with PSO's |
| 5526 | // VkPipelineLayout (diff stageFlags in this case) |
| 5527 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5528 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5529 | 2, &descriptorSet[0], 0, NULL); |
| 5530 | m_errorMonitor->SetDesiredFailureMsg( |
| 5531 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5532 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5533 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5534 | m_errorMonitor->VerifyFound(); |
| 5535 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5536 | // Remaining clean-up |
| 5537 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5538 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5539 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5540 | } |
| 5541 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5542 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5543 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5544 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5545 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5546 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5547 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 5548 | vkDestroyImage(m_device->device(), image, NULL); |
| 5549 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5550 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5552 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5553 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5554 | m_errorMonitor->SetDesiredFailureMsg( |
| 5555 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5556 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5557 | |
| 5558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5559 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5560 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5561 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5562 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5563 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5564 | } |
| 5565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5566 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5567 | VkResult err; |
| 5568 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | m_errorMonitor->SetDesiredFailureMsg( |
| 5571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5572 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5573 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5574 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5575 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5576 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5577 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5578 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5579 | cmd.commandPool = m_commandPool; |
| 5580 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5581 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5582 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5583 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5584 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5585 | |
| 5586 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5587 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5588 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5589 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5590 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5591 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5592 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5593 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5594 | |
| 5595 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5596 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5597 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5598 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5599 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5600 | } |
| 5601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5602 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5603 | // Cause error due to Begin while recording CB |
| 5604 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5605 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5606 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5607 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5608 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5609 | |
| 5610 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5611 | |
| 5612 | // Calls AllocateCommandBuffers |
| 5613 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5614 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5615 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5616 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5617 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5618 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5619 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5620 | cmd_buf_info.pNext = NULL; |
| 5621 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5622 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5623 | |
| 5624 | // Begin CB to transition to recording state |
| 5625 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5626 | // Can't re-begin. This should trigger error |
| 5627 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5628 | m_errorMonitor->VerifyFound(); |
| 5629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5630 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5631 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5632 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5633 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5634 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5635 | m_errorMonitor->VerifyFound(); |
| 5636 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5637 | m_errorMonitor->SetDesiredFailureMsg( |
| 5638 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5639 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5640 | // Transition CB to RECORDED state |
| 5641 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5642 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5643 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5644 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5645 | } |
| 5646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5647 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5648 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5649 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5651 | m_errorMonitor->SetDesiredFailureMsg( |
| 5652 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5653 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5654 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5656 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5657 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5658 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5660 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5661 | |
| 5662 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5663 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5664 | ds_pool_ci.pNext = NULL; |
| 5665 | ds_pool_ci.maxSets = 1; |
| 5666 | ds_pool_ci.poolSizeCount = 1; |
| 5667 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5668 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5669 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | err = |
| 5671 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5672 | ASSERT_VK_SUCCESS(err); |
| 5673 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5674 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5675 | dsl_binding.binding = 0; |
| 5676 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5677 | dsl_binding.descriptorCount = 1; |
| 5678 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5679 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5680 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5681 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5682 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5683 | ds_layout_ci.pNext = NULL; |
| 5684 | ds_layout_ci.bindingCount = 1; |
| 5685 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5686 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5687 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5688 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5689 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5690 | ASSERT_VK_SUCCESS(err); |
| 5691 | |
| 5692 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5693 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5694 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5695 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5696 | alloc_info.descriptorPool = ds_pool; |
| 5697 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5698 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5699 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5700 | ASSERT_VK_SUCCESS(err); |
| 5701 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5702 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5703 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5704 | pipeline_layout_ci.setLayoutCount = 1; |
| 5705 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5706 | |
| 5707 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5708 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5709 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5710 | ASSERT_VK_SUCCESS(err); |
| 5711 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5712 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5713 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5714 | |
| 5715 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5716 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5717 | vp_state_ci.scissorCount = 1; |
| 5718 | vp_state_ci.pScissors = ≻ |
| 5719 | vp_state_ci.viewportCount = 1; |
| 5720 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5721 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5722 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5723 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5724 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5725 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5726 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5727 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5728 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5729 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5730 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5731 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5732 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5733 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5734 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5736 | gp_ci.layout = pipeline_layout; |
| 5737 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5738 | |
| 5739 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5740 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5741 | pc_ci.initialDataSize = 0; |
| 5742 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5743 | |
| 5744 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5745 | VkPipelineCache pipelineCache; |
| 5746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5747 | err = |
| 5748 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5749 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5750 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5751 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5752 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5753 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5754 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5755 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5756 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5757 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5758 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5759 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5760 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5761 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5762 | { |
| 5763 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5764 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5765 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5766 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5767 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5768 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5769 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5772 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5773 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5774 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5775 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5776 | |
| 5777 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5778 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5779 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5780 | ds_pool_ci.poolSizeCount = 1; |
| 5781 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5782 | |
| 5783 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5784 | err = vkCreateDescriptorPool(m_device->device(), |
| 5785 | 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] | 5786 | ASSERT_VK_SUCCESS(err); |
| 5787 | |
| 5788 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5789 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5790 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5791 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5792 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5793 | dsl_binding.pImmutableSamplers = NULL; |
| 5794 | |
| 5795 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5796 | ds_layout_ci.sType = |
| 5797 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5798 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5799 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5800 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5801 | |
| 5802 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5803 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5804 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5805 | ASSERT_VK_SUCCESS(err); |
| 5806 | |
| 5807 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5808 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5809 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5810 | ASSERT_VK_SUCCESS(err); |
| 5811 | |
| 5812 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5813 | pipeline_layout_ci.sType = |
| 5814 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5815 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5816 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5817 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5818 | |
| 5819 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5821 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5822 | ASSERT_VK_SUCCESS(err); |
| 5823 | |
| 5824 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5825 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5827 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5828 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5829 | // 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] | 5830 | VkShaderObj |
| 5831 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5832 | this); |
| 5833 | VkShaderObj |
| 5834 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5835 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5836 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | shaderStages[0].sType = |
| 5838 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5839 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5840 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5841 | shaderStages[1].sType = |
| 5842 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5843 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5844 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5845 | shaderStages[2].sType = |
| 5846 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5847 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5848 | shaderStages[2].shader = te.handle(); |
| 5849 | |
| 5850 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5851 | iaCI.sType = |
| 5852 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5853 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5854 | |
| 5855 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5856 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5857 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5858 | |
| 5859 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5860 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5861 | gp_ci.pNext = NULL; |
| 5862 | gp_ci.stageCount = 3; |
| 5863 | gp_ci.pStages = shaderStages; |
| 5864 | gp_ci.pVertexInputState = NULL; |
| 5865 | gp_ci.pInputAssemblyState = &iaCI; |
| 5866 | gp_ci.pTessellationState = &tsCI; |
| 5867 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5868 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5869 | gp_ci.pMultisampleState = NULL; |
| 5870 | gp_ci.pDepthStencilState = NULL; |
| 5871 | gp_ci.pColorBlendState = NULL; |
| 5872 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5873 | gp_ci.layout = pipeline_layout; |
| 5874 | gp_ci.renderPass = renderPass(); |
| 5875 | |
| 5876 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5877 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5878 | pc_ci.pNext = NULL; |
| 5879 | pc_ci.initialSize = 0; |
| 5880 | pc_ci.initialData = 0; |
| 5881 | pc_ci.maxSize = 0; |
| 5882 | |
| 5883 | VkPipeline pipeline; |
| 5884 | VkPipelineCache pipelineCache; |
| 5885 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5886 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5887 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5888 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5889 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5890 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5891 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5892 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5893 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5894 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5895 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5896 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5897 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5898 | } |
| 5899 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5900 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5902 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5903 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5904 | m_errorMonitor->SetDesiredFailureMsg( |
| 5905 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5906 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5907 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5908 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5909 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5910 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5911 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5912 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5913 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5914 | |
| 5915 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5916 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5917 | ds_pool_ci.maxSets = 1; |
| 5918 | ds_pool_ci.poolSizeCount = 1; |
| 5919 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5920 | |
| 5921 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5922 | err = |
| 5923 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5924 | ASSERT_VK_SUCCESS(err); |
| 5925 | |
| 5926 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5927 | dsl_binding.binding = 0; |
| 5928 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5929 | dsl_binding.descriptorCount = 1; |
| 5930 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5931 | |
| 5932 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5933 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5934 | ds_layout_ci.bindingCount = 1; |
| 5935 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5936 | |
| 5937 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5939 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5940 | ASSERT_VK_SUCCESS(err); |
| 5941 | |
| 5942 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5943 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5944 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5945 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5946 | alloc_info.descriptorPool = ds_pool; |
| 5947 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5948 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5949 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5950 | ASSERT_VK_SUCCESS(err); |
| 5951 | |
| 5952 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5954 | pipeline_layout_ci.setLayoutCount = 1; |
| 5955 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5956 | |
| 5957 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5958 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5959 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5960 | ASSERT_VK_SUCCESS(err); |
| 5961 | |
| 5962 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5963 | |
| 5964 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5965 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5966 | vp_state_ci.scissorCount = 0; |
| 5967 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5968 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5969 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5970 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5971 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5972 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5973 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5974 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5975 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5976 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5977 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5978 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5979 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5980 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5981 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5982 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5983 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5984 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5985 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5986 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5987 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5988 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5989 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5990 | |
| 5991 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5992 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5993 | gp_ci.stageCount = 2; |
| 5994 | gp_ci.pStages = shaderStages; |
| 5995 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5996 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5997 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5998 | gp_ci.layout = pipeline_layout; |
| 5999 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6000 | |
| 6001 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6002 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6003 | |
| 6004 | VkPipeline pipeline; |
| 6005 | VkPipelineCache pipelineCache; |
| 6006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6007 | err = |
| 6008 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6009 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6010 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6011 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6012 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6013 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6014 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6015 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6016 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6017 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6018 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6019 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6020 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 6021 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6022 | // 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] | 6023 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6024 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 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 pViewportState is null. Even if "); |
| 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 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6086 | // Set scissor as dynamic to avoid second error |
| 6087 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6088 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6089 | dyn_state_ci.dynamicStateCount = 1; |
| 6090 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6091 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6092 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6093 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6095 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6096 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6097 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6098 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6099 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6100 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6101 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6102 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6103 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6104 | |
| 6105 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6106 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6107 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6108 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6109 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6110 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6111 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6112 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6113 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6114 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6115 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6116 | gp_ci.stageCount = 2; |
| 6117 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6118 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6119 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6120 | // should cause validation error |
| 6121 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6122 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6123 | gp_ci.layout = pipeline_layout; |
| 6124 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6125 | |
| 6126 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6128 | |
| 6129 | VkPipeline pipeline; |
| 6130 | VkPipelineCache pipelineCache; |
| 6131 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6132 | err = |
| 6133 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6134 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6136 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6137 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6138 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6139 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6140 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6141 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6142 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6143 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6144 | } |
| 6145 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6146 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6147 | // count |
| 6148 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6149 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6151 | m_errorMonitor->SetDesiredFailureMsg( |
| 6152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6153 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6154 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6155 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6156 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6157 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6158 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6159 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6160 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6161 | |
| 6162 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6163 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6164 | ds_pool_ci.maxSets = 1; |
| 6165 | ds_pool_ci.poolSizeCount = 1; |
| 6166 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6167 | |
| 6168 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | err = |
| 6170 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6171 | ASSERT_VK_SUCCESS(err); |
| 6172 | |
| 6173 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6174 | dsl_binding.binding = 0; |
| 6175 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6176 | dsl_binding.descriptorCount = 1; |
| 6177 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6178 | |
| 6179 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6180 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6181 | ds_layout_ci.bindingCount = 1; |
| 6182 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6183 | |
| 6184 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6185 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6186 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6187 | ASSERT_VK_SUCCESS(err); |
| 6188 | |
| 6189 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6190 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6191 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6192 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6193 | alloc_info.descriptorPool = ds_pool; |
| 6194 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6196 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6197 | ASSERT_VK_SUCCESS(err); |
| 6198 | |
| 6199 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6200 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6201 | pipeline_layout_ci.setLayoutCount = 1; |
| 6202 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6203 | |
| 6204 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6205 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6206 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6207 | ASSERT_VK_SUCCESS(err); |
| 6208 | |
| 6209 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6210 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6211 | vp_state_ci.viewportCount = 1; |
| 6212 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6213 | vp_state_ci.scissorCount = 1; |
| 6214 | vp_state_ci.pScissors = |
| 6215 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6216 | |
| 6217 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6218 | // Set scissor as dynamic to avoid that error |
| 6219 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6220 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6221 | dyn_state_ci.dynamicStateCount = 1; |
| 6222 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6223 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6224 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6225 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6226 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6227 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6228 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6229 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6230 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6231 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6232 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6233 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6234 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6235 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6236 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6237 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6238 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6239 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6240 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6241 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6242 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6243 | |
| 6244 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6245 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6246 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6247 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6248 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6249 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6250 | rs_ci.pNext = nullptr; |
| 6251 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6252 | VkPipelineColorBlendAttachmentState att = {}; |
| 6253 | att.blendEnable = VK_FALSE; |
| 6254 | att.colorWriteMask = 0xf; |
| 6255 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6256 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6257 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6258 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6259 | cb_ci.attachmentCount = 1; |
| 6260 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6261 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6262 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6263 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6264 | gp_ci.stageCount = 2; |
| 6265 | gp_ci.pStages = shaderStages; |
| 6266 | gp_ci.pVertexInputState = &vi_ci; |
| 6267 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6268 | gp_ci.pViewportState = &vp_state_ci; |
| 6269 | gp_ci.pRasterizationState = &rs_ci; |
| 6270 | gp_ci.pColorBlendState = &cb_ci; |
| 6271 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6272 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6273 | gp_ci.layout = pipeline_layout; |
| 6274 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6275 | |
| 6276 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6277 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6278 | |
| 6279 | VkPipeline pipeline; |
| 6280 | VkPipelineCache pipelineCache; |
| 6281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6282 | err = |
| 6283 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6284 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6285 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6286 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6287 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6288 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6289 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6290 | // 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] | 6291 | // First need to successfully create the PSO from above by setting |
| 6292 | // pViewports |
| 6293 | m_errorMonitor->SetDesiredFailureMsg( |
| 6294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6295 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6296 | "scissorCount is 1. These counts must match."); |
| 6297 | |
| 6298 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6299 | vp_state_ci.pViewports = &vp; |
| 6300 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6301 | &gp_ci, NULL, &pipeline); |
| 6302 | ASSERT_VK_SUCCESS(err); |
| 6303 | BeginCommandBuffer(); |
| 6304 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6305 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6306 | VkRect2D scissors[2] = {}; // don't care about data |
| 6307 | // Count of 2 doesn't match PSO count of 1 |
| 6308 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6309 | Draw(1, 0, 0, 0); |
| 6310 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6311 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6312 | |
| 6313 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6314 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6315 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6316 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6317 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6318 | } |
| 6319 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6320 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6321 | // viewportCount |
| 6322 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6323 | VkResult err; |
| 6324 | |
| 6325 | m_errorMonitor->SetDesiredFailureMsg( |
| 6326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6327 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6328 | |
| 6329 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6330 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6331 | |
| 6332 | VkDescriptorPoolSize ds_type_count = {}; |
| 6333 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6334 | ds_type_count.descriptorCount = 1; |
| 6335 | |
| 6336 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6337 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6338 | ds_pool_ci.maxSets = 1; |
| 6339 | ds_pool_ci.poolSizeCount = 1; |
| 6340 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6341 | |
| 6342 | VkDescriptorPool ds_pool; |
| 6343 | err = |
| 6344 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6345 | ASSERT_VK_SUCCESS(err); |
| 6346 | |
| 6347 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6348 | dsl_binding.binding = 0; |
| 6349 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6350 | dsl_binding.descriptorCount = 1; |
| 6351 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6352 | |
| 6353 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6354 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6355 | ds_layout_ci.bindingCount = 1; |
| 6356 | ds_layout_ci.pBindings = &dsl_binding; |
| 6357 | |
| 6358 | VkDescriptorSetLayout ds_layout; |
| 6359 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6360 | &ds_layout); |
| 6361 | ASSERT_VK_SUCCESS(err); |
| 6362 | |
| 6363 | VkDescriptorSet descriptorSet; |
| 6364 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6365 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6366 | alloc_info.descriptorSetCount = 1; |
| 6367 | alloc_info.descriptorPool = ds_pool; |
| 6368 | alloc_info.pSetLayouts = &ds_layout; |
| 6369 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6370 | &descriptorSet); |
| 6371 | ASSERT_VK_SUCCESS(err); |
| 6372 | |
| 6373 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6374 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6375 | pipeline_layout_ci.setLayoutCount = 1; |
| 6376 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6377 | |
| 6378 | VkPipelineLayout pipeline_layout; |
| 6379 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6380 | &pipeline_layout); |
| 6381 | ASSERT_VK_SUCCESS(err); |
| 6382 | |
| 6383 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6384 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6385 | vp_state_ci.scissorCount = 1; |
| 6386 | vp_state_ci.pScissors = |
| 6387 | NULL; // Null scissor w/ count of 1 should cause error |
| 6388 | vp_state_ci.viewportCount = 1; |
| 6389 | vp_state_ci.pViewports = |
| 6390 | NULL; // vp is dynamic (below) so this won't cause error |
| 6391 | |
| 6392 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6393 | // Set scissor as dynamic to avoid that error |
| 6394 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6395 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6396 | dyn_state_ci.dynamicStateCount = 1; |
| 6397 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6398 | |
| 6399 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6400 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6401 | |
| 6402 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6403 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6404 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6405 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6406 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6407 | // but add it to be able to run on more devices |
| 6408 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6409 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6410 | |
| 6411 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6412 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6413 | vi_ci.pNext = nullptr; |
| 6414 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6415 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6416 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6417 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6418 | |
| 6419 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6420 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6421 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6422 | |
| 6423 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6424 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6425 | rs_ci.pNext = nullptr; |
| 6426 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6427 | VkPipelineColorBlendAttachmentState att = {}; |
| 6428 | att.blendEnable = VK_FALSE; |
| 6429 | att.colorWriteMask = 0xf; |
| 6430 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6431 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6432 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6433 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6434 | cb_ci.attachmentCount = 1; |
| 6435 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6436 | |
| 6437 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6438 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6439 | gp_ci.stageCount = 2; |
| 6440 | gp_ci.pStages = shaderStages; |
| 6441 | gp_ci.pVertexInputState = &vi_ci; |
| 6442 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6443 | gp_ci.pViewportState = &vp_state_ci; |
| 6444 | gp_ci.pRasterizationState = &rs_ci; |
| 6445 | gp_ci.pColorBlendState = &cb_ci; |
| 6446 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6447 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6448 | gp_ci.layout = pipeline_layout; |
| 6449 | gp_ci.renderPass = renderPass(); |
| 6450 | |
| 6451 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6452 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6453 | |
| 6454 | VkPipeline pipeline; |
| 6455 | VkPipelineCache pipelineCache; |
| 6456 | |
| 6457 | err = |
| 6458 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6459 | ASSERT_VK_SUCCESS(err); |
| 6460 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6461 | &gp_ci, NULL, &pipeline); |
| 6462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6463 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6464 | |
| 6465 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6466 | // First need to successfully create the PSO from above by setting |
| 6467 | // pViewports |
| 6468 | m_errorMonitor->SetDesiredFailureMsg( |
| 6469 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6470 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6471 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6472 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6473 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6474 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6475 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6476 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6477 | ASSERT_VK_SUCCESS(err); |
| 6478 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6479 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6480 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6481 | VkViewport viewports[2] = {}; // don't care about data |
| 6482 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6483 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6484 | Draw(1, 0, 0, 0); |
| 6485 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6486 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6487 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6488 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6489 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6492 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6493 | } |
| 6494 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6495 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6496 | VkResult err; |
| 6497 | |
| 6498 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6499 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6500 | |
| 6501 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6502 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6503 | |
| 6504 | VkDescriptorPoolSize ds_type_count = {}; |
| 6505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6506 | ds_type_count.descriptorCount = 1; |
| 6507 | |
| 6508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6510 | ds_pool_ci.maxSets = 1; |
| 6511 | ds_pool_ci.poolSizeCount = 1; |
| 6512 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6513 | |
| 6514 | VkDescriptorPool ds_pool; |
| 6515 | err = |
| 6516 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6517 | ASSERT_VK_SUCCESS(err); |
| 6518 | |
| 6519 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6520 | dsl_binding.binding = 0; |
| 6521 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6522 | dsl_binding.descriptorCount = 1; |
| 6523 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6524 | |
| 6525 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6526 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6527 | ds_layout_ci.bindingCount = 1; |
| 6528 | ds_layout_ci.pBindings = &dsl_binding; |
| 6529 | |
| 6530 | VkDescriptorSetLayout ds_layout; |
| 6531 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6532 | &ds_layout); |
| 6533 | ASSERT_VK_SUCCESS(err); |
| 6534 | |
| 6535 | VkDescriptorSet descriptorSet; |
| 6536 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6537 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6538 | alloc_info.descriptorSetCount = 1; |
| 6539 | alloc_info.descriptorPool = ds_pool; |
| 6540 | alloc_info.pSetLayouts = &ds_layout; |
| 6541 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6542 | &descriptorSet); |
| 6543 | ASSERT_VK_SUCCESS(err); |
| 6544 | |
| 6545 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6546 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6547 | pipeline_layout_ci.setLayoutCount = 1; |
| 6548 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6549 | |
| 6550 | VkPipelineLayout pipeline_layout; |
| 6551 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6552 | &pipeline_layout); |
| 6553 | ASSERT_VK_SUCCESS(err); |
| 6554 | |
| 6555 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6556 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6557 | vp_state_ci.scissorCount = 1; |
| 6558 | vp_state_ci.pScissors = NULL; |
| 6559 | vp_state_ci.viewportCount = 1; |
| 6560 | vp_state_ci.pViewports = NULL; |
| 6561 | |
| 6562 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6563 | VK_DYNAMIC_STATE_SCISSOR, |
| 6564 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6565 | // Set scissor as dynamic to avoid that error |
| 6566 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6567 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6568 | dyn_state_ci.dynamicStateCount = 2; |
| 6569 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6570 | |
| 6571 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6572 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6573 | |
| 6574 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6575 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6576 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6577 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6578 | this); // TODO - We shouldn't need a fragment shader |
| 6579 | // but add it to be able to run on more devices |
| 6580 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6581 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6582 | |
| 6583 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6584 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6585 | vi_ci.pNext = nullptr; |
| 6586 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6587 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6588 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6589 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6590 | |
| 6591 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6592 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6593 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6594 | |
| 6595 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6596 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6597 | rs_ci.pNext = nullptr; |
| 6598 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6599 | // Check too low (line width of -1.0f). |
| 6600 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6601 | |
| 6602 | VkPipelineColorBlendAttachmentState att = {}; |
| 6603 | att.blendEnable = VK_FALSE; |
| 6604 | att.colorWriteMask = 0xf; |
| 6605 | |
| 6606 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6607 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6608 | cb_ci.pNext = nullptr; |
| 6609 | cb_ci.attachmentCount = 1; |
| 6610 | cb_ci.pAttachments = &att; |
| 6611 | |
| 6612 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6613 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6614 | gp_ci.stageCount = 2; |
| 6615 | gp_ci.pStages = shaderStages; |
| 6616 | gp_ci.pVertexInputState = &vi_ci; |
| 6617 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6618 | gp_ci.pViewportState = &vp_state_ci; |
| 6619 | gp_ci.pRasterizationState = &rs_ci; |
| 6620 | gp_ci.pColorBlendState = &cb_ci; |
| 6621 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6622 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6623 | gp_ci.layout = pipeline_layout; |
| 6624 | gp_ci.renderPass = renderPass(); |
| 6625 | |
| 6626 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6627 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6628 | |
| 6629 | VkPipeline pipeline; |
| 6630 | VkPipelineCache pipelineCache; |
| 6631 | |
| 6632 | err = |
| 6633 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6634 | ASSERT_VK_SUCCESS(err); |
| 6635 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6636 | &gp_ci, NULL, &pipeline); |
| 6637 | |
| 6638 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6639 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6640 | |
| 6641 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6642 | "Attempt to set lineWidth to 65536"); |
| 6643 | |
| 6644 | // Check too high (line width of 65536.0f). |
| 6645 | rs_ci.lineWidth = 65536.0f; |
| 6646 | |
| 6647 | err = |
| 6648 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6649 | ASSERT_VK_SUCCESS(err); |
| 6650 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6651 | &gp_ci, NULL, &pipeline); |
| 6652 | |
| 6653 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6654 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6655 | |
| 6656 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6657 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6658 | |
| 6659 | dyn_state_ci.dynamicStateCount = 3; |
| 6660 | |
| 6661 | rs_ci.lineWidth = 1.0f; |
| 6662 | |
| 6663 | err = |
| 6664 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6665 | ASSERT_VK_SUCCESS(err); |
| 6666 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6667 | &gp_ci, NULL, &pipeline); |
| 6668 | BeginCommandBuffer(); |
| 6669 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6670 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6671 | |
| 6672 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6673 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6674 | m_errorMonitor->VerifyFound(); |
| 6675 | |
| 6676 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6677 | "Attempt to set lineWidth to 65536"); |
| 6678 | |
| 6679 | // Check too high with dynamic setting. |
| 6680 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6681 | m_errorMonitor->VerifyFound(); |
| 6682 | EndCommandBuffer(); |
| 6683 | |
| 6684 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6685 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6686 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6687 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6688 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6689 | } |
| 6690 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6691 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6692 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6693 | m_errorMonitor->SetDesiredFailureMsg( |
| 6694 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6695 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6696 | |
| 6697 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6698 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6699 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6700 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6702 | // that |
| 6703 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6704 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6705 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6706 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6707 | } |
| 6708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6710 | // Bind a BeginRenderPass 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"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6714 | |
| 6715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6716 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6717 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6718 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6719 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6720 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6721 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6722 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6723 | rp_begin.pNext = NULL; |
| 6724 | rp_begin.renderPass = renderPass(); |
| 6725 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6727 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6728 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6729 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6730 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6731 | } |
| 6732 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6733 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 6734 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 6735 | "the number of renderPass attachments that use loadOp" |
| 6736 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 6737 | |
| 6738 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6739 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6740 | |
| 6741 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 6742 | VkAttachmentReference attach = {}; |
| 6743 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6744 | VkSubpassDescription subpass = {}; |
| 6745 | subpass.inputAttachmentCount = 1; |
| 6746 | subpass.pInputAttachments = &attach; |
| 6747 | VkRenderPassCreateInfo rpci = {}; |
| 6748 | rpci.subpassCount = 1; |
| 6749 | rpci.pSubpasses = &subpass; |
| 6750 | rpci.attachmentCount = 1; |
| 6751 | VkAttachmentDescription attach_desc = {}; |
| 6752 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6753 | // Set loadOp to CLEAR |
| 6754 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6755 | rpci.pAttachments = &attach_desc; |
| 6756 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 6757 | VkRenderPass rp; |
| 6758 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6759 | |
| 6760 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 6761 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 6762 | hinfo.renderPass = VK_NULL_HANDLE; |
| 6763 | hinfo.subpass = 0; |
| 6764 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 6765 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 6766 | hinfo.queryFlags = 0; |
| 6767 | hinfo.pipelineStatistics = 0; |
| 6768 | VkCommandBufferBeginInfo info = {}; |
| 6769 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 6770 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6771 | info.pInheritanceInfo = &hinfo; |
| 6772 | |
| 6773 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 6774 | VkRenderPassBeginInfo rp_begin = {}; |
| 6775 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6776 | rp_begin.pNext = NULL; |
| 6777 | rp_begin.renderPass = renderPass(); |
| 6778 | rp_begin.framebuffer = framebuffer(); |
| 6779 | rp_begin.clearValueCount = 0; // Should be 1 |
| 6780 | |
| 6781 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6782 | " has a clearValueCount of 0 but the " |
| 6783 | "actual number of attachments in " |
| 6784 | "renderPass "); |
| 6785 | |
| 6786 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6787 | VK_SUBPASS_CONTENTS_INLINE); |
| 6788 | |
| 6789 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 6790 | |
| 6791 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6792 | } |
| 6793 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6794 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6795 | |
| 6796 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6797 | |
| 6798 | m_errorMonitor->SetDesiredFailureMsg( |
| 6799 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6800 | "It is invalid to issue this call inside an active render pass"); |
| 6801 | |
| 6802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6803 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6804 | |
| 6805 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6806 | BeginCommandBuffer(); |
| 6807 | |
| 6808 | // Call directly into vkEndCommandBuffer instead of the |
| 6809 | // the framework's EndCommandBuffer, which inserts a |
| 6810 | // vkEndRenderPass |
| 6811 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6812 | |
| 6813 | m_errorMonitor->VerifyFound(); |
| 6814 | |
| 6815 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6816 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6817 | } |
| 6818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6819 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6820 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6821 | m_errorMonitor->SetDesiredFailureMsg( |
| 6822 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6823 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6824 | |
| 6825 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6826 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6827 | |
| 6828 | // Renderpass is started here |
| 6829 | BeginCommandBuffer(); |
| 6830 | |
| 6831 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6832 | vk_testing::Buffer dstBuffer; |
| 6833 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6834 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6835 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6836 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6837 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6838 | } |
| 6839 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6840 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6841 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6842 | m_errorMonitor->SetDesiredFailureMsg( |
| 6843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6844 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6845 | |
| 6846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6847 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6848 | |
| 6849 | // Renderpass is started here |
| 6850 | BeginCommandBuffer(); |
| 6851 | |
| 6852 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6853 | vk_testing::Buffer dstBuffer; |
| 6854 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6855 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6856 | VkDeviceSize dstOffset = 0; |
| 6857 | VkDeviceSize dataSize = 1024; |
| 6858 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6860 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6861 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6862 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6863 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6864 | } |
| 6865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6866 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6867 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6868 | m_errorMonitor->SetDesiredFailureMsg( |
| 6869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6870 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6871 | |
| 6872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6873 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6874 | |
| 6875 | // Renderpass is started here |
| 6876 | BeginCommandBuffer(); |
| 6877 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6878 | VkClearColorValue clear_color; |
| 6879 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6880 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6881 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6882 | const int32_t tex_width = 32; |
| 6883 | const int32_t tex_height = 32; |
| 6884 | VkImageCreateInfo image_create_info = {}; |
| 6885 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6886 | image_create_info.pNext = NULL; |
| 6887 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6888 | image_create_info.format = tex_format; |
| 6889 | image_create_info.extent.width = tex_width; |
| 6890 | image_create_info.extent.height = tex_height; |
| 6891 | image_create_info.extent.depth = 1; |
| 6892 | image_create_info.mipLevels = 1; |
| 6893 | image_create_info.arrayLayers = 1; |
| 6894 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6895 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6896 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6897 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6898 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6899 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6900 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6901 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6902 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6903 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6905 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6906 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6907 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6908 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6909 | } |
| 6910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6911 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6912 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6913 | m_errorMonitor->SetDesiredFailureMsg( |
| 6914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6915 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6916 | |
| 6917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6919 | |
| 6920 | // Renderpass is started here |
| 6921 | BeginCommandBuffer(); |
| 6922 | |
| 6923 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6924 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6925 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6926 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6927 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6928 | image_create_info.extent.width = 64; |
| 6929 | image_create_info.extent.height = 64; |
| 6930 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6931 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6932 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6933 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6934 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6935 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6937 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6938 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6940 | vkCmdClearDepthStencilImage( |
| 6941 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6942 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6943 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6944 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6945 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6946 | } |
| 6947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6948 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6949 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6950 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6951 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6952 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6953 | "vkCmdClearAttachments: This call " |
| 6954 | "must be issued inside an active " |
| 6955 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6956 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6957 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6958 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6959 | |
| 6960 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6961 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6962 | ASSERT_VK_SUCCESS(err); |
| 6963 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6964 | VkClearAttachment color_attachment; |
| 6965 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6966 | color_attachment.clearValue.color.float32[0] = 0; |
| 6967 | color_attachment.clearValue.color.float32[1] = 0; |
| 6968 | color_attachment.clearValue.color.float32[2] = 0; |
| 6969 | color_attachment.clearValue.color.float32[3] = 0; |
| 6970 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6971 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6972 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6973 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6974 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6975 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6976 | } |
| 6977 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6978 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6979 | // Try to add a buffer memory barrier with no buffer. |
| 6980 | m_errorMonitor->SetDesiredFailureMsg( |
| 6981 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6982 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6983 | |
| 6984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6985 | BeginCommandBuffer(); |
| 6986 | |
| 6987 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6988 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6989 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6990 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6991 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6992 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6993 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6994 | buf_barrier.offset = 0; |
| 6995 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6996 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6997 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6998 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6999 | |
| 7000 | m_errorMonitor->VerifyFound(); |
| 7001 | } |
| 7002 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 7003 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 7004 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 7005 | |
| 7006 | m_errorMonitor->SetDesiredFailureMsg( |
| 7007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 7008 | |
| 7009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7011 | |
| 7012 | VkMemoryBarrier mem_barrier = {}; |
| 7013 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 7014 | mem_barrier.pNext = NULL; |
| 7015 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7016 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7017 | BeginCommandBuffer(); |
| 7018 | // BeginCommandBuffer() starts a render pass |
| 7019 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7020 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7021 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 7022 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 7023 | m_errorMonitor->VerifyFound(); |
| 7024 | |
| 7025 | m_errorMonitor->SetDesiredFailureMsg( |
| 7026 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7027 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 7028 | VkImageObj image(m_device); |
| 7029 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 7030 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 7031 | ASSERT_TRUE(image.initialized()); |
| 7032 | VkImageMemoryBarrier img_barrier = {}; |
| 7033 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 7034 | img_barrier.pNext = NULL; |
| 7035 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7036 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7037 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7038 | // New layout can't be UNDEFINED |
| 7039 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 7040 | img_barrier.image = image.handle(); |
| 7041 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7042 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7043 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7044 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7045 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7046 | img_barrier.subresourceRange.layerCount = 1; |
| 7047 | img_barrier.subresourceRange.levelCount = 1; |
| 7048 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7049 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7050 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7051 | nullptr, 1, &img_barrier); |
| 7052 | m_errorMonitor->VerifyFound(); |
| 7053 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7054 | |
| 7055 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7056 | "Subresource must have the sum of the " |
| 7057 | "baseArrayLayer"); |
| 7058 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 7059 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 7060 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7061 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7062 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7063 | nullptr, 1, &img_barrier); |
| 7064 | m_errorMonitor->VerifyFound(); |
| 7065 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7066 | |
| 7067 | m_errorMonitor->SetDesiredFailureMsg( |
| 7068 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7069 | "Subresource must have the sum of the baseMipLevel"); |
| 7070 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 7071 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 7072 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7073 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7074 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7075 | nullptr, 1, &img_barrier); |
| 7076 | m_errorMonitor->VerifyFound(); |
| 7077 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7078 | |
| 7079 | m_errorMonitor->SetDesiredFailureMsg( |
| 7080 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7081 | "Buffer Barriers cannot be used during a render pass"); |
| 7082 | vk_testing::Buffer buffer; |
| 7083 | buffer.init(*m_device, 256); |
| 7084 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7085 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7086 | buf_barrier.pNext = NULL; |
| 7087 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7088 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7089 | buf_barrier.buffer = buffer.handle(); |
| 7090 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7091 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7092 | buf_barrier.offset = 0; |
| 7093 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7094 | // Can't send buffer barrier during a render pass |
| 7095 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7096 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7097 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7098 | &buf_barrier, 0, nullptr); |
| 7099 | m_errorMonitor->VerifyFound(); |
| 7100 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7101 | |
| 7102 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7103 | "which is not less than total size"); |
| 7104 | buf_barrier.offset = 257; |
| 7105 | // Offset greater than total size |
| 7106 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7107 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7108 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7109 | &buf_barrier, 0, nullptr); |
| 7110 | m_errorMonitor->VerifyFound(); |
| 7111 | buf_barrier.offset = 0; |
| 7112 | |
| 7113 | m_errorMonitor->SetDesiredFailureMsg( |
| 7114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 7115 | buf_barrier.size = 257; |
| 7116 | // Size greater than total size |
| 7117 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7118 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7119 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7120 | &buf_barrier, 0, nullptr); |
| 7121 | m_errorMonitor->VerifyFound(); |
| 7122 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7123 | |
| 7124 | m_errorMonitor->SetDesiredFailureMsg( |
| 7125 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7126 | "Image is a depth and stencil format and thus must " |
| 7127 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7128 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7129 | VkDepthStencilObj ds_image(m_device); |
| 7130 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7131 | ASSERT_TRUE(ds_image.initialized()); |
| 7132 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7133 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7134 | img_barrier.image = ds_image.handle(); |
| 7135 | // Leave aspectMask at COLOR on purpose |
| 7136 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7137 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7138 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7139 | nullptr, 1, &img_barrier); |
| 7140 | m_errorMonitor->VerifyFound(); |
| 7141 | } |
| 7142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7143 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7144 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7145 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7146 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7147 | m_errorMonitor->SetDesiredFailureMsg( |
| 7148 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7149 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7150 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7151 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7152 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7153 | uint32_t qfi = 0; |
| 7154 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7155 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7156 | buffCI.size = 1024; |
| 7157 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7158 | buffCI.queueFamilyIndexCount = 1; |
| 7159 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7160 | |
| 7161 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7162 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7163 | ASSERT_VK_SUCCESS(err); |
| 7164 | |
| 7165 | BeginCommandBuffer(); |
| 7166 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7167 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7168 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7169 | // 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] | 7170 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7171 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7173 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7174 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7175 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7176 | } |
| 7177 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7178 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7179 | // Create an out-of-range queueFamilyIndex |
| 7180 | m_errorMonitor->SetDesiredFailureMsg( |
| 7181 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7182 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7183 | "of the indices specified when the device was created, via the " |
| 7184 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7185 | |
| 7186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7187 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7188 | VkBufferCreateInfo buffCI = {}; |
| 7189 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7190 | buffCI.size = 1024; |
| 7191 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7192 | buffCI.queueFamilyIndexCount = 1; |
| 7193 | // Introduce failure by specifying invalid queue_family_index |
| 7194 | uint32_t qfi = 777; |
| 7195 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7196 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7197 | |
| 7198 | VkBuffer ib; |
| 7199 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7200 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7201 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7202 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7203 | } |
| 7204 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7205 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7206 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7207 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7209 | m_errorMonitor->SetDesiredFailureMsg( |
| 7210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7211 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7212 | |
| 7213 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7214 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7215 | |
| 7216 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7217 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7218 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7219 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7220 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7221 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7222 | } |
| 7223 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7224 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7225 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7226 | "that do not have correct usage bits sets."); |
| 7227 | VkResult err; |
| 7228 | |
| 7229 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7230 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7231 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7232 | ds_type_count[i].type = VkDescriptorType(i); |
| 7233 | ds_type_count[i].descriptorCount = 1; |
| 7234 | } |
| 7235 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7236 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7237 | ds_pool_ci.pNext = NULL; |
| 7238 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7239 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7240 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7241 | |
| 7242 | VkDescriptorPool ds_pool; |
| 7243 | err = |
| 7244 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7245 | ASSERT_VK_SUCCESS(err); |
| 7246 | |
| 7247 | // Create 10 layouts where each has a single descriptor of different type |
| 7248 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7249 | {}; |
| 7250 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7251 | dsl_binding[i].binding = 0; |
| 7252 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7253 | dsl_binding[i].descriptorCount = 1; |
| 7254 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7255 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7256 | } |
| 7257 | |
| 7258 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7259 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7260 | ds_layout_ci.pNext = NULL; |
| 7261 | ds_layout_ci.bindingCount = 1; |
| 7262 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7263 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7264 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7265 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7266 | NULL, ds_layouts + i); |
| 7267 | ASSERT_VK_SUCCESS(err); |
| 7268 | } |
| 7269 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7270 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7271 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7272 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7273 | alloc_info.descriptorPool = ds_pool; |
| 7274 | alloc_info.pSetLayouts = ds_layouts; |
| 7275 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7276 | descriptor_sets); |
| 7277 | ASSERT_VK_SUCCESS(err); |
| 7278 | |
| 7279 | // Create a buffer & bufferView to be used for invalid updates |
| 7280 | VkBufferCreateInfo buff_ci = {}; |
| 7281 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7282 | // This usage is not valid for any descriptor type |
| 7283 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7284 | buff_ci.size = 256; |
| 7285 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7286 | VkBuffer buffer; |
| 7287 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7288 | ASSERT_VK_SUCCESS(err); |
| 7289 | |
| 7290 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7291 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7292 | buff_view_ci.buffer = buffer; |
| 7293 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7294 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7295 | VkBufferView buff_view; |
| 7296 | err = |
| 7297 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7298 | ASSERT_VK_SUCCESS(err); |
| 7299 | |
| 7300 | // Create an image to be used for invalid updates |
| 7301 | VkImageCreateInfo image_ci = {}; |
| 7302 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7303 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7304 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7305 | image_ci.extent.width = 64; |
| 7306 | image_ci.extent.height = 64; |
| 7307 | image_ci.extent.depth = 1; |
| 7308 | image_ci.mipLevels = 1; |
| 7309 | image_ci.arrayLayers = 1; |
| 7310 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7311 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7312 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7313 | // This usage is not valid for any descriptor type |
| 7314 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7315 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7316 | VkImage image; |
| 7317 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7318 | ASSERT_VK_SUCCESS(err); |
| 7319 | // Bind memory to image |
| 7320 | VkMemoryRequirements mem_reqs; |
| 7321 | VkDeviceMemory image_mem; |
| 7322 | bool pass; |
| 7323 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7324 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7325 | mem_alloc.pNext = NULL; |
| 7326 | mem_alloc.allocationSize = 0; |
| 7327 | mem_alloc.memoryTypeIndex = 0; |
| 7328 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7329 | mem_alloc.allocationSize = mem_reqs.size; |
| 7330 | pass = |
| 7331 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7332 | ASSERT_TRUE(pass); |
| 7333 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7334 | ASSERT_VK_SUCCESS(err); |
| 7335 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7336 | ASSERT_VK_SUCCESS(err); |
| 7337 | // Now create view for image |
| 7338 | VkImageViewCreateInfo image_view_ci = {}; |
| 7339 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7340 | image_view_ci.image = image; |
| 7341 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7342 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7343 | image_view_ci.subresourceRange.layerCount = 1; |
| 7344 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7345 | image_view_ci.subresourceRange.levelCount = 1; |
| 7346 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7347 | VkImageView image_view; |
| 7348 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7349 | &image_view); |
| 7350 | ASSERT_VK_SUCCESS(err); |
| 7351 | |
| 7352 | VkDescriptorBufferInfo buff_info = {}; |
| 7353 | buff_info.buffer = buffer; |
| 7354 | VkDescriptorImageInfo img_info = {}; |
| 7355 | img_info.imageView = image_view; |
| 7356 | VkWriteDescriptorSet descriptor_write = {}; |
| 7357 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7358 | descriptor_write.dstBinding = 0; |
| 7359 | descriptor_write.descriptorCount = 1; |
| 7360 | descriptor_write.pTexelBufferView = &buff_view; |
| 7361 | descriptor_write.pBufferInfo = &buff_info; |
| 7362 | descriptor_write.pImageInfo = &img_info; |
| 7363 | |
| 7364 | // These error messages align with VkDescriptorType struct |
| 7365 | const char *error_msgs[] = { |
| 7366 | "", // placeholder, no error for SAMPLER descriptor |
| 7367 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7368 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7369 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7370 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7371 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 7372 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7373 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7374 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7375 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7376 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7377 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7378 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7379 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7380 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7381 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7382 | error_msgs[i]); |
| 7383 | |
| 7384 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7385 | NULL); |
| 7386 | |
| 7387 | m_errorMonitor->VerifyFound(); |
| 7388 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7389 | } |
| 7390 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7391 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7392 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7393 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7394 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7395 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7396 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7397 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7398 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7399 | } |
| 7400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7401 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7402 | // 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] | 7403 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7405 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7406 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7407 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7408 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7409 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7410 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7411 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7412 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7413 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7414 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7415 | |
| 7416 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7417 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7418 | ds_pool_ci.pNext = NULL; |
| 7419 | ds_pool_ci.maxSets = 1; |
| 7420 | ds_pool_ci.poolSizeCount = 1; |
| 7421 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7422 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7423 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7424 | err = |
| 7425 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7426 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7427 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7428 | dsl_binding.binding = 0; |
| 7429 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7430 | dsl_binding.descriptorCount = 1; |
| 7431 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7432 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7433 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7434 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7435 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7436 | ds_layout_ci.pNext = NULL; |
| 7437 | ds_layout_ci.bindingCount = 1; |
| 7438 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7439 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7440 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7441 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7442 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7443 | ASSERT_VK_SUCCESS(err); |
| 7444 | |
| 7445 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7446 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7447 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7448 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7449 | alloc_info.descriptorPool = ds_pool; |
| 7450 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7451 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7452 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7453 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7454 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7455 | VkSamplerCreateInfo sampler_ci = {}; |
| 7456 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7457 | sampler_ci.pNext = NULL; |
| 7458 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7459 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7460 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7461 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7462 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7463 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7464 | sampler_ci.mipLodBias = 1.0; |
| 7465 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7466 | sampler_ci.maxAnisotropy = 1; |
| 7467 | sampler_ci.compareEnable = VK_FALSE; |
| 7468 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7469 | sampler_ci.minLod = 1.0; |
| 7470 | sampler_ci.maxLod = 1.0; |
| 7471 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7472 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7473 | VkSampler sampler; |
| 7474 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7475 | ASSERT_VK_SUCCESS(err); |
| 7476 | |
| 7477 | VkDescriptorImageInfo info = {}; |
| 7478 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7479 | |
| 7480 | VkWriteDescriptorSet descriptor_write; |
| 7481 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7482 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7483 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7484 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7485 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7486 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7487 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7488 | |
| 7489 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7490 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7491 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7492 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7493 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7494 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7495 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7496 | } |
| 7497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7498 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7499 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7500 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7501 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7502 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7504 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7505 | "starting at binding offset of 0 combined with update array element " |
| 7506 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7507 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7509 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7510 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7511 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7512 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7513 | |
| 7514 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7515 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7516 | ds_pool_ci.pNext = NULL; |
| 7517 | ds_pool_ci.maxSets = 1; |
| 7518 | ds_pool_ci.poolSizeCount = 1; |
| 7519 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7520 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7521 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7522 | err = |
| 7523 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7524 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7525 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7526 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7527 | dsl_binding.binding = 0; |
| 7528 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7529 | dsl_binding.descriptorCount = 1; |
| 7530 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7531 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7532 | |
| 7533 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7534 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7535 | ds_layout_ci.pNext = NULL; |
| 7536 | ds_layout_ci.bindingCount = 1; |
| 7537 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7538 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7539 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7540 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7541 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7542 | ASSERT_VK_SUCCESS(err); |
| 7543 | |
| 7544 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7545 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7546 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7547 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7548 | alloc_info.descriptorPool = ds_pool; |
| 7549 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7550 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7551 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7552 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7553 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7554 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7555 | VkDescriptorBufferInfo buff_info = {}; |
| 7556 | buff_info.buffer = |
| 7557 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7558 | buff_info.offset = 0; |
| 7559 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7560 | |
| 7561 | VkWriteDescriptorSet descriptor_write; |
| 7562 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7563 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7564 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7565 | descriptor_write.dstArrayElement = |
| 7566 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7567 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7568 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7569 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7570 | |
| 7571 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7572 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7573 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7574 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7575 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7576 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7577 | } |
| 7578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7579 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7580 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7581 | // index 2 |
| 7582 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7583 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7584 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7585 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7586 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7587 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7588 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7589 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7590 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7591 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7592 | |
| 7593 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7594 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7595 | ds_pool_ci.pNext = NULL; |
| 7596 | ds_pool_ci.maxSets = 1; |
| 7597 | ds_pool_ci.poolSizeCount = 1; |
| 7598 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7599 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7600 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7601 | err = |
| 7602 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7603 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7604 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7605 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7606 | dsl_binding.binding = 0; |
| 7607 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7608 | dsl_binding.descriptorCount = 1; |
| 7609 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7610 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7611 | |
| 7612 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7613 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7614 | ds_layout_ci.pNext = NULL; |
| 7615 | ds_layout_ci.bindingCount = 1; |
| 7616 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7617 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7618 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7619 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7620 | ASSERT_VK_SUCCESS(err); |
| 7621 | |
| 7622 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7623 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7624 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7625 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7626 | alloc_info.descriptorPool = ds_pool; |
| 7627 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7628 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7629 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7630 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7631 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7632 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7633 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7634 | sampler_ci.pNext = NULL; |
| 7635 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7636 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7637 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7638 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7639 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7640 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7641 | sampler_ci.mipLodBias = 1.0; |
| 7642 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7643 | sampler_ci.maxAnisotropy = 1; |
| 7644 | sampler_ci.compareEnable = VK_FALSE; |
| 7645 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7646 | sampler_ci.minLod = 1.0; |
| 7647 | sampler_ci.maxLod = 1.0; |
| 7648 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7649 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7650 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7651 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7652 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7653 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7654 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7655 | VkDescriptorImageInfo info = {}; |
| 7656 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7657 | |
| 7658 | VkWriteDescriptorSet descriptor_write; |
| 7659 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7660 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7661 | descriptor_write.dstSet = descriptorSet; |
| 7662 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7663 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7664 | // 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] | 7665 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7666 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7667 | |
| 7668 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7669 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7670 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7671 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7672 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7673 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7674 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7675 | } |
| 7676 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7677 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7678 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7679 | // types |
| 7680 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7681 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7682 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7683 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7684 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7685 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7686 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7687 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7688 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7689 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7690 | |
| 7691 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7692 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7693 | ds_pool_ci.pNext = NULL; |
| 7694 | ds_pool_ci.maxSets = 1; |
| 7695 | ds_pool_ci.poolSizeCount = 1; |
| 7696 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7697 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7698 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7699 | err = |
| 7700 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7701 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7702 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7703 | dsl_binding.binding = 0; |
| 7704 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7705 | dsl_binding.descriptorCount = 1; |
| 7706 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7707 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7708 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7709 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7710 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7711 | ds_layout_ci.pNext = NULL; |
| 7712 | ds_layout_ci.bindingCount = 1; |
| 7713 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7714 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7715 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7716 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7717 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7718 | ASSERT_VK_SUCCESS(err); |
| 7719 | |
| 7720 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7721 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7722 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7723 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7724 | alloc_info.descriptorPool = ds_pool; |
| 7725 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7726 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7727 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7728 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7729 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7730 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7731 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7732 | sampler_ci.pNext = NULL; |
| 7733 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7734 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7735 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7736 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7737 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7738 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7739 | sampler_ci.mipLodBias = 1.0; |
| 7740 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7741 | sampler_ci.maxAnisotropy = 1; |
| 7742 | sampler_ci.compareEnable = VK_FALSE; |
| 7743 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7744 | sampler_ci.minLod = 1.0; |
| 7745 | sampler_ci.maxLod = 1.0; |
| 7746 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7747 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7748 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7749 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7750 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7751 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7752 | VkDescriptorImageInfo info = {}; |
| 7753 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7754 | |
| 7755 | VkWriteDescriptorSet descriptor_write; |
| 7756 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7757 | descriptor_write.sType = |
| 7758 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7759 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7760 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7761 | // 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] | 7762 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7763 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7764 | |
| 7765 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7766 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7767 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7768 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7769 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7770 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7771 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7772 | } |
| 7773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7774 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7775 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7776 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7778 | m_errorMonitor->SetDesiredFailureMsg( |
| 7779 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7780 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7781 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7783 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7784 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7785 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7786 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7787 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7788 | |
| 7789 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7790 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7791 | ds_pool_ci.pNext = NULL; |
| 7792 | ds_pool_ci.maxSets = 1; |
| 7793 | ds_pool_ci.poolSizeCount = 1; |
| 7794 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7795 | |
| 7796 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7797 | err = |
| 7798 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7799 | ASSERT_VK_SUCCESS(err); |
| 7800 | |
| 7801 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7802 | dsl_binding.binding = 0; |
| 7803 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7804 | dsl_binding.descriptorCount = 1; |
| 7805 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7806 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7807 | |
| 7808 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7809 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7810 | ds_layout_ci.pNext = NULL; |
| 7811 | ds_layout_ci.bindingCount = 1; |
| 7812 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7813 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7814 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7815 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7816 | ASSERT_VK_SUCCESS(err); |
| 7817 | |
| 7818 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7819 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7820 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7821 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7822 | alloc_info.descriptorPool = ds_pool; |
| 7823 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7824 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7825 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7826 | ASSERT_VK_SUCCESS(err); |
| 7827 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7828 | VkSampler sampler = |
| 7829 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7830 | |
| 7831 | VkDescriptorImageInfo descriptor_info; |
| 7832 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7833 | descriptor_info.sampler = sampler; |
| 7834 | |
| 7835 | VkWriteDescriptorSet descriptor_write; |
| 7836 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7837 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7838 | descriptor_write.dstSet = descriptorSet; |
| 7839 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7840 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7841 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7842 | descriptor_write.pImageInfo = &descriptor_info; |
| 7843 | |
| 7844 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7845 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7846 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7847 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7848 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7849 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7850 | } |
| 7851 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7852 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7853 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7854 | // imageView |
| 7855 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7856 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7857 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7858 | "Attempted write update to combined " |
| 7859 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7860 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7861 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7862 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7863 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7864 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7865 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7866 | |
| 7867 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7868 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7869 | ds_pool_ci.pNext = NULL; |
| 7870 | ds_pool_ci.maxSets = 1; |
| 7871 | ds_pool_ci.poolSizeCount = 1; |
| 7872 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7873 | |
| 7874 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7875 | err = |
| 7876 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7877 | ASSERT_VK_SUCCESS(err); |
| 7878 | |
| 7879 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7880 | dsl_binding.binding = 0; |
| 7881 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7882 | dsl_binding.descriptorCount = 1; |
| 7883 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7884 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7885 | |
| 7886 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7887 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7888 | ds_layout_ci.pNext = NULL; |
| 7889 | ds_layout_ci.bindingCount = 1; |
| 7890 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7891 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7892 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7893 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7894 | ASSERT_VK_SUCCESS(err); |
| 7895 | |
| 7896 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7897 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7898 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7899 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7900 | alloc_info.descriptorPool = ds_pool; |
| 7901 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7902 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7903 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7904 | ASSERT_VK_SUCCESS(err); |
| 7905 | |
| 7906 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7907 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7908 | sampler_ci.pNext = NULL; |
| 7909 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7910 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7911 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7912 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7913 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7914 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7915 | sampler_ci.mipLodBias = 1.0; |
| 7916 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7917 | sampler_ci.maxAnisotropy = 1; |
| 7918 | sampler_ci.compareEnable = VK_FALSE; |
| 7919 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7920 | sampler_ci.minLod = 1.0; |
| 7921 | sampler_ci.maxLod = 1.0; |
| 7922 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7923 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7924 | |
| 7925 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7926 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7927 | ASSERT_VK_SUCCESS(err); |
| 7928 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7929 | VkImageView view = |
| 7930 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7931 | |
| 7932 | VkDescriptorImageInfo descriptor_info; |
| 7933 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7934 | descriptor_info.sampler = sampler; |
| 7935 | descriptor_info.imageView = view; |
| 7936 | |
| 7937 | VkWriteDescriptorSet descriptor_write; |
| 7938 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7939 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7940 | descriptor_write.dstSet = descriptorSet; |
| 7941 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7942 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7943 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7944 | descriptor_write.pImageInfo = &descriptor_info; |
| 7945 | |
| 7946 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7947 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7948 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7949 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7950 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7951 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7952 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7953 | } |
| 7954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7955 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7956 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7957 | // into the other |
| 7958 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7959 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7960 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7961 | " binding #1 with type " |
| 7962 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7963 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7964 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7966 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7967 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7968 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7969 | ds_type_count[0].descriptorCount = 1; |
| 7970 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7971 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7972 | |
| 7973 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7974 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7975 | ds_pool_ci.pNext = NULL; |
| 7976 | ds_pool_ci.maxSets = 1; |
| 7977 | ds_pool_ci.poolSizeCount = 2; |
| 7978 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7979 | |
| 7980 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7981 | err = |
| 7982 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7983 | ASSERT_VK_SUCCESS(err); |
| 7984 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7985 | dsl_binding[0].binding = 0; |
| 7986 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7987 | dsl_binding[0].descriptorCount = 1; |
| 7988 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7989 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7990 | dsl_binding[1].binding = 1; |
| 7991 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7992 | dsl_binding[1].descriptorCount = 1; |
| 7993 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7994 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7995 | |
| 7996 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7997 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7998 | ds_layout_ci.pNext = NULL; |
| 7999 | ds_layout_ci.bindingCount = 2; |
| 8000 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8001 | |
| 8002 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8003 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8004 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8005 | ASSERT_VK_SUCCESS(err); |
| 8006 | |
| 8007 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8008 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8009 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8010 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8011 | alloc_info.descriptorPool = ds_pool; |
| 8012 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8013 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8014 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8015 | ASSERT_VK_SUCCESS(err); |
| 8016 | |
| 8017 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8018 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8019 | sampler_ci.pNext = NULL; |
| 8020 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8021 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8022 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8023 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8024 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8025 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8026 | sampler_ci.mipLodBias = 1.0; |
| 8027 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8028 | sampler_ci.maxAnisotropy = 1; |
| 8029 | sampler_ci.compareEnable = VK_FALSE; |
| 8030 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8031 | sampler_ci.minLod = 1.0; |
| 8032 | sampler_ci.maxLod = 1.0; |
| 8033 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8034 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8035 | |
| 8036 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8037 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8038 | ASSERT_VK_SUCCESS(err); |
| 8039 | |
| 8040 | VkDescriptorImageInfo info = {}; |
| 8041 | info.sampler = sampler; |
| 8042 | |
| 8043 | VkWriteDescriptorSet descriptor_write; |
| 8044 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 8045 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8046 | descriptor_write.dstSet = descriptorSet; |
| 8047 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8048 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8049 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8050 | descriptor_write.pImageInfo = &info; |
| 8051 | // This write update should succeed |
| 8052 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8053 | // Now perform a copy update that fails due to type mismatch |
| 8054 | VkCopyDescriptorSet copy_ds_update; |
| 8055 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8056 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8057 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8058 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8059 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8060 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8061 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8062 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8063 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8064 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8065 | // 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] | 8066 | m_errorMonitor->SetDesiredFailureMsg( |
| 8067 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8068 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8069 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8070 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8071 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8072 | copy_ds_update.srcBinding = |
| 8073 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8074 | copy_ds_update.dstSet = descriptorSet; |
| 8075 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8076 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8077 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8078 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8079 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8080 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8081 | // 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] | 8082 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8083 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 8084 | "update array offset of 0 and update of " |
| 8085 | "5 descriptors oversteps total number " |
| 8086 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8087 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8088 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8089 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8090 | copy_ds_update.srcSet = descriptorSet; |
| 8091 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8092 | copy_ds_update.dstSet = descriptorSet; |
| 8093 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8094 | copy_ds_update.descriptorCount = |
| 8095 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8096 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8097 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8098 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8099 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8100 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8101 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8102 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8103 | } |
| 8104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8105 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 8106 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 8107 | // sampleCount |
| 8108 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8109 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8110 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8111 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8112 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8114 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8115 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8116 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8117 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8118 | |
| 8119 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8120 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8121 | ds_pool_ci.pNext = NULL; |
| 8122 | ds_pool_ci.maxSets = 1; |
| 8123 | ds_pool_ci.poolSizeCount = 1; |
| 8124 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8125 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8126 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8127 | err = |
| 8128 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8129 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8130 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8131 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8132 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8133 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8134 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8135 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8136 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8137 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8138 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8139 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8140 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8141 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8142 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8143 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8144 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8145 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8146 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8147 | ASSERT_VK_SUCCESS(err); |
| 8148 | |
| 8149 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8150 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8151 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8152 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8153 | alloc_info.descriptorPool = ds_pool; |
| 8154 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8155 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8156 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8157 | ASSERT_VK_SUCCESS(err); |
| 8158 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8159 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8160 | pipe_ms_state_ci.sType = |
| 8161 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8162 | pipe_ms_state_ci.pNext = NULL; |
| 8163 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8164 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8165 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8166 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8167 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8168 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8169 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8170 | pipeline_layout_ci.pNext = NULL; |
| 8171 | pipeline_layout_ci.setLayoutCount = 1; |
| 8172 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8173 | |
| 8174 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8175 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8176 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8177 | ASSERT_VK_SUCCESS(err); |
| 8178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8179 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8180 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8181 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8182 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8183 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8184 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8185 | VkPipelineObj pipe(m_device); |
| 8186 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8187 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8188 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8189 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8190 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8191 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8192 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8193 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8194 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8195 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8196 | // Render triangle (the error should trigger on the attempt to draw). |
| 8197 | Draw(3, 1, 0, 0); |
| 8198 | |
| 8199 | // Finalize recording of the command buffer |
| 8200 | EndCommandBuffer(); |
| 8201 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8202 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8203 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8204 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8205 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8206 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8207 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8208 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8209 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8210 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8211 | // number of color attachments. In this case, we don't add any color |
| 8212 | // blend attachments even though we have a color attachment. |
| 8213 | VkResult err; |
| 8214 | |
| 8215 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8216 | "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] | 8217 | |
| 8218 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8219 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8220 | VkDescriptorPoolSize ds_type_count = {}; |
| 8221 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8222 | ds_type_count.descriptorCount = 1; |
| 8223 | |
| 8224 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8225 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8226 | ds_pool_ci.pNext = NULL; |
| 8227 | ds_pool_ci.maxSets = 1; |
| 8228 | ds_pool_ci.poolSizeCount = 1; |
| 8229 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8230 | |
| 8231 | VkDescriptorPool ds_pool; |
| 8232 | err = |
| 8233 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8234 | ASSERT_VK_SUCCESS(err); |
| 8235 | |
| 8236 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8237 | dsl_binding.binding = 0; |
| 8238 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8239 | dsl_binding.descriptorCount = 1; |
| 8240 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8241 | dsl_binding.pImmutableSamplers = NULL; |
| 8242 | |
| 8243 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8244 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8245 | ds_layout_ci.pNext = NULL; |
| 8246 | ds_layout_ci.bindingCount = 1; |
| 8247 | ds_layout_ci.pBindings = &dsl_binding; |
| 8248 | |
| 8249 | VkDescriptorSetLayout ds_layout; |
| 8250 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8251 | &ds_layout); |
| 8252 | ASSERT_VK_SUCCESS(err); |
| 8253 | |
| 8254 | VkDescriptorSet descriptorSet; |
| 8255 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8256 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8257 | alloc_info.descriptorSetCount = 1; |
| 8258 | alloc_info.descriptorPool = ds_pool; |
| 8259 | alloc_info.pSetLayouts = &ds_layout; |
| 8260 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8261 | &descriptorSet); |
| 8262 | ASSERT_VK_SUCCESS(err); |
| 8263 | |
| 8264 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8265 | pipe_ms_state_ci.sType = |
| 8266 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8267 | pipe_ms_state_ci.pNext = NULL; |
| 8268 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8269 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8270 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8271 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8272 | |
| 8273 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8274 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8275 | pipeline_layout_ci.pNext = NULL; |
| 8276 | pipeline_layout_ci.setLayoutCount = 1; |
| 8277 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8278 | |
| 8279 | VkPipelineLayout pipeline_layout; |
| 8280 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8281 | &pipeline_layout); |
| 8282 | ASSERT_VK_SUCCESS(err); |
| 8283 | |
| 8284 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8285 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8286 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8287 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8288 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8289 | // but add it to be able to run on more devices |
| 8290 | VkPipelineObj pipe(m_device); |
| 8291 | pipe.AddShader(&vs); |
| 8292 | pipe.AddShader(&fs); |
| 8293 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8294 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8295 | |
| 8296 | BeginCommandBuffer(); |
| 8297 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8298 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8299 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8300 | // Render triangle (the error should trigger on the attempt to draw). |
| 8301 | Draw(3, 1, 0, 0); |
| 8302 | |
| 8303 | // Finalize recording of the command buffer |
| 8304 | EndCommandBuffer(); |
| 8305 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8306 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8307 | |
| 8308 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8309 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8310 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8311 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8313 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8314 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8315 | // to issuing a Draw |
| 8316 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8318 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8319 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8320 | "vkCmdClearAttachments() issued on CB object "); |
| 8321 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8322 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8323 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8324 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8325 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8326 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8327 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8328 | |
| 8329 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8330 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8331 | ds_pool_ci.pNext = NULL; |
| 8332 | ds_pool_ci.maxSets = 1; |
| 8333 | ds_pool_ci.poolSizeCount = 1; |
| 8334 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8335 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8336 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8337 | err = |
| 8338 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8339 | ASSERT_VK_SUCCESS(err); |
| 8340 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8341 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8342 | dsl_binding.binding = 0; |
| 8343 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8344 | dsl_binding.descriptorCount = 1; |
| 8345 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8346 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8347 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8348 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8350 | ds_layout_ci.pNext = NULL; |
| 8351 | ds_layout_ci.bindingCount = 1; |
| 8352 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8353 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8354 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8355 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8356 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8357 | ASSERT_VK_SUCCESS(err); |
| 8358 | |
| 8359 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8360 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8361 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8362 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8363 | alloc_info.descriptorPool = ds_pool; |
| 8364 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8365 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8366 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8367 | ASSERT_VK_SUCCESS(err); |
| 8368 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8369 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8370 | pipe_ms_state_ci.sType = |
| 8371 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8372 | pipe_ms_state_ci.pNext = NULL; |
| 8373 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8374 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8375 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8376 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8377 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8378 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8379 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8380 | pipeline_layout_ci.pNext = NULL; |
| 8381 | pipeline_layout_ci.setLayoutCount = 1; |
| 8382 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8383 | |
| 8384 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8385 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8386 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8387 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8389 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8390 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8391 | // 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] | 8392 | // on more devices |
| 8393 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8394 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8395 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8396 | VkPipelineObj pipe(m_device); |
| 8397 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8398 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8399 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8400 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8401 | |
| 8402 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8403 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8404 | // Main thing we care about for this test is that the VkImage obj we're |
| 8405 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8406 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8407 | VkClearAttachment color_attachment; |
| 8408 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8409 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8410 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8411 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8412 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8413 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8414 | VkClearRect clear_rect = { |
| 8415 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8416 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8417 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8418 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8419 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8420 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8421 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8422 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8423 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8424 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8425 | } |
| 8426 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8427 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8428 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8429 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8430 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8431 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8432 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8433 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8435 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8436 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8437 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8438 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8439 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8440 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8441 | |
| 8442 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8443 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8444 | ds_pool_ci.pNext = NULL; |
| 8445 | ds_pool_ci.maxSets = 1; |
| 8446 | ds_pool_ci.poolSizeCount = 1; |
| 8447 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8448 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8449 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8450 | err = |
| 8451 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8452 | ASSERT_VK_SUCCESS(err); |
| 8453 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8454 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8455 | dsl_binding.binding = 0; |
| 8456 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8457 | dsl_binding.descriptorCount = 1; |
| 8458 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8459 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8460 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8461 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8462 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8463 | ds_layout_ci.pNext = NULL; |
| 8464 | ds_layout_ci.bindingCount = 1; |
| 8465 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8466 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8467 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8468 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8469 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8470 | ASSERT_VK_SUCCESS(err); |
| 8471 | |
| 8472 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8473 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8474 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8475 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8476 | alloc_info.descriptorPool = ds_pool; |
| 8477 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8478 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8479 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8480 | ASSERT_VK_SUCCESS(err); |
| 8481 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8482 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8483 | pipe_ms_state_ci.sType = |
| 8484 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8485 | pipe_ms_state_ci.pNext = NULL; |
| 8486 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8487 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8488 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8489 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8490 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8491 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8492 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8493 | pipeline_layout_ci.pNext = NULL; |
| 8494 | pipeline_layout_ci.setLayoutCount = 1; |
| 8495 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8496 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8498 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8499 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8500 | ASSERT_VK_SUCCESS(err); |
| 8501 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8502 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8503 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8504 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8505 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8506 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8507 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8508 | VkPipelineObj pipe(m_device); |
| 8509 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8510 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8511 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8512 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8513 | pipe.SetViewport(m_viewports); |
| 8514 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8515 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8516 | |
| 8517 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8518 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8519 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8520 | // Don't care about actual data, just need to get to draw to flag error |
| 8521 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8522 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8523 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8524 | 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] | 8525 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8526 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8527 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8528 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8529 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8530 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8531 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8532 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8533 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8534 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8535 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8536 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8537 | "images in the wrong layout when they're copied or transitioned."); |
| 8538 | // 3 in ValidateCmdBufImageLayouts |
| 8539 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8540 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8541 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8542 | m_errorMonitor->SetDesiredFailureMsg( |
| 8543 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8544 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8545 | |
| 8546 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8547 | // Create src & dst images to use for copy operations |
| 8548 | VkImage src_image; |
| 8549 | VkImage dst_image; |
| 8550 | |
| 8551 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8552 | const int32_t tex_width = 32; |
| 8553 | const int32_t tex_height = 32; |
| 8554 | |
| 8555 | VkImageCreateInfo image_create_info = {}; |
| 8556 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8557 | image_create_info.pNext = NULL; |
| 8558 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8559 | image_create_info.format = tex_format; |
| 8560 | image_create_info.extent.width = tex_width; |
| 8561 | image_create_info.extent.height = tex_height; |
| 8562 | image_create_info.extent.depth = 1; |
| 8563 | image_create_info.mipLevels = 1; |
| 8564 | image_create_info.arrayLayers = 4; |
| 8565 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8566 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8567 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8568 | image_create_info.flags = 0; |
| 8569 | |
| 8570 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8571 | ASSERT_VK_SUCCESS(err); |
| 8572 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8573 | ASSERT_VK_SUCCESS(err); |
| 8574 | |
| 8575 | BeginCommandBuffer(); |
| 8576 | VkImageCopy copyRegion; |
| 8577 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8578 | copyRegion.srcSubresource.mipLevel = 0; |
| 8579 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8580 | copyRegion.srcSubresource.layerCount = 1; |
| 8581 | copyRegion.srcOffset.x = 0; |
| 8582 | copyRegion.srcOffset.y = 0; |
| 8583 | copyRegion.srcOffset.z = 0; |
| 8584 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8585 | copyRegion.dstSubresource.mipLevel = 0; |
| 8586 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8587 | copyRegion.dstSubresource.layerCount = 1; |
| 8588 | copyRegion.dstOffset.x = 0; |
| 8589 | copyRegion.dstOffset.y = 0; |
| 8590 | copyRegion.dstOffset.z = 0; |
| 8591 | copyRegion.extent.width = 1; |
| 8592 | copyRegion.extent.height = 1; |
| 8593 | copyRegion.extent.depth = 1; |
| 8594 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8595 | m_errorMonitor->VerifyFound(); |
| 8596 | // Now cause error due to src image layout changing |
| 8597 | m_errorMonitor->SetDesiredFailureMsg( |
| 8598 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8599 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8600 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8601 | m_errorMonitor->VerifyFound(); |
| 8602 | // Final src error is due to bad layout type |
| 8603 | m_errorMonitor->SetDesiredFailureMsg( |
| 8604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8605 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8606 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8607 | m_errorMonitor->VerifyFound(); |
| 8608 | // Now verify same checks for dst |
| 8609 | m_errorMonitor->SetDesiredFailureMsg( |
| 8610 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8611 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8612 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8613 | m_errorMonitor->VerifyFound(); |
| 8614 | // Now cause error due to src image layout changing |
| 8615 | m_errorMonitor->SetDesiredFailureMsg( |
| 8616 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8617 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8618 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8619 | m_errorMonitor->VerifyFound(); |
| 8620 | m_errorMonitor->SetDesiredFailureMsg( |
| 8621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8622 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8623 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8624 | m_errorMonitor->VerifyFound(); |
| 8625 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8626 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8627 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8628 | image_barrier[0].image = src_image; |
| 8629 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8630 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8631 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8632 | m_errorMonitor->SetDesiredFailureMsg( |
| 8633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8634 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8635 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8636 | m_errorMonitor->VerifyFound(); |
| 8637 | |
| 8638 | // Finally some layout errors at RenderPass create time |
| 8639 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8640 | VkAttachmentReference attach = {}; |
| 8641 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8642 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8643 | VkSubpassDescription subpass = {}; |
| 8644 | subpass.inputAttachmentCount = 1; |
| 8645 | subpass.pInputAttachments = &attach; |
| 8646 | VkRenderPassCreateInfo rpci = {}; |
| 8647 | rpci.subpassCount = 1; |
| 8648 | rpci.pSubpasses = &subpass; |
| 8649 | rpci.attachmentCount = 1; |
| 8650 | VkAttachmentDescription attach_desc = {}; |
| 8651 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8652 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8653 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8654 | VkRenderPass rp; |
| 8655 | m_errorMonitor->SetDesiredFailureMsg( |
| 8656 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8657 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8658 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8659 | m_errorMonitor->VerifyFound(); |
| 8660 | // error w/ non-general layout |
| 8661 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8662 | |
| 8663 | m_errorMonitor->SetDesiredFailureMsg( |
| 8664 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8665 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8666 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8667 | m_errorMonitor->VerifyFound(); |
| 8668 | subpass.inputAttachmentCount = 0; |
| 8669 | subpass.colorAttachmentCount = 1; |
| 8670 | subpass.pColorAttachments = &attach; |
| 8671 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8672 | // perf warning for GENERAL layout on color attachment |
| 8673 | m_errorMonitor->SetDesiredFailureMsg( |
| 8674 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8675 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8676 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8677 | m_errorMonitor->VerifyFound(); |
| 8678 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8679 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8680 | m_errorMonitor->SetDesiredFailureMsg( |
| 8681 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8682 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8683 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8684 | m_errorMonitor->VerifyFound(); |
| 8685 | subpass.colorAttachmentCount = 0; |
| 8686 | subpass.pDepthStencilAttachment = &attach; |
| 8687 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8688 | // perf warning for GENERAL layout on DS attachment |
| 8689 | m_errorMonitor->SetDesiredFailureMsg( |
| 8690 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8691 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8692 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8693 | m_errorMonitor->VerifyFound(); |
| 8694 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8695 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8696 | m_errorMonitor->SetDesiredFailureMsg( |
| 8697 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8698 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8699 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8700 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8701 | // For this error we need a valid renderpass so create default one |
| 8702 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8703 | attach.attachment = 0; |
| 8704 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8705 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8706 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8707 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8708 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8709 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8710 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8711 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8712 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8713 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8714 | " with invalid first layout " |
| 8715 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8716 | "ONLY_OPTIMAL"); |
| 8717 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8718 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8719 | |
| 8720 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8721 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8722 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8723 | #endif // DRAW_STATE_TESTS |
| 8724 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8725 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8726 | #if GTEST_IS_THREADSAFE |
| 8727 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8728 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8729 | VkEvent event; |
| 8730 | bool bailout; |
| 8731 | }; |
| 8732 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8733 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8734 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8735 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8736 | for (int i = 0; i < 10000; i++) { |
| 8737 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8738 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8739 | if (data->bailout) { |
| 8740 | break; |
| 8741 | } |
| 8742 | } |
| 8743 | return NULL; |
| 8744 | } |
| 8745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8746 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8747 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8748 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8749 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8750 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8751 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8752 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8753 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8754 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8755 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8756 | // Calls AllocateCommandBuffers |
| 8757 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8758 | |
| 8759 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8760 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8761 | |
| 8762 | VkEventCreateInfo event_info; |
| 8763 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8764 | VkResult err; |
| 8765 | |
| 8766 | memset(&event_info, 0, sizeof(event_info)); |
| 8767 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8768 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8769 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8770 | ASSERT_VK_SUCCESS(err); |
| 8771 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8772 | err = vkResetEvent(device(), event); |
| 8773 | ASSERT_VK_SUCCESS(err); |
| 8774 | |
| 8775 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8776 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8777 | data.event = event; |
| 8778 | data.bailout = false; |
| 8779 | m_errorMonitor->SetBailout(&data.bailout); |
| 8780 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8781 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8782 | // Add many entries to command buffer from this thread at the same time. |
| 8783 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8784 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8785 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8786 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8787 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8788 | m_errorMonitor->SetBailout(NULL); |
| 8789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8790 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8791 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8792 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8793 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8794 | #endif // GTEST_IS_THREADSAFE |
| 8795 | #endif // THREADING_TESTS |
| 8796 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8797 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8798 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8799 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8800 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8801 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8803 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8804 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8805 | VkShaderModule module; |
| 8806 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8807 | struct icd_spv_header spv; |
| 8808 | |
| 8809 | spv.magic = ICD_SPV_MAGIC; |
| 8810 | spv.version = ICD_SPV_VERSION; |
| 8811 | spv.gen_magic = 0; |
| 8812 | |
| 8813 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8814 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8815 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8816 | moduleCreateInfo.codeSize = 4; |
| 8817 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8818 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8819 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8820 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8821 | } |
| 8822 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8823 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8824 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8825 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8826 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8827 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8828 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8829 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8830 | VkShaderModule module; |
| 8831 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8832 | struct icd_spv_header spv; |
| 8833 | |
| 8834 | spv.magic = ~ICD_SPV_MAGIC; |
| 8835 | spv.version = ICD_SPV_VERSION; |
| 8836 | spv.gen_magic = 0; |
| 8837 | |
| 8838 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8839 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8840 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8841 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8842 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8843 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8844 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8845 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8846 | } |
| 8847 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8848 | #if 0 |
| 8849 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8850 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8851 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8852 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8853 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8854 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8855 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8856 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8857 | VkShaderModule module; |
| 8858 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8859 | struct icd_spv_header spv; |
| 8860 | |
| 8861 | spv.magic = ICD_SPV_MAGIC; |
| 8862 | spv.version = ~ICD_SPV_VERSION; |
| 8863 | spv.gen_magic = 0; |
| 8864 | |
| 8865 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8866 | moduleCreateInfo.pNext = NULL; |
| 8867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8868 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8869 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8870 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8871 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8872 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8873 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8874 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8875 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8877 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8879 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8880 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8881 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8882 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8883 | |
| 8884 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8885 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8886 | "\n" |
| 8887 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8888 | "out gl_PerVertex {\n" |
| 8889 | " vec4 gl_Position;\n" |
| 8890 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8891 | "void main(){\n" |
| 8892 | " gl_Position = vec4(1);\n" |
| 8893 | " x = 0;\n" |
| 8894 | "}\n"; |
| 8895 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8896 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8897 | "\n" |
| 8898 | "layout(location=0) out vec4 color;\n" |
| 8899 | "void main(){\n" |
| 8900 | " color = vec4(1);\n" |
| 8901 | "}\n"; |
| 8902 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8903 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8904 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8905 | |
| 8906 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8907 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8908 | pipe.AddShader(&vs); |
| 8909 | pipe.AddShader(&fs); |
| 8910 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8911 | VkDescriptorSetObj descriptorSet(m_device); |
| 8912 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8913 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8914 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8915 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8916 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8917 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8918 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8919 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8920 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8921 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8922 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8923 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8925 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8926 | |
| 8927 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8928 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8929 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8930 | "out gl_PerVertex {\n" |
| 8931 | " vec4 gl_Position;\n" |
| 8932 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8933 | "void main(){\n" |
| 8934 | " gl_Position = vec4(1);\n" |
| 8935 | "}\n"; |
| 8936 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8937 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8938 | "\n" |
| 8939 | "layout(location=0) in float x;\n" |
| 8940 | "layout(location=0) out vec4 color;\n" |
| 8941 | "void main(){\n" |
| 8942 | " color = vec4(x);\n" |
| 8943 | "}\n"; |
| 8944 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8945 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8946 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8947 | |
| 8948 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8949 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8950 | pipe.AddShader(&vs); |
| 8951 | pipe.AddShader(&fs); |
| 8952 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8953 | VkDescriptorSetObj descriptorSet(m_device); |
| 8954 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8955 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8956 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8957 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8958 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8959 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8960 | } |
| 8961 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8962 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8964 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8965 | |
| 8966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8968 | |
| 8969 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8970 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8971 | "\n" |
| 8972 | "out gl_PerVertex {\n" |
| 8973 | " vec4 gl_Position;\n" |
| 8974 | "};\n" |
| 8975 | "void main(){\n" |
| 8976 | " gl_Position = vec4(1);\n" |
| 8977 | "}\n"; |
| 8978 | char const *fsSource = |
| 8979 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8980 | "\n" |
| 8981 | "in block { layout(location=0) float x; } ins;\n" |
| 8982 | "layout(location=0) out vec4 color;\n" |
| 8983 | "void main(){\n" |
| 8984 | " color = vec4(ins.x);\n" |
| 8985 | "}\n"; |
| 8986 | |
| 8987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8989 | |
| 8990 | VkPipelineObj pipe(m_device); |
| 8991 | pipe.AddColorAttachment(); |
| 8992 | pipe.AddShader(&vs); |
| 8993 | pipe.AddShader(&fs); |
| 8994 | |
| 8995 | VkDescriptorSetObj descriptorSet(m_device); |
| 8996 | descriptorSet.AppendDummy(); |
| 8997 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8998 | |
| 8999 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9000 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9001 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9002 | } |
| 9003 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9004 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9006 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9007 | "output arr[2] of float32' vs 'ptr to " |
| 9008 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9009 | |
| 9010 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9011 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9012 | |
| 9013 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9014 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9015 | "\n" |
| 9016 | "layout(location=0) out float x[2];\n" |
| 9017 | "out gl_PerVertex {\n" |
| 9018 | " vec4 gl_Position;\n" |
| 9019 | "};\n" |
| 9020 | "void main(){\n" |
| 9021 | " x[0] = 0; x[1] = 0;\n" |
| 9022 | " gl_Position = vec4(1);\n" |
| 9023 | "}\n"; |
| 9024 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9025 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9026 | "\n" |
| 9027 | "layout(location=0) in float x[3];\n" |
| 9028 | "layout(location=0) out vec4 color;\n" |
| 9029 | "void main(){\n" |
| 9030 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 9031 | "}\n"; |
| 9032 | |
| 9033 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9034 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9035 | |
| 9036 | VkPipelineObj pipe(m_device); |
| 9037 | pipe.AddColorAttachment(); |
| 9038 | pipe.AddShader(&vs); |
| 9039 | pipe.AddShader(&fs); |
| 9040 | |
| 9041 | VkDescriptorSetObj descriptorSet(m_device); |
| 9042 | descriptorSet.AppendDummy(); |
| 9043 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9044 | |
| 9045 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9046 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9047 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9048 | } |
| 9049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9050 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9051 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9052 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9053 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9054 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9055 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9056 | |
| 9057 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9058 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9059 | "\n" |
| 9060 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9061 | "out gl_PerVertex {\n" |
| 9062 | " vec4 gl_Position;\n" |
| 9063 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9064 | "void main(){\n" |
| 9065 | " x = 0;\n" |
| 9066 | " gl_Position = vec4(1);\n" |
| 9067 | "}\n"; |
| 9068 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9069 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9070 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9071 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9072 | "layout(location=0) out vec4 color;\n" |
| 9073 | "void main(){\n" |
| 9074 | " color = vec4(x);\n" |
| 9075 | "}\n"; |
| 9076 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9077 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9078 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9079 | |
| 9080 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9081 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9082 | pipe.AddShader(&vs); |
| 9083 | pipe.AddShader(&fs); |
| 9084 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9085 | VkDescriptorSetObj descriptorSet(m_device); |
| 9086 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9087 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9088 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9089 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9090 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9091 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9092 | } |
| 9093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9094 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9096 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9097 | |
| 9098 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9099 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9100 | |
| 9101 | char const *vsSource = |
| 9102 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9103 | "\n" |
| 9104 | "out block { layout(location=0) int x; } outs;\n" |
| 9105 | "out gl_PerVertex {\n" |
| 9106 | " vec4 gl_Position;\n" |
| 9107 | "};\n" |
| 9108 | "void main(){\n" |
| 9109 | " outs.x = 0;\n" |
| 9110 | " gl_Position = vec4(1);\n" |
| 9111 | "}\n"; |
| 9112 | char const *fsSource = |
| 9113 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9114 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9115 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9116 | "layout(location=0) out vec4 color;\n" |
| 9117 | "void main(){\n" |
| 9118 | " color = vec4(ins.x);\n" |
| 9119 | "}\n"; |
| 9120 | |
| 9121 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9122 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9123 | |
| 9124 | VkPipelineObj pipe(m_device); |
| 9125 | pipe.AddColorAttachment(); |
| 9126 | pipe.AddShader(&vs); |
| 9127 | pipe.AddShader(&fs); |
| 9128 | |
| 9129 | VkDescriptorSetObj descriptorSet(m_device); |
| 9130 | descriptorSet.AppendDummy(); |
| 9131 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9132 | |
| 9133 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9134 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9135 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9136 | } |
| 9137 | |
| 9138 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9139 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9140 | "location 0.0 which is not written by vertex shader"); |
| 9141 | |
| 9142 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9143 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9144 | |
| 9145 | char const *vsSource = |
| 9146 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9147 | "\n" |
| 9148 | "out block { layout(location=1) float x; } outs;\n" |
| 9149 | "out gl_PerVertex {\n" |
| 9150 | " vec4 gl_Position;\n" |
| 9151 | "};\n" |
| 9152 | "void main(){\n" |
| 9153 | " outs.x = 0;\n" |
| 9154 | " gl_Position = vec4(1);\n" |
| 9155 | "}\n"; |
| 9156 | char const *fsSource = |
| 9157 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9158 | "\n" |
| 9159 | "in block { layout(location=0) float x; } ins;\n" |
| 9160 | "layout(location=0) out vec4 color;\n" |
| 9161 | "void main(){\n" |
| 9162 | " color = vec4(ins.x);\n" |
| 9163 | "}\n"; |
| 9164 | |
| 9165 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9166 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9167 | |
| 9168 | VkPipelineObj pipe(m_device); |
| 9169 | pipe.AddColorAttachment(); |
| 9170 | pipe.AddShader(&vs); |
| 9171 | pipe.AddShader(&fs); |
| 9172 | |
| 9173 | VkDescriptorSetObj descriptorSet(m_device); |
| 9174 | descriptorSet.AppendDummy(); |
| 9175 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9176 | |
| 9177 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9178 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9179 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9180 | } |
| 9181 | |
| 9182 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9183 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9184 | "location 0.1 which is not written by vertex shader"); |
| 9185 | |
| 9186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9187 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9188 | |
| 9189 | char const *vsSource = |
| 9190 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9191 | "\n" |
| 9192 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9193 | "out gl_PerVertex {\n" |
| 9194 | " vec4 gl_Position;\n" |
| 9195 | "};\n" |
| 9196 | "void main(){\n" |
| 9197 | " outs.x = 0;\n" |
| 9198 | " gl_Position = vec4(1);\n" |
| 9199 | "}\n"; |
| 9200 | char const *fsSource = |
| 9201 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9202 | "\n" |
| 9203 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9204 | "layout(location=0) out vec4 color;\n" |
| 9205 | "void main(){\n" |
| 9206 | " color = vec4(ins.x);\n" |
| 9207 | "}\n"; |
| 9208 | |
| 9209 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9210 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9211 | |
| 9212 | VkPipelineObj pipe(m_device); |
| 9213 | pipe.AddColorAttachment(); |
| 9214 | pipe.AddShader(&vs); |
| 9215 | pipe.AddShader(&fs); |
| 9216 | |
| 9217 | VkDescriptorSetObj descriptorSet(m_device); |
| 9218 | descriptorSet.AppendDummy(); |
| 9219 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9220 | |
| 9221 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9222 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9223 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9224 | } |
| 9225 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9226 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9227 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9228 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9229 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9231 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9232 | |
| 9233 | VkVertexInputBindingDescription input_binding; |
| 9234 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9235 | |
| 9236 | VkVertexInputAttributeDescription input_attrib; |
| 9237 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9238 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9239 | |
| 9240 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9241 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9242 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9243 | "out gl_PerVertex {\n" |
| 9244 | " vec4 gl_Position;\n" |
| 9245 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9246 | "void main(){\n" |
| 9247 | " gl_Position = vec4(1);\n" |
| 9248 | "}\n"; |
| 9249 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9250 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9251 | "\n" |
| 9252 | "layout(location=0) out vec4 color;\n" |
| 9253 | "void main(){\n" |
| 9254 | " color = vec4(1);\n" |
| 9255 | "}\n"; |
| 9256 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9257 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9258 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9259 | |
| 9260 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9261 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9262 | pipe.AddShader(&vs); |
| 9263 | pipe.AddShader(&fs); |
| 9264 | |
| 9265 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9266 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9267 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9268 | VkDescriptorSetObj descriptorSet(m_device); |
| 9269 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9270 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9271 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9272 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9273 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9274 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9275 | } |
| 9276 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9277 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9278 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9279 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9280 | |
| 9281 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9282 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9283 | |
| 9284 | VkVertexInputBindingDescription input_binding; |
| 9285 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9286 | |
| 9287 | VkVertexInputAttributeDescription input_attrib; |
| 9288 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9289 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9290 | |
| 9291 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9292 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9293 | "\n" |
| 9294 | "layout(location=1) in float x;\n" |
| 9295 | "out gl_PerVertex {\n" |
| 9296 | " vec4 gl_Position;\n" |
| 9297 | "};\n" |
| 9298 | "void main(){\n" |
| 9299 | " gl_Position = vec4(x);\n" |
| 9300 | "}\n"; |
| 9301 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9302 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9303 | "\n" |
| 9304 | "layout(location=0) out vec4 color;\n" |
| 9305 | "void main(){\n" |
| 9306 | " color = vec4(1);\n" |
| 9307 | "}\n"; |
| 9308 | |
| 9309 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9310 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9311 | |
| 9312 | VkPipelineObj pipe(m_device); |
| 9313 | pipe.AddColorAttachment(); |
| 9314 | pipe.AddShader(&vs); |
| 9315 | pipe.AddShader(&fs); |
| 9316 | |
| 9317 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9318 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9319 | |
| 9320 | VkDescriptorSetObj descriptorSet(m_device); |
| 9321 | descriptorSet.AppendDummy(); |
| 9322 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9323 | |
| 9324 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9325 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9326 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9327 | } |
| 9328 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9329 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9330 | m_errorMonitor->SetDesiredFailureMsg( |
| 9331 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9332 | "VS consumes input at location 0 but not provided"); |
| 9333 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9334 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9335 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9336 | |
| 9337 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9338 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9339 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9340 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9341 | "out gl_PerVertex {\n" |
| 9342 | " vec4 gl_Position;\n" |
| 9343 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9344 | "void main(){\n" |
| 9345 | " gl_Position = x;\n" |
| 9346 | "}\n"; |
| 9347 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9348 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9349 | "\n" |
| 9350 | "layout(location=0) out vec4 color;\n" |
| 9351 | "void main(){\n" |
| 9352 | " color = vec4(1);\n" |
| 9353 | "}\n"; |
| 9354 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9355 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9356 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9357 | |
| 9358 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9359 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9360 | pipe.AddShader(&vs); |
| 9361 | pipe.AddShader(&fs); |
| 9362 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9363 | VkDescriptorSetObj descriptorSet(m_device); |
| 9364 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9365 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9366 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9367 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9368 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9369 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9370 | } |
| 9371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9372 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9373 | m_errorMonitor->SetDesiredFailureMsg( |
| 9374 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9375 | "location 0 does not match VS input type"); |
| 9376 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9377 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9378 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9379 | |
| 9380 | VkVertexInputBindingDescription input_binding; |
| 9381 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9382 | |
| 9383 | VkVertexInputAttributeDescription input_attrib; |
| 9384 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9385 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9386 | |
| 9387 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9388 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9389 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9390 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9391 | "out gl_PerVertex {\n" |
| 9392 | " vec4 gl_Position;\n" |
| 9393 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9394 | "void main(){\n" |
| 9395 | " gl_Position = vec4(x);\n" |
| 9396 | "}\n"; |
| 9397 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9398 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9399 | "\n" |
| 9400 | "layout(location=0) out vec4 color;\n" |
| 9401 | "void main(){\n" |
| 9402 | " color = vec4(1);\n" |
| 9403 | "}\n"; |
| 9404 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9405 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9406 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9407 | |
| 9408 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9409 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9410 | pipe.AddShader(&vs); |
| 9411 | pipe.AddShader(&fs); |
| 9412 | |
| 9413 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9414 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9415 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9416 | VkDescriptorSetObj descriptorSet(m_device); |
| 9417 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9418 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9419 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9420 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9422 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9423 | } |
| 9424 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9425 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9426 | m_errorMonitor->SetDesiredFailureMsg( |
| 9427 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9428 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9429 | |
| 9430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9431 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9432 | |
| 9433 | char const *vsSource = |
| 9434 | "#version 450\n" |
| 9435 | "\n" |
| 9436 | "out gl_PerVertex {\n" |
| 9437 | " vec4 gl_Position;\n" |
| 9438 | "};\n" |
| 9439 | "void main(){\n" |
| 9440 | " gl_Position = vec4(1);\n" |
| 9441 | "}\n"; |
| 9442 | char const *fsSource = |
| 9443 | "#version 450\n" |
| 9444 | "\n" |
| 9445 | "layout(location=0) out vec4 color;\n" |
| 9446 | "void main(){\n" |
| 9447 | " color = vec4(1);\n" |
| 9448 | "}\n"; |
| 9449 | |
| 9450 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9451 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9452 | |
| 9453 | VkPipelineObj pipe(m_device); |
| 9454 | pipe.AddColorAttachment(); |
| 9455 | pipe.AddShader(&vs); |
| 9456 | pipe.AddShader(&vs); |
| 9457 | pipe.AddShader(&fs); |
| 9458 | |
| 9459 | VkDescriptorSetObj descriptorSet(m_device); |
| 9460 | descriptorSet.AppendDummy(); |
| 9461 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9462 | |
| 9463 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9464 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9465 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9466 | } |
| 9467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9468 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9469 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9470 | |
| 9471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9472 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9473 | |
| 9474 | VkVertexInputBindingDescription input_binding; |
| 9475 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9476 | |
| 9477 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9478 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9479 | |
| 9480 | for (int i = 0; i < 2; i++) { |
| 9481 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9482 | input_attribs[i].location = i; |
| 9483 | } |
| 9484 | |
| 9485 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9486 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9487 | "\n" |
| 9488 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9489 | "out gl_PerVertex {\n" |
| 9490 | " vec4 gl_Position;\n" |
| 9491 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9492 | "void main(){\n" |
| 9493 | " gl_Position = x[0] + x[1];\n" |
| 9494 | "}\n"; |
| 9495 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9496 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9497 | "\n" |
| 9498 | "layout(location=0) out vec4 color;\n" |
| 9499 | "void main(){\n" |
| 9500 | " color = vec4(1);\n" |
| 9501 | "}\n"; |
| 9502 | |
| 9503 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9504 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9505 | |
| 9506 | VkPipelineObj pipe(m_device); |
| 9507 | pipe.AddColorAttachment(); |
| 9508 | pipe.AddShader(&vs); |
| 9509 | pipe.AddShader(&fs); |
| 9510 | |
| 9511 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9512 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9513 | |
| 9514 | VkDescriptorSetObj descriptorSet(m_device); |
| 9515 | descriptorSet.AppendDummy(); |
| 9516 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9517 | |
| 9518 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9519 | |
| 9520 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9521 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9522 | } |
| 9523 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9524 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9525 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9526 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9527 | |
| 9528 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9529 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9530 | |
| 9531 | VkVertexInputBindingDescription input_binding; |
| 9532 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9533 | |
| 9534 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9535 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9536 | |
| 9537 | for (int i = 0; i < 2; i++) { |
| 9538 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9539 | input_attribs[i].location = i; |
| 9540 | } |
| 9541 | |
| 9542 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9543 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9544 | "\n" |
| 9545 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9546 | "out gl_PerVertex {\n" |
| 9547 | " vec4 gl_Position;\n" |
| 9548 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9549 | "void main(){\n" |
| 9550 | " gl_Position = x[0] + x[1];\n" |
| 9551 | "}\n"; |
| 9552 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9553 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9554 | "\n" |
| 9555 | "layout(location=0) out vec4 color;\n" |
| 9556 | "void main(){\n" |
| 9557 | " color = vec4(1);\n" |
| 9558 | "}\n"; |
| 9559 | |
| 9560 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9561 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9562 | |
| 9563 | VkPipelineObj pipe(m_device); |
| 9564 | pipe.AddColorAttachment(); |
| 9565 | pipe.AddShader(&vs); |
| 9566 | pipe.AddShader(&fs); |
| 9567 | |
| 9568 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9569 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9570 | |
| 9571 | VkDescriptorSetObj descriptorSet(m_device); |
| 9572 | descriptorSet.AppendDummy(); |
| 9573 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9574 | |
| 9575 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9576 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9577 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9578 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9579 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9580 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9581 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9582 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9583 | |
| 9584 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9585 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9586 | |
| 9587 | char const *vsSource = |
| 9588 | "#version 450\n" |
| 9589 | "out gl_PerVertex {\n" |
| 9590 | " vec4 gl_Position;\n" |
| 9591 | "};\n" |
| 9592 | "void main(){\n" |
| 9593 | " gl_Position = vec4(0);\n" |
| 9594 | "}\n"; |
| 9595 | char const *fsSource = |
| 9596 | "#version 450\n" |
| 9597 | "\n" |
| 9598 | "layout(location=0) out vec4 color;\n" |
| 9599 | "void main(){\n" |
| 9600 | " color = vec4(1);\n" |
| 9601 | "}\n"; |
| 9602 | |
| 9603 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9604 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9605 | |
| 9606 | VkPipelineObj pipe(m_device); |
| 9607 | pipe.AddColorAttachment(); |
| 9608 | pipe.AddShader(&vs); |
| 9609 | pipe.AddShader(&fs); |
| 9610 | |
| 9611 | VkDescriptorSetObj descriptorSet(m_device); |
| 9612 | descriptorSet.AppendDummy(); |
| 9613 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9614 | |
| 9615 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9616 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9617 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9618 | } |
| 9619 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9620 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9621 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9622 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9623 | |
| 9624 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9625 | |
| 9626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9628 | |
| 9629 | char const *vsSource = |
| 9630 | "#version 450\n" |
| 9631 | "out gl_PerVertex {\n" |
| 9632 | " vec4 gl_Position;\n" |
| 9633 | "};\n" |
| 9634 | "layout(location=0) out vec3 x;\n" |
| 9635 | "layout(location=1) out ivec3 y;\n" |
| 9636 | "layout(location=2) out vec3 z;\n" |
| 9637 | "void main(){\n" |
| 9638 | " gl_Position = vec4(0);\n" |
| 9639 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9640 | "}\n"; |
| 9641 | char const *fsSource = |
| 9642 | "#version 450\n" |
| 9643 | "\n" |
| 9644 | "layout(location=0) out vec4 color;\n" |
| 9645 | "layout(location=0) in float x;\n" |
| 9646 | "layout(location=1) flat in int y;\n" |
| 9647 | "layout(location=2) in vec2 z;\n" |
| 9648 | "void main(){\n" |
| 9649 | " color = vec4(1 + x + y + z.x);\n" |
| 9650 | "}\n"; |
| 9651 | |
| 9652 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9653 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9654 | |
| 9655 | VkPipelineObj pipe(m_device); |
| 9656 | pipe.AddColorAttachment(); |
| 9657 | pipe.AddShader(&vs); |
| 9658 | pipe.AddShader(&fs); |
| 9659 | |
| 9660 | VkDescriptorSetObj descriptorSet(m_device); |
| 9661 | descriptorSet.AppendDummy(); |
| 9662 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9663 | |
| 9664 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9665 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9666 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9667 | } |
| 9668 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9669 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9670 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9671 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9672 | |
| 9673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9674 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9675 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9676 | if (!m_device->phy().features().tessellationShader) { |
| 9677 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9678 | return; |
| 9679 | } |
| 9680 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9681 | char const *vsSource = |
| 9682 | "#version 450\n" |
| 9683 | "void main(){}\n"; |
| 9684 | char const *tcsSource = |
| 9685 | "#version 450\n" |
| 9686 | "layout(location=0) out int x[];\n" |
| 9687 | "layout(vertices=3) out;\n" |
| 9688 | "void main(){\n" |
| 9689 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9690 | " gl_TessLevelInner[0] = 1;\n" |
| 9691 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9692 | "}\n"; |
| 9693 | char const *tesSource = |
| 9694 | "#version 450\n" |
| 9695 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9696 | "layout(location=0) in int x[];\n" |
| 9697 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9698 | "void main(){\n" |
| 9699 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9700 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9701 | "}\n"; |
| 9702 | char const *fsSource = |
| 9703 | "#version 450\n" |
| 9704 | "layout(location=0) out vec4 color;\n" |
| 9705 | "void main(){\n" |
| 9706 | " color = vec4(1);\n" |
| 9707 | "}\n"; |
| 9708 | |
| 9709 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9710 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9711 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9712 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9713 | |
| 9714 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9715 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9716 | nullptr, |
| 9717 | 0, |
| 9718 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9719 | VK_FALSE}; |
| 9720 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9721 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9722 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9723 | nullptr, |
| 9724 | 0, |
| 9725 | 3}; |
| 9726 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9727 | VkPipelineObj pipe(m_device); |
| 9728 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9729 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9730 | pipe.AddColorAttachment(); |
| 9731 | pipe.AddShader(&vs); |
| 9732 | pipe.AddShader(&tcs); |
| 9733 | pipe.AddShader(&tes); |
| 9734 | pipe.AddShader(&fs); |
| 9735 | |
| 9736 | VkDescriptorSetObj descriptorSet(m_device); |
| 9737 | descriptorSet.AppendDummy(); |
| 9738 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9739 | |
| 9740 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9741 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9742 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9743 | } |
| 9744 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9745 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9746 | { |
| 9747 | m_errorMonitor->ExpectSuccess(); |
| 9748 | |
| 9749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9751 | |
| 9752 | if (!m_device->phy().features().geometryShader) { |
| 9753 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9754 | return; |
| 9755 | } |
| 9756 | |
| 9757 | char const *vsSource = |
| 9758 | "#version 450\n" |
| 9759 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9760 | "void main(){\n" |
| 9761 | " vs_out.x = vec4(1);\n" |
| 9762 | "}\n"; |
| 9763 | char const *gsSource = |
| 9764 | "#version 450\n" |
| 9765 | "layout(triangles) in;\n" |
| 9766 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9767 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9768 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9769 | "void main() {\n" |
| 9770 | " gl_Position = gs_in[0].x;\n" |
| 9771 | " EmitVertex();\n" |
| 9772 | "}\n"; |
| 9773 | char const *fsSource = |
| 9774 | "#version 450\n" |
| 9775 | "layout(location=0) out vec4 color;\n" |
| 9776 | "void main(){\n" |
| 9777 | " color = vec4(1);\n" |
| 9778 | "}\n"; |
| 9779 | |
| 9780 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9781 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9782 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9783 | |
| 9784 | VkPipelineObj pipe(m_device); |
| 9785 | pipe.AddColorAttachment(); |
| 9786 | pipe.AddShader(&vs); |
| 9787 | pipe.AddShader(&gs); |
| 9788 | pipe.AddShader(&fs); |
| 9789 | |
| 9790 | VkDescriptorSetObj descriptorSet(m_device); |
| 9791 | descriptorSet.AppendDummy(); |
| 9792 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9793 | |
| 9794 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9795 | |
| 9796 | m_errorMonitor->VerifyNotFound(); |
| 9797 | } |
| 9798 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9799 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9800 | { |
| 9801 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9802 | "is per-vertex in tessellation control shader stage " |
| 9803 | "but per-patch in tessellation evaluation shader stage"); |
| 9804 | |
| 9805 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9806 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9807 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9808 | if (!m_device->phy().features().tessellationShader) { |
| 9809 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9810 | return; |
| 9811 | } |
| 9812 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9813 | char const *vsSource = |
| 9814 | "#version 450\n" |
| 9815 | "void main(){}\n"; |
| 9816 | char const *tcsSource = |
| 9817 | "#version 450\n" |
| 9818 | "layout(location=0) out int x[];\n" |
| 9819 | "layout(vertices=3) out;\n" |
| 9820 | "void main(){\n" |
| 9821 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9822 | " gl_TessLevelInner[0] = 1;\n" |
| 9823 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9824 | "}\n"; |
| 9825 | char const *tesSource = |
| 9826 | "#version 450\n" |
| 9827 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9828 | "layout(location=0) patch in int x;\n" |
| 9829 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9830 | "void main(){\n" |
| 9831 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9832 | " gl_Position.w = x;\n" |
| 9833 | "}\n"; |
| 9834 | char const *fsSource = |
| 9835 | "#version 450\n" |
| 9836 | "layout(location=0) out vec4 color;\n" |
| 9837 | "void main(){\n" |
| 9838 | " color = vec4(1);\n" |
| 9839 | "}\n"; |
| 9840 | |
| 9841 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9842 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9843 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9844 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9845 | |
| 9846 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9847 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9848 | nullptr, |
| 9849 | 0, |
| 9850 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9851 | VK_FALSE}; |
| 9852 | |
| 9853 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9854 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9855 | nullptr, |
| 9856 | 0, |
| 9857 | 3}; |
| 9858 | |
| 9859 | VkPipelineObj pipe(m_device); |
| 9860 | pipe.SetInputAssembly(&iasci); |
| 9861 | pipe.SetTessellation(&tsci); |
| 9862 | pipe.AddColorAttachment(); |
| 9863 | pipe.AddShader(&vs); |
| 9864 | pipe.AddShader(&tcs); |
| 9865 | pipe.AddShader(&tes); |
| 9866 | pipe.AddShader(&fs); |
| 9867 | |
| 9868 | VkDescriptorSetObj descriptorSet(m_device); |
| 9869 | descriptorSet.AppendDummy(); |
| 9870 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9871 | |
| 9872 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9873 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9874 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9875 | } |
| 9876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9877 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9878 | m_errorMonitor->SetDesiredFailureMsg( |
| 9879 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9880 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9881 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9882 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9883 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9884 | |
| 9885 | /* Two binding descriptions for binding 0 */ |
| 9886 | VkVertexInputBindingDescription input_bindings[2]; |
| 9887 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9888 | |
| 9889 | VkVertexInputAttributeDescription input_attrib; |
| 9890 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9891 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9892 | |
| 9893 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9894 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9895 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9896 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9897 | "out gl_PerVertex {\n" |
| 9898 | " vec4 gl_Position;\n" |
| 9899 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9900 | "void main(){\n" |
| 9901 | " gl_Position = vec4(x);\n" |
| 9902 | "}\n"; |
| 9903 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9904 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9905 | "\n" |
| 9906 | "layout(location=0) out vec4 color;\n" |
| 9907 | "void main(){\n" |
| 9908 | " color = vec4(1);\n" |
| 9909 | "}\n"; |
| 9910 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9911 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9912 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9913 | |
| 9914 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9915 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9916 | pipe.AddShader(&vs); |
| 9917 | pipe.AddShader(&fs); |
| 9918 | |
| 9919 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9920 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9921 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9922 | VkDescriptorSetObj descriptorSet(m_device); |
| 9923 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9924 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9925 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9926 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9927 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9928 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9929 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9930 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9931 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9932 | m_errorMonitor->ExpectSuccess(); |
| 9933 | |
| 9934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9935 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9936 | |
| 9937 | if (!m_device->phy().features().tessellationShader) { |
| 9938 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9939 | return; |
| 9940 | } |
| 9941 | |
| 9942 | VkVertexInputBindingDescription input_bindings[1]; |
| 9943 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9944 | |
| 9945 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9946 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9947 | input_attribs[0].location = 0; |
| 9948 | input_attribs[0].offset = 0; |
| 9949 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9950 | input_attribs[1].location = 2; |
| 9951 | input_attribs[1].offset = 32; |
| 9952 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9953 | input_attribs[2].location = 4; |
| 9954 | input_attribs[2].offset = 64; |
| 9955 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9956 | input_attribs[3].location = 6; |
| 9957 | input_attribs[3].offset = 96; |
| 9958 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9959 | |
| 9960 | char const *vsSource = |
| 9961 | "#version 450\n" |
| 9962 | "\n" |
| 9963 | "layout(location=0) in dmat4 x;\n" |
| 9964 | "out gl_PerVertex {\n" |
| 9965 | " vec4 gl_Position;\n" |
| 9966 | "};\n" |
| 9967 | "void main(){\n" |
| 9968 | " gl_Position = vec4(x[0][0]);\n" |
| 9969 | "}\n"; |
| 9970 | char const *fsSource = |
| 9971 | "#version 450\n" |
| 9972 | "\n" |
| 9973 | "layout(location=0) out vec4 color;\n" |
| 9974 | "void main(){\n" |
| 9975 | " color = vec4(1);\n" |
| 9976 | "}\n"; |
| 9977 | |
| 9978 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9979 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9980 | |
| 9981 | VkPipelineObj pipe(m_device); |
| 9982 | pipe.AddColorAttachment(); |
| 9983 | pipe.AddShader(&vs); |
| 9984 | pipe.AddShader(&fs); |
| 9985 | |
| 9986 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9987 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9988 | |
| 9989 | VkDescriptorSetObj descriptorSet(m_device); |
| 9990 | descriptorSet.AppendDummy(); |
| 9991 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9992 | |
| 9993 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9994 | |
| 9995 | m_errorMonitor->VerifyNotFound(); |
| 9996 | } |
| 9997 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9998 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9999 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10000 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10001 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10002 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10003 | |
| 10004 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10005 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10006 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10007 | "out gl_PerVertex {\n" |
| 10008 | " vec4 gl_Position;\n" |
| 10009 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10010 | "void main(){\n" |
| 10011 | " gl_Position = vec4(1);\n" |
| 10012 | "}\n"; |
| 10013 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10014 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10015 | "\n" |
| 10016 | "void main(){\n" |
| 10017 | "}\n"; |
| 10018 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10019 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10020 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10021 | |
| 10022 | VkPipelineObj pipe(m_device); |
| 10023 | pipe.AddShader(&vs); |
| 10024 | pipe.AddShader(&fs); |
| 10025 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10026 | /* set up CB 0, not written */ |
| 10027 | pipe.AddColorAttachment(); |
| 10028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10029 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10030 | VkDescriptorSetObj descriptorSet(m_device); |
| 10031 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10032 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10033 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10034 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10035 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10036 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10037 | } |
| 10038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10039 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10040 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10041 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10042 | "FS writes to output location 1 with no matching attachment"); |
| 10043 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10044 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10045 | |
| 10046 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10047 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10048 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10049 | "out gl_PerVertex {\n" |
| 10050 | " vec4 gl_Position;\n" |
| 10051 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10052 | "void main(){\n" |
| 10053 | " gl_Position = vec4(1);\n" |
| 10054 | "}\n"; |
| 10055 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10056 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10057 | "\n" |
| 10058 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10059 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10060 | "void main(){\n" |
| 10061 | " x = vec4(1);\n" |
| 10062 | " y = vec4(1);\n" |
| 10063 | "}\n"; |
| 10064 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10065 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10066 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10067 | |
| 10068 | VkPipelineObj pipe(m_device); |
| 10069 | pipe.AddShader(&vs); |
| 10070 | pipe.AddShader(&fs); |
| 10071 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10072 | /* set up CB 0, not written */ |
| 10073 | pipe.AddColorAttachment(); |
| 10074 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10075 | /* FS writes CB 1, but we don't configure it */ |
| 10076 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10077 | VkDescriptorSetObj descriptorSet(m_device); |
| 10078 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10079 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10080 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10081 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10082 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10083 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10084 | } |
| 10085 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10086 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10087 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10088 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10089 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10090 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10091 | |
| 10092 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10093 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10094 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10095 | "out gl_PerVertex {\n" |
| 10096 | " vec4 gl_Position;\n" |
| 10097 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10098 | "void main(){\n" |
| 10099 | " gl_Position = vec4(1);\n" |
| 10100 | "}\n"; |
| 10101 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10102 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10103 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10104 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10105 | "void main(){\n" |
| 10106 | " x = ivec4(1);\n" |
| 10107 | "}\n"; |
| 10108 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10109 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10110 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10111 | |
| 10112 | VkPipelineObj pipe(m_device); |
| 10113 | pipe.AddShader(&vs); |
| 10114 | pipe.AddShader(&fs); |
| 10115 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10116 | /* set up CB 0; type is UNORM by default */ |
| 10117 | pipe.AddColorAttachment(); |
| 10118 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10119 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10120 | VkDescriptorSetObj descriptorSet(m_device); |
| 10121 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10122 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10123 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10124 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10125 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10126 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10127 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10128 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10129 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10130 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10131 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10132 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10134 | |
| 10135 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10136 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10137 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10138 | "out gl_PerVertex {\n" |
| 10139 | " vec4 gl_Position;\n" |
| 10140 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10141 | "void main(){\n" |
| 10142 | " gl_Position = vec4(1);\n" |
| 10143 | "}\n"; |
| 10144 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10145 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10146 | "\n" |
| 10147 | "layout(location=0) out vec4 x;\n" |
| 10148 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10149 | "void main(){\n" |
| 10150 | " x = vec4(bar.y);\n" |
| 10151 | "}\n"; |
| 10152 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10153 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10154 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10155 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10156 | VkPipelineObj pipe(m_device); |
| 10157 | pipe.AddShader(&vs); |
| 10158 | pipe.AddShader(&fs); |
| 10159 | |
| 10160 | /* set up CB 0; type is UNORM by default */ |
| 10161 | pipe.AddColorAttachment(); |
| 10162 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10163 | |
| 10164 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10165 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10166 | |
| 10167 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10168 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10169 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10170 | } |
| 10171 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10172 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10173 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10174 | "not declared in layout"); |
| 10175 | |
| 10176 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10177 | |
| 10178 | char const *vsSource = |
| 10179 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10180 | "\n" |
| 10181 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10182 | "out gl_PerVertex {\n" |
| 10183 | " vec4 gl_Position;\n" |
| 10184 | "};\n" |
| 10185 | "void main(){\n" |
| 10186 | " gl_Position = vec4(consts.x);\n" |
| 10187 | "}\n"; |
| 10188 | char const *fsSource = |
| 10189 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10190 | "\n" |
| 10191 | "layout(location=0) out vec4 x;\n" |
| 10192 | "void main(){\n" |
| 10193 | " x = vec4(1);\n" |
| 10194 | "}\n"; |
| 10195 | |
| 10196 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10197 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10198 | |
| 10199 | VkPipelineObj pipe(m_device); |
| 10200 | pipe.AddShader(&vs); |
| 10201 | pipe.AddShader(&fs); |
| 10202 | |
| 10203 | /* set up CB 0; type is UNORM by default */ |
| 10204 | pipe.AddColorAttachment(); |
| 10205 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10206 | |
| 10207 | VkDescriptorSetObj descriptorSet(m_device); |
| 10208 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10209 | |
| 10210 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10211 | |
| 10212 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10213 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10214 | } |
| 10215 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10216 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10217 | m_errorMonitor->SetDesiredFailureMsg( |
| 10218 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10219 | "Shader uses descriptor slot 0.0"); |
| 10220 | |
| 10221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10222 | |
| 10223 | char const *csSource = |
| 10224 | "#version 450\n" |
| 10225 | "\n" |
| 10226 | "layout(local_size_x=1) in;\n" |
| 10227 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10228 | "void main(){\n" |
| 10229 | " x = vec4(1);\n" |
| 10230 | "}\n"; |
| 10231 | |
| 10232 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10233 | |
| 10234 | VkDescriptorSetObj descriptorSet(m_device); |
| 10235 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10236 | |
| 10237 | VkComputePipelineCreateInfo cpci = { |
| 10238 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10239 | nullptr, 0, { |
| 10240 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10241 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10242 | cs.handle(), "main", nullptr |
| 10243 | }, |
| 10244 | descriptorSet.GetPipelineLayout(), |
| 10245 | VK_NULL_HANDLE, -1 |
| 10246 | }; |
| 10247 | |
| 10248 | VkPipeline pipe; |
| 10249 | VkResult err = vkCreateComputePipelines( |
| 10250 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10251 | |
| 10252 | m_errorMonitor->VerifyFound(); |
| 10253 | |
| 10254 | if (err == VK_SUCCESS) { |
| 10255 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10256 | } |
| 10257 | } |
| 10258 | |
| 10259 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10260 | m_errorMonitor->ExpectSuccess(); |
| 10261 | |
| 10262 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10263 | |
| 10264 | char const *csSource = |
| 10265 | "#version 450\n" |
| 10266 | "\n" |
| 10267 | "layout(local_size_x=1) in;\n" |
| 10268 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10269 | "void main(){\n" |
| 10270 | " // x is not used.\n" |
| 10271 | "}\n"; |
| 10272 | |
| 10273 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10274 | |
| 10275 | VkDescriptorSetObj descriptorSet(m_device); |
| 10276 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10277 | |
| 10278 | VkComputePipelineCreateInfo cpci = { |
| 10279 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10280 | nullptr, 0, { |
| 10281 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10282 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10283 | cs.handle(), "main", nullptr |
| 10284 | }, |
| 10285 | descriptorSet.GetPipelineLayout(), |
| 10286 | VK_NULL_HANDLE, -1 |
| 10287 | }; |
| 10288 | |
| 10289 | VkPipeline pipe; |
| 10290 | VkResult err = vkCreateComputePipelines( |
| 10291 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10292 | |
| 10293 | m_errorMonitor->VerifyNotFound(); |
| 10294 | |
| 10295 | if (err == VK_SUCCESS) { |
| 10296 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10297 | } |
| 10298 | } |
| 10299 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10300 | #endif // SHADER_CHECKER_TESTS |
| 10301 | |
| 10302 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10303 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10304 | m_errorMonitor->SetDesiredFailureMsg( |
| 10305 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10306 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10307 | |
| 10308 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10309 | |
| 10310 | // Create an image |
| 10311 | VkImage image; |
| 10312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10313 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10314 | const int32_t tex_width = 32; |
| 10315 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10316 | |
| 10317 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10318 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10319 | image_create_info.pNext = NULL; |
| 10320 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10321 | image_create_info.format = tex_format; |
| 10322 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10323 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10324 | image_create_info.extent.depth = 1; |
| 10325 | image_create_info.mipLevels = 1; |
| 10326 | image_create_info.arrayLayers = 1; |
| 10327 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10328 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10329 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10330 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10331 | |
| 10332 | // Introduce error by sending down a bogus width extent |
| 10333 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10334 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10335 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10336 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10337 | } |
| 10338 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10339 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10340 | m_errorMonitor->SetDesiredFailureMsg( |
| 10341 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10342 | "CreateImage extents is 0 for at least one required dimension"); |
| 10343 | |
| 10344 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10345 | |
| 10346 | // Create an image |
| 10347 | VkImage image; |
| 10348 | |
| 10349 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10350 | const int32_t tex_width = 32; |
| 10351 | const int32_t tex_height = 32; |
| 10352 | |
| 10353 | VkImageCreateInfo image_create_info = {}; |
| 10354 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10355 | image_create_info.pNext = NULL; |
| 10356 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10357 | image_create_info.format = tex_format; |
| 10358 | image_create_info.extent.width = tex_width; |
| 10359 | image_create_info.extent.height = tex_height; |
| 10360 | image_create_info.extent.depth = 1; |
| 10361 | image_create_info.mipLevels = 1; |
| 10362 | image_create_info.arrayLayers = 1; |
| 10363 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10364 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10365 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10366 | image_create_info.flags = 0; |
| 10367 | |
| 10368 | // Introduce error by sending down a bogus width extent |
| 10369 | image_create_info.extent.width = 0; |
| 10370 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10371 | |
| 10372 | m_errorMonitor->VerifyFound(); |
| 10373 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10374 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10375 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10376 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10377 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10378 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10380 | m_errorMonitor->SetDesiredFailureMsg( |
| 10381 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10382 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10383 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10385 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10386 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10387 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10389 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10390 | const int32_t tex_width = 32; |
| 10391 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10392 | |
| 10393 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10394 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10395 | image_create_info.pNext = NULL; |
| 10396 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10397 | image_create_info.format = tex_format; |
| 10398 | image_create_info.extent.width = tex_width; |
| 10399 | image_create_info.extent.height = tex_height; |
| 10400 | image_create_info.extent.depth = 1; |
| 10401 | image_create_info.mipLevels = 1; |
| 10402 | image_create_info.arrayLayers = 1; |
| 10403 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10404 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10405 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10406 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10407 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10408 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10409 | ASSERT_VK_SUCCESS(err); |
| 10410 | |
| 10411 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10412 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10413 | image_view_create_info.image = image; |
| 10414 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10415 | image_view_create_info.format = tex_format; |
| 10416 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10417 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10418 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10419 | image_view_create_info.subresourceRange.aspectMask = |
| 10420 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10421 | |
| 10422 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10423 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10424 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10425 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10426 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10427 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10428 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10429 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10430 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10431 | TEST_DESCRIPTION( |
| 10432 | "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] | 10433 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10434 | "vkCreateImageView: Color image " |
| 10435 | "formats must have ONLY the " |
| 10436 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10437 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10439 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10440 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10441 | VkImageObj image(m_device); |
| 10442 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10443 | VK_IMAGE_TILING_LINEAR, 0); |
| 10444 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10445 | |
| 10446 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10447 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10448 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10449 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10450 | image_view_create_info.format = tex_format; |
| 10451 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10452 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10453 | // Cause an error by setting an invalid image aspect |
| 10454 | image_view_create_info.subresourceRange.aspectMask = |
| 10455 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10456 | |
| 10457 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10458 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10459 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10460 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10461 | } |
| 10462 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10463 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10464 | VkResult err; |
| 10465 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10467 | m_errorMonitor->SetDesiredFailureMsg( |
| 10468 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10469 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10470 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10472 | |
| 10473 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10474 | VkImage srcImage; |
| 10475 | VkImage dstImage; |
| 10476 | VkDeviceMemory srcMem; |
| 10477 | VkDeviceMemory destMem; |
| 10478 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10479 | |
| 10480 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10481 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10482 | image_create_info.pNext = NULL; |
| 10483 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10484 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10485 | image_create_info.extent.width = 32; |
| 10486 | image_create_info.extent.height = 32; |
| 10487 | image_create_info.extent.depth = 1; |
| 10488 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10489 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10490 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10491 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10492 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10493 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10494 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10495 | err = |
| 10496 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10497 | ASSERT_VK_SUCCESS(err); |
| 10498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10499 | err = |
| 10500 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10501 | ASSERT_VK_SUCCESS(err); |
| 10502 | |
| 10503 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10504 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10505 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10506 | memAlloc.pNext = NULL; |
| 10507 | memAlloc.allocationSize = 0; |
| 10508 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10509 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10510 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10511 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10512 | pass = |
| 10513 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10514 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10515 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10516 | ASSERT_VK_SUCCESS(err); |
| 10517 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10518 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10519 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10520 | pass = |
| 10521 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10522 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10523 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10524 | ASSERT_VK_SUCCESS(err); |
| 10525 | |
| 10526 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10527 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10528 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10529 | ASSERT_VK_SUCCESS(err); |
| 10530 | |
| 10531 | BeginCommandBuffer(); |
| 10532 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10533 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10534 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10535 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10536 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10537 | copyRegion.srcOffset.x = 0; |
| 10538 | copyRegion.srcOffset.y = 0; |
| 10539 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10540 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10541 | copyRegion.dstSubresource.mipLevel = 0; |
| 10542 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10543 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10544 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10545 | copyRegion.dstOffset.x = 0; |
| 10546 | copyRegion.dstOffset.y = 0; |
| 10547 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10548 | copyRegion.extent.width = 1; |
| 10549 | copyRegion.extent.height = 1; |
| 10550 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10551 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10552 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10553 | EndCommandBuffer(); |
| 10554 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10555 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10556 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10557 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10558 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10559 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10560 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10561 | } |
| 10562 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10563 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10564 | |
| 10565 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10566 | |
| 10567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10569 | VkImageObj image(m_device); |
| 10570 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10571 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10572 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10573 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10574 | ASSERT_TRUE(image.initialized()); |
| 10575 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10576 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10577 | VkImageCreateInfo image_create_info; |
| 10578 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10579 | image_create_info.pNext = NULL; |
| 10580 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10581 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10582 | image_create_info.extent.width = 32; |
| 10583 | image_create_info.extent.height = 32; |
| 10584 | image_create_info.extent.depth = 1; |
| 10585 | image_create_info.mipLevels = 1; |
| 10586 | image_create_info.arrayLayers = 1; |
| 10587 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10588 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10589 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10590 | image_create_info.flags = 0; |
| 10591 | |
| 10592 | m_errorMonitor->SetDesiredFailureMsg( |
| 10593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10594 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10595 | |
| 10596 | VkImage localImage; |
| 10597 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10598 | m_errorMonitor->VerifyFound(); |
| 10599 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10600 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10601 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10602 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10603 | VkFormat format = static_cast<VkFormat>(f); |
| 10604 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10605 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10606 | fProps.optimalTilingFeatures == 0) { |
| 10607 | unsupported = format; |
| 10608 | break; |
| 10609 | } |
| 10610 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10611 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10612 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10613 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10614 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10615 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10616 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10617 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10618 | m_errorMonitor->VerifyFound(); |
| 10619 | } |
| 10620 | } |
| 10621 | |
| 10622 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10623 | VkResult ret; |
| 10624 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10625 | |
| 10626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10627 | |
| 10628 | VkImageObj image(m_device); |
| 10629 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10630 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10631 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10632 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10633 | ASSERT_TRUE(image.initialized()); |
| 10634 | |
| 10635 | VkImageView imgView; |
| 10636 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10637 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10638 | imgViewInfo.image = image.handle(); |
| 10639 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10640 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10641 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10642 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10643 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10644 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10645 | |
| 10646 | m_errorMonitor->SetDesiredFailureMsg( |
| 10647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10648 | "vkCreateImageView called with baseMipLevel"); |
| 10649 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10650 | // VIEW_CREATE_ERROR |
| 10651 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10652 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10653 | m_errorMonitor->VerifyFound(); |
| 10654 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10655 | |
| 10656 | m_errorMonitor->SetDesiredFailureMsg( |
| 10657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10658 | "vkCreateImageView called with baseArrayLayer"); |
| 10659 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10660 | // VIEW_CREATE_ERROR |
| 10661 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10662 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10663 | m_errorMonitor->VerifyFound(); |
| 10664 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10665 | |
| 10666 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10667 | "vkCreateImageView called with 0 in " |
| 10668 | "pCreateInfo->subresourceRange." |
| 10669 | "levelCount"); |
| 10670 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10671 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10672 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10673 | m_errorMonitor->VerifyFound(); |
| 10674 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10675 | |
| 10676 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10677 | "vkCreateImageView called with 0 in " |
| 10678 | "pCreateInfo->subresourceRange." |
| 10679 | "layerCount"); |
| 10680 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10681 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10682 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10683 | m_errorMonitor->VerifyFound(); |
| 10684 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10685 | |
| 10686 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10687 | "but both must be color formats"); |
| 10688 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10689 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10690 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10691 | m_errorMonitor->VerifyFound(); |
| 10692 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10693 | |
| 10694 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10695 | "Formats MUST be IDENTICAL unless " |
| 10696 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10697 | "was set on image creation."); |
| 10698 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10699 | // VIEW_CREATE_ERROR |
| 10700 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10701 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10702 | m_errorMonitor->VerifyFound(); |
| 10703 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10704 | |
| 10705 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10706 | "can support ImageViews with " |
| 10707 | "differing formats but they must be " |
| 10708 | "in the same compatibility class."); |
| 10709 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10710 | // VIEW_CREATE_ERROR |
| 10711 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10712 | VkImage mutImage; |
| 10713 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10714 | assert( |
| 10715 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10716 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10717 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10718 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10719 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10720 | ASSERT_VK_SUCCESS(ret); |
| 10721 | imgViewInfo.image = mutImage; |
| 10722 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10723 | m_errorMonitor->VerifyFound(); |
| 10724 | imgViewInfo.image = image.handle(); |
| 10725 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10726 | } |
| 10727 | |
| 10728 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10729 | |
| 10730 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10731 | |
| 10732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10733 | |
| 10734 | VkImageObj image(m_device); |
| 10735 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10736 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10737 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10738 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10739 | ASSERT_TRUE(image.initialized()); |
| 10740 | |
| 10741 | m_errorMonitor->SetDesiredFailureMsg( |
| 10742 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10743 | "number of layers in image subresource is zero"); |
| 10744 | vk_testing::Buffer buffer; |
| 10745 | VkMemoryPropertyFlags reqs = 0; |
| 10746 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10747 | VkBufferImageCopy region = {}; |
| 10748 | region.bufferRowLength = 128; |
| 10749 | region.bufferImageHeight = 128; |
| 10750 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10751 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10752 | region.imageSubresource.layerCount = 0; |
| 10753 | region.imageExtent.height = 4; |
| 10754 | region.imageExtent.width = 4; |
| 10755 | region.imageExtent.depth = 1; |
| 10756 | m_commandBuffer->BeginCommandBuffer(); |
| 10757 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10758 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10759 | 1, ®ion); |
| 10760 | m_errorMonitor->VerifyFound(); |
| 10761 | region.imageSubresource.layerCount = 1; |
| 10762 | |
| 10763 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10764 | "aspectMasks for each region must " |
| 10765 | "specify only COLOR or DEPTH or " |
| 10766 | "STENCIL"); |
| 10767 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10768 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10769 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10770 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10771 | 1, ®ion); |
| 10772 | m_errorMonitor->VerifyFound(); |
| 10773 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10774 | |
| 10775 | m_errorMonitor->SetDesiredFailureMsg( |
| 10776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10777 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10778 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10779 | // Expect INVALID_FILTER |
| 10780 | VkImageObj intImage1(m_device); |
| 10781 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10782 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10783 | 0); |
| 10784 | VkImageObj intImage2(m_device); |
| 10785 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10786 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10787 | 0); |
| 10788 | VkImageBlit blitRegion = {}; |
| 10789 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10790 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10791 | blitRegion.srcSubresource.layerCount = 1; |
| 10792 | blitRegion.srcSubresource.mipLevel = 0; |
| 10793 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10794 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10795 | blitRegion.dstSubresource.layerCount = 1; |
| 10796 | blitRegion.dstSubresource.mipLevel = 0; |
| 10797 | |
| 10798 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10799 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10800 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10801 | m_errorMonitor->VerifyFound(); |
| 10802 | |
| 10803 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10804 | "called with 0 in ppMemoryBarriers"); |
| 10805 | VkImageMemoryBarrier img_barrier; |
| 10806 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10807 | img_barrier.pNext = NULL; |
| 10808 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10809 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10810 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10811 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10812 | img_barrier.image = image.handle(); |
| 10813 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10814 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10815 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10816 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10817 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10818 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10819 | img_barrier.subresourceRange.layerCount = 0; |
| 10820 | img_barrier.subresourceRange.levelCount = 1; |
| 10821 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10822 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10823 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10824 | nullptr, 1, &img_barrier); |
| 10825 | m_errorMonitor->VerifyFound(); |
| 10826 | img_barrier.subresourceRange.layerCount = 1; |
| 10827 | } |
| 10828 | |
| 10829 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10830 | |
| 10831 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10832 | |
| 10833 | m_errorMonitor->SetDesiredFailureMsg( |
| 10834 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10835 | "CreateImage extents exceed allowable limits for format"); |
| 10836 | VkImageCreateInfo image_create_info = {}; |
| 10837 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10838 | image_create_info.pNext = NULL; |
| 10839 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10840 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10841 | image_create_info.extent.width = 32; |
| 10842 | image_create_info.extent.height = 32; |
| 10843 | image_create_info.extent.depth = 1; |
| 10844 | image_create_info.mipLevels = 1; |
| 10845 | image_create_info.arrayLayers = 1; |
| 10846 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10847 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10848 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10849 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10850 | image_create_info.flags = 0; |
| 10851 | |
| 10852 | VkImage nullImg; |
| 10853 | VkImageFormatProperties imgFmtProps; |
| 10854 | vkGetPhysicalDeviceImageFormatProperties( |
| 10855 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10856 | image_create_info.tiling, image_create_info.usage, |
| 10857 | image_create_info.flags, &imgFmtProps); |
| 10858 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10859 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10860 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10861 | m_errorMonitor->VerifyFound(); |
| 10862 | image_create_info.extent.depth = 1; |
| 10863 | |
| 10864 | m_errorMonitor->SetDesiredFailureMsg( |
| 10865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10866 | "exceeds allowable maximum supported by format of"); |
| 10867 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10868 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10869 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10870 | m_errorMonitor->VerifyFound(); |
| 10871 | image_create_info.mipLevels = 1; |
| 10872 | |
| 10873 | m_errorMonitor->SetDesiredFailureMsg( |
| 10874 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10875 | "exceeds allowable maximum supported by format of"); |
| 10876 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10877 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10878 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10879 | m_errorMonitor->VerifyFound(); |
| 10880 | image_create_info.arrayLayers = 1; |
| 10881 | |
| 10882 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10883 | "is not supported by format"); |
| 10884 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10885 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10886 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10887 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10888 | m_errorMonitor->VerifyFound(); |
| 10889 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10890 | |
| 10891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10892 | "pCreateInfo->initialLayout, must be " |
| 10893 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10894 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10895 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10896 | // Expect INVALID_LAYOUT |
| 10897 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10898 | m_errorMonitor->VerifyFound(); |
| 10899 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10900 | } |
| 10901 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10902 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10903 | VkResult err; |
| 10904 | bool pass; |
| 10905 | |
| 10906 | // Create color images with different format sizes and try to copy between them |
| 10907 | m_errorMonitor->SetDesiredFailureMsg( |
| 10908 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10909 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10910 | |
| 10911 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10912 | |
| 10913 | // Create two images of different types and try to copy between them |
| 10914 | VkImage srcImage; |
| 10915 | VkImage dstImage; |
| 10916 | VkDeviceMemory srcMem; |
| 10917 | VkDeviceMemory destMem; |
| 10918 | VkMemoryRequirements memReqs; |
| 10919 | |
| 10920 | VkImageCreateInfo image_create_info = {}; |
| 10921 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10922 | image_create_info.pNext = NULL; |
| 10923 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10924 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10925 | image_create_info.extent.width = 32; |
| 10926 | image_create_info.extent.height = 32; |
| 10927 | image_create_info.extent.depth = 1; |
| 10928 | image_create_info.mipLevels = 1; |
| 10929 | image_create_info.arrayLayers = 1; |
| 10930 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10931 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10932 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10933 | image_create_info.flags = 0; |
| 10934 | |
| 10935 | err = |
| 10936 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10937 | ASSERT_VK_SUCCESS(err); |
| 10938 | |
| 10939 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10940 | // Introduce failure by creating second image with a different-sized format. |
| 10941 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10942 | |
| 10943 | err = |
| 10944 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10945 | ASSERT_VK_SUCCESS(err); |
| 10946 | |
| 10947 | // Allocate memory |
| 10948 | VkMemoryAllocateInfo memAlloc = {}; |
| 10949 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10950 | memAlloc.pNext = NULL; |
| 10951 | memAlloc.allocationSize = 0; |
| 10952 | memAlloc.memoryTypeIndex = 0; |
| 10953 | |
| 10954 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10955 | memAlloc.allocationSize = memReqs.size; |
| 10956 | pass = |
| 10957 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10958 | ASSERT_TRUE(pass); |
| 10959 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10960 | ASSERT_VK_SUCCESS(err); |
| 10961 | |
| 10962 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10963 | memAlloc.allocationSize = memReqs.size; |
| 10964 | pass = |
| 10965 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10966 | ASSERT_TRUE(pass); |
| 10967 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10968 | ASSERT_VK_SUCCESS(err); |
| 10969 | |
| 10970 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10971 | ASSERT_VK_SUCCESS(err); |
| 10972 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10973 | ASSERT_VK_SUCCESS(err); |
| 10974 | |
| 10975 | BeginCommandBuffer(); |
| 10976 | VkImageCopy copyRegion; |
| 10977 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10978 | copyRegion.srcSubresource.mipLevel = 0; |
| 10979 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10980 | copyRegion.srcSubresource.layerCount = 0; |
| 10981 | copyRegion.srcOffset.x = 0; |
| 10982 | copyRegion.srcOffset.y = 0; |
| 10983 | copyRegion.srcOffset.z = 0; |
| 10984 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10985 | copyRegion.dstSubresource.mipLevel = 0; |
| 10986 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10987 | copyRegion.dstSubresource.layerCount = 0; |
| 10988 | copyRegion.dstOffset.x = 0; |
| 10989 | copyRegion.dstOffset.y = 0; |
| 10990 | copyRegion.dstOffset.z = 0; |
| 10991 | copyRegion.extent.width = 1; |
| 10992 | copyRegion.extent.height = 1; |
| 10993 | copyRegion.extent.depth = 1; |
| 10994 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10995 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10996 | EndCommandBuffer(); |
| 10997 | |
| 10998 | m_errorMonitor->VerifyFound(); |
| 10999 | |
| 11000 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 11001 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 11002 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11003 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11004 | } |
| 11005 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11006 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 11007 | VkResult err; |
| 11008 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11009 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11010 | // 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] | 11011 | m_errorMonitor->SetDesiredFailureMsg( |
| 11012 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11013 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11014 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11015 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11016 | |
| 11017 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11018 | VkImage srcImage; |
| 11019 | VkImage dstImage; |
| 11020 | VkDeviceMemory srcMem; |
| 11021 | VkDeviceMemory destMem; |
| 11022 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11023 | |
| 11024 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11025 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11026 | image_create_info.pNext = NULL; |
| 11027 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11028 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11029 | image_create_info.extent.width = 32; |
| 11030 | image_create_info.extent.height = 32; |
| 11031 | image_create_info.extent.depth = 1; |
| 11032 | image_create_info.mipLevels = 1; |
| 11033 | image_create_info.arrayLayers = 1; |
| 11034 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11035 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11036 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11037 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11039 | err = |
| 11040 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11041 | ASSERT_VK_SUCCESS(err); |
| 11042 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11043 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11044 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11045 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11046 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11047 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11048 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11050 | err = |
| 11051 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11052 | ASSERT_VK_SUCCESS(err); |
| 11053 | |
| 11054 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11055 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11056 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11057 | memAlloc.pNext = NULL; |
| 11058 | memAlloc.allocationSize = 0; |
| 11059 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11060 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11061 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11062 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11063 | pass = |
| 11064 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11065 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11066 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11067 | ASSERT_VK_SUCCESS(err); |
| 11068 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11069 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11070 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11071 | pass = |
| 11072 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11073 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11074 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11075 | ASSERT_VK_SUCCESS(err); |
| 11076 | |
| 11077 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11078 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11079 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11080 | ASSERT_VK_SUCCESS(err); |
| 11081 | |
| 11082 | BeginCommandBuffer(); |
| 11083 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11084 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11085 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11086 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11087 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11088 | copyRegion.srcOffset.x = 0; |
| 11089 | copyRegion.srcOffset.y = 0; |
| 11090 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11091 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11092 | copyRegion.dstSubresource.mipLevel = 0; |
| 11093 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11094 | copyRegion.dstSubresource.layerCount = 0; |
| 11095 | copyRegion.dstOffset.x = 0; |
| 11096 | copyRegion.dstOffset.y = 0; |
| 11097 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11098 | copyRegion.extent.width = 1; |
| 11099 | copyRegion.extent.height = 1; |
| 11100 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11101 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11102 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11103 | EndCommandBuffer(); |
| 11104 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11105 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11106 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11107 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11108 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11109 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11110 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11111 | } |
| 11112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11113 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11114 | VkResult err; |
| 11115 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11117 | m_errorMonitor->SetDesiredFailureMsg( |
| 11118 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11119 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11120 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11122 | |
| 11123 | // 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] | 11124 | VkImage srcImage; |
| 11125 | VkImage dstImage; |
| 11126 | VkDeviceMemory srcMem; |
| 11127 | VkDeviceMemory destMem; |
| 11128 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11129 | |
| 11130 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11131 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11132 | image_create_info.pNext = NULL; |
| 11133 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11134 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11135 | image_create_info.extent.width = 32; |
| 11136 | image_create_info.extent.height = 1; |
| 11137 | image_create_info.extent.depth = 1; |
| 11138 | image_create_info.mipLevels = 1; |
| 11139 | image_create_info.arrayLayers = 1; |
| 11140 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11141 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11142 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11143 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11144 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11145 | err = |
| 11146 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11147 | ASSERT_VK_SUCCESS(err); |
| 11148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11149 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11151 | err = |
| 11152 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11153 | ASSERT_VK_SUCCESS(err); |
| 11154 | |
| 11155 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11156 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11157 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11158 | memAlloc.pNext = NULL; |
| 11159 | memAlloc.allocationSize = 0; |
| 11160 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11161 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11162 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11163 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11164 | pass = |
| 11165 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11166 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11167 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11168 | ASSERT_VK_SUCCESS(err); |
| 11169 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11170 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11171 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11172 | pass = |
| 11173 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11174 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11175 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11176 | ASSERT_VK_SUCCESS(err); |
| 11177 | |
| 11178 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11179 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11180 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11181 | ASSERT_VK_SUCCESS(err); |
| 11182 | |
| 11183 | BeginCommandBuffer(); |
| 11184 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11185 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11186 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11187 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11188 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11189 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11190 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11191 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11192 | resolveRegion.srcOffset.x = 0; |
| 11193 | resolveRegion.srcOffset.y = 0; |
| 11194 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11195 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11196 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11197 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11198 | resolveRegion.dstSubresource.layerCount = 0; |
| 11199 | resolveRegion.dstOffset.x = 0; |
| 11200 | resolveRegion.dstOffset.y = 0; |
| 11201 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11202 | resolveRegion.extent.width = 1; |
| 11203 | resolveRegion.extent.height = 1; |
| 11204 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11205 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11206 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11207 | EndCommandBuffer(); |
| 11208 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11209 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11210 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11211 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11212 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11213 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11214 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11215 | } |
| 11216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11217 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11218 | VkResult err; |
| 11219 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11221 | m_errorMonitor->SetDesiredFailureMsg( |
| 11222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11223 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11224 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11226 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11227 | // 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] | 11228 | VkImage srcImage; |
| 11229 | VkImage dstImage; |
| 11230 | VkDeviceMemory srcMem; |
| 11231 | VkDeviceMemory destMem; |
| 11232 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11233 | |
| 11234 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11235 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11236 | image_create_info.pNext = NULL; |
| 11237 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11238 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11239 | image_create_info.extent.width = 32; |
| 11240 | image_create_info.extent.height = 1; |
| 11241 | image_create_info.extent.depth = 1; |
| 11242 | image_create_info.mipLevels = 1; |
| 11243 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11244 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11245 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11246 | // Note: Some implementations expect color attachment usage for any |
| 11247 | // multisample surface |
| 11248 | image_create_info.usage = |
| 11249 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11250 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11252 | err = |
| 11253 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11254 | ASSERT_VK_SUCCESS(err); |
| 11255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11256 | // Note: Some implementations expect color attachment usage for any |
| 11257 | // multisample surface |
| 11258 | image_create_info.usage = |
| 11259 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11260 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11261 | err = |
| 11262 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11263 | ASSERT_VK_SUCCESS(err); |
| 11264 | |
| 11265 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11266 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11267 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11268 | memAlloc.pNext = NULL; |
| 11269 | memAlloc.allocationSize = 0; |
| 11270 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11271 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11272 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11273 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11274 | pass = |
| 11275 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11276 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11277 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11278 | ASSERT_VK_SUCCESS(err); |
| 11279 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11280 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11281 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11282 | pass = |
| 11283 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11284 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11285 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11286 | ASSERT_VK_SUCCESS(err); |
| 11287 | |
| 11288 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11289 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11290 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11291 | ASSERT_VK_SUCCESS(err); |
| 11292 | |
| 11293 | BeginCommandBuffer(); |
| 11294 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11295 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11296 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11297 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11298 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11299 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11300 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11301 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11302 | resolveRegion.srcOffset.x = 0; |
| 11303 | resolveRegion.srcOffset.y = 0; |
| 11304 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11305 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11306 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11307 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11308 | resolveRegion.dstSubresource.layerCount = 0; |
| 11309 | resolveRegion.dstOffset.x = 0; |
| 11310 | resolveRegion.dstOffset.y = 0; |
| 11311 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11312 | resolveRegion.extent.width = 1; |
| 11313 | resolveRegion.extent.height = 1; |
| 11314 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11315 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11316 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11317 | EndCommandBuffer(); |
| 11318 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11319 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11320 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11321 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11322 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11323 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11324 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11325 | } |
| 11326 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11327 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11328 | VkResult err; |
| 11329 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11331 | m_errorMonitor->SetDesiredFailureMsg( |
| 11332 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11333 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11334 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11336 | |
| 11337 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11338 | VkImage srcImage; |
| 11339 | VkImage dstImage; |
| 11340 | VkDeviceMemory srcMem; |
| 11341 | VkDeviceMemory destMem; |
| 11342 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11343 | |
| 11344 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11345 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11346 | image_create_info.pNext = NULL; |
| 11347 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11348 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11349 | image_create_info.extent.width = 32; |
| 11350 | image_create_info.extent.height = 1; |
| 11351 | image_create_info.extent.depth = 1; |
| 11352 | image_create_info.mipLevels = 1; |
| 11353 | image_create_info.arrayLayers = 1; |
| 11354 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11355 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11356 | // Note: Some implementations expect color attachment usage for any |
| 11357 | // multisample surface |
| 11358 | image_create_info.usage = |
| 11359 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11360 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11362 | err = |
| 11363 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11364 | ASSERT_VK_SUCCESS(err); |
| 11365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11366 | // Set format to something other than source image |
| 11367 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11368 | // Note: Some implementations expect color attachment usage for any |
| 11369 | // multisample surface |
| 11370 | image_create_info.usage = |
| 11371 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11372 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11374 | err = |
| 11375 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11376 | ASSERT_VK_SUCCESS(err); |
| 11377 | |
| 11378 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11379 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11380 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11381 | memAlloc.pNext = NULL; |
| 11382 | memAlloc.allocationSize = 0; |
| 11383 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11384 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11385 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11386 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11387 | pass = |
| 11388 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11389 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11390 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11391 | ASSERT_VK_SUCCESS(err); |
| 11392 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11393 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11394 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11395 | pass = |
| 11396 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11397 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11398 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11399 | ASSERT_VK_SUCCESS(err); |
| 11400 | |
| 11401 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11402 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11403 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11404 | ASSERT_VK_SUCCESS(err); |
| 11405 | |
| 11406 | BeginCommandBuffer(); |
| 11407 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11408 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11409 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11410 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11411 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11412 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11413 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11414 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11415 | resolveRegion.srcOffset.x = 0; |
| 11416 | resolveRegion.srcOffset.y = 0; |
| 11417 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11418 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11419 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11420 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11421 | resolveRegion.dstSubresource.layerCount = 0; |
| 11422 | resolveRegion.dstOffset.x = 0; |
| 11423 | resolveRegion.dstOffset.y = 0; |
| 11424 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11425 | resolveRegion.extent.width = 1; |
| 11426 | resolveRegion.extent.height = 1; |
| 11427 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11428 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11429 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11430 | EndCommandBuffer(); |
| 11431 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11432 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11433 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11434 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11435 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11436 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11437 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11438 | } |
| 11439 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11440 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11441 | VkResult err; |
| 11442 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11444 | m_errorMonitor->SetDesiredFailureMsg( |
| 11445 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11446 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11447 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11448 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11449 | |
| 11450 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11451 | VkImage srcImage; |
| 11452 | VkImage dstImage; |
| 11453 | VkDeviceMemory srcMem; |
| 11454 | VkDeviceMemory destMem; |
| 11455 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11456 | |
| 11457 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11458 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11459 | image_create_info.pNext = NULL; |
| 11460 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11461 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11462 | image_create_info.extent.width = 32; |
| 11463 | image_create_info.extent.height = 1; |
| 11464 | image_create_info.extent.depth = 1; |
| 11465 | image_create_info.mipLevels = 1; |
| 11466 | image_create_info.arrayLayers = 1; |
| 11467 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11468 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11469 | // Note: Some implementations expect color attachment usage for any |
| 11470 | // multisample surface |
| 11471 | image_create_info.usage = |
| 11472 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11473 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11474 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11475 | err = |
| 11476 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11477 | ASSERT_VK_SUCCESS(err); |
| 11478 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11479 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11480 | // Note: Some implementations expect color attachment usage for any |
| 11481 | // multisample surface |
| 11482 | image_create_info.usage = |
| 11483 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11484 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11486 | err = |
| 11487 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11488 | ASSERT_VK_SUCCESS(err); |
| 11489 | |
| 11490 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11491 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11492 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11493 | memAlloc.pNext = NULL; |
| 11494 | memAlloc.allocationSize = 0; |
| 11495 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11496 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11497 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11498 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11499 | pass = |
| 11500 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11501 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11502 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11503 | ASSERT_VK_SUCCESS(err); |
| 11504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11505 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11506 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11507 | pass = |
| 11508 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11509 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11510 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11511 | ASSERT_VK_SUCCESS(err); |
| 11512 | |
| 11513 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11514 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11515 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11516 | ASSERT_VK_SUCCESS(err); |
| 11517 | |
| 11518 | BeginCommandBuffer(); |
| 11519 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11520 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11521 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11522 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11523 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11524 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11525 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11526 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11527 | resolveRegion.srcOffset.x = 0; |
| 11528 | resolveRegion.srcOffset.y = 0; |
| 11529 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11530 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11531 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11532 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11533 | resolveRegion.dstSubresource.layerCount = 0; |
| 11534 | resolveRegion.dstOffset.x = 0; |
| 11535 | resolveRegion.dstOffset.y = 0; |
| 11536 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11537 | resolveRegion.extent.width = 1; |
| 11538 | resolveRegion.extent.height = 1; |
| 11539 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11540 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11541 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11542 | EndCommandBuffer(); |
| 11543 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11544 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11545 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11546 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11547 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11548 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11549 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11550 | } |
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 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11553 | // 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] | 11554 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11555 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11556 | // The image format check comes 2nd in validation so we trigger it first, |
| 11557 | // 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] | 11558 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11559 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11560 | m_errorMonitor->SetDesiredFailureMsg( |
| 11561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11562 | "Combination depth/stencil image formats can have only the "); |
| 11563 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11564 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11565 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11566 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11567 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11568 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11569 | |
| 11570 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11571 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11572 | ds_pool_ci.pNext = NULL; |
| 11573 | ds_pool_ci.maxSets = 1; |
| 11574 | ds_pool_ci.poolSizeCount = 1; |
| 11575 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11576 | |
| 11577 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11578 | err = |
| 11579 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11580 | ASSERT_VK_SUCCESS(err); |
| 11581 | |
| 11582 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11583 | dsl_binding.binding = 0; |
| 11584 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11585 | dsl_binding.descriptorCount = 1; |
| 11586 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11587 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11588 | |
| 11589 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11590 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11591 | ds_layout_ci.pNext = NULL; |
| 11592 | ds_layout_ci.bindingCount = 1; |
| 11593 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11594 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11595 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11596 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11597 | ASSERT_VK_SUCCESS(err); |
| 11598 | |
| 11599 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11600 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11601 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11602 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11603 | alloc_info.descriptorPool = ds_pool; |
| 11604 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11605 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11606 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11607 | ASSERT_VK_SUCCESS(err); |
| 11608 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11609 | VkImage image_bad; |
| 11610 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11611 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11612 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11613 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11614 | const int32_t tex_width = 32; |
| 11615 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11616 | |
| 11617 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11618 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11619 | image_create_info.pNext = NULL; |
| 11620 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11621 | image_create_info.format = tex_format_bad; |
| 11622 | image_create_info.extent.width = tex_width; |
| 11623 | image_create_info.extent.height = tex_height; |
| 11624 | image_create_info.extent.depth = 1; |
| 11625 | image_create_info.mipLevels = 1; |
| 11626 | image_create_info.arrayLayers = 1; |
| 11627 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11628 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11629 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11630 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11631 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11633 | err = |
| 11634 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11635 | ASSERT_VK_SUCCESS(err); |
| 11636 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11637 | image_create_info.usage = |
| 11638 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11639 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11640 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11641 | ASSERT_VK_SUCCESS(err); |
| 11642 | |
| 11643 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11644 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11645 | image_view_create_info.image = image_bad; |
| 11646 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11647 | image_view_create_info.format = tex_format_bad; |
| 11648 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11649 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11650 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11651 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11652 | image_view_create_info.subresourceRange.aspectMask = |
| 11653 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11654 | |
| 11655 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11656 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11657 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11658 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11659 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11660 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11661 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11662 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11663 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11664 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11665 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11666 | |
| 11667 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11668 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11669 | "ClearDepthStencilImage with a color image."); |
| 11670 | |
| 11671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11672 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11673 | |
| 11674 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11675 | BeginCommandBuffer(); |
| 11676 | m_commandBuffer->EndRenderPass(); |
| 11677 | |
| 11678 | // Color image |
| 11679 | VkClearColorValue clear_color; |
| 11680 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11681 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11682 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11683 | const int32_t img_width = 32; |
| 11684 | const int32_t img_height = 32; |
| 11685 | VkImageCreateInfo image_create_info = {}; |
| 11686 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11687 | image_create_info.pNext = NULL; |
| 11688 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11689 | image_create_info.format = color_format; |
| 11690 | image_create_info.extent.width = img_width; |
| 11691 | image_create_info.extent.height = img_height; |
| 11692 | image_create_info.extent.depth = 1; |
| 11693 | image_create_info.mipLevels = 1; |
| 11694 | image_create_info.arrayLayers = 1; |
| 11695 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11696 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11697 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11698 | |
| 11699 | vk_testing::Image color_image; |
| 11700 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11701 | reqs); |
| 11702 | |
| 11703 | const VkImageSubresourceRange color_range = |
| 11704 | vk_testing::Image::subresource_range(image_create_info, |
| 11705 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11706 | |
| 11707 | // Depth/Stencil image |
| 11708 | VkClearDepthStencilValue clear_value = {0}; |
| 11709 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11710 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11711 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11712 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11713 | ds_image_create_info.extent.width = 64; |
| 11714 | ds_image_create_info.extent.height = 64; |
| 11715 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11716 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11717 | |
| 11718 | vk_testing::Image ds_image; |
| 11719 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11720 | reqs); |
| 11721 | |
| 11722 | const VkImageSubresourceRange ds_range = |
| 11723 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11724 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11725 | |
| 11726 | m_errorMonitor->SetDesiredFailureMsg( |
| 11727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11728 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11729 | |
| 11730 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11731 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11732 | &color_range); |
| 11733 | |
| 11734 | m_errorMonitor->VerifyFound(); |
| 11735 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 11736 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11737 | "vkCmdClearColorImage called with " |
| 11738 | "image created without " |
| 11739 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 11740 | |
| 11741 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11742 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11743 | &color_range); |
| 11744 | |
| 11745 | m_errorMonitor->VerifyFound(); |
| 11746 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11747 | // Call CmdClearDepthStencilImage with color image |
| 11748 | m_errorMonitor->SetDesiredFailureMsg( |
| 11749 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11750 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11751 | |
| 11752 | vkCmdClearDepthStencilImage( |
| 11753 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11754 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11755 | &ds_range); |
| 11756 | |
| 11757 | m_errorMonitor->VerifyFound(); |
| 11758 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11759 | #endif // IMAGE_TESTS |
| 11760 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11761 | int main(int argc, char **argv) { |
| 11762 | int result; |
| 11763 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11764 | #ifdef ANDROID |
| 11765 | int vulkanSupport = InitVulkan(); |
| 11766 | if (vulkanSupport == 0) |
| 11767 | return 1; |
| 11768 | #endif |
| 11769 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11770 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11771 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11772 | |
| 11773 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11774 | |
| 11775 | result = RUN_ALL_TESTS(); |
| 11776 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11777 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11778 | return result; |
| 11779 | } |