Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 66 | BsoFailCmdClearAttachments = 0x00000200, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 67 | } BsoFailSelect; |
| 68 | |
| 69 | struct vktriangle_vs_uniform { |
| 70 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 71 | float mvp[4][4]; |
| 72 | float position[3][4]; |
| 73 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 74 | }; |
| 75 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 76 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 77 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | "vec2 vertices[3];\n" |
| 79 | "out gl_PerVertex {\n" |
| 80 | " vec4 gl_Position;\n" |
| 81 | "};\n" |
| 82 | "void main() {\n" |
| 83 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 84 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 85 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 86 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 87 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 88 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 89 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 90 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 91 | "\n" |
| 92 | "layout(location = 0) out vec4 uFragColor;\n" |
| 93 | "void main(){\n" |
| 94 | " uFragColor = vec4(0,1,0,1);\n" |
| 95 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 96 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 97 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 98 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 99 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 100 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 102 | // ******************************************************** |
| 103 | // ErrorMonitor Usage: |
| 104 | // |
| 105 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 106 | // encountered log messages. Passing NULL will match all log messages. |
| 107 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 108 | // |
| 109 | // Call DesiredMsgFound to determine if the desired failure message |
| 110 | // was encountered. |
| 111 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 112 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 113 | public: |
| 114 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 115 | test_platform_thread_create_mutex(&m_mutex); |
| 116 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 117 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 118 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 119 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 120 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 121 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 122 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 124 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 125 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 127 | m_failureMsg.clear(); |
| 128 | m_otherMsgs.clear(); |
| 129 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 130 | m_msgFound = VK_FALSE; |
| 131 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 132 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 133 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 134 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 135 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 137 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 138 | if (m_bailout != NULL) { |
| 139 | *m_bailout = true; |
| 140 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 141 | string errorString(msgString); |
| 142 | if (msgFlags & m_msgFlags) { |
| 143 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 144 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 145 | m_otherMsgs.push_back(m_failureMsg); |
| 146 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 148 | m_msgFound = VK_TRUE; |
| 149 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 150 | } else { |
| 151 | m_otherMsgs.push_back(errorString); |
| 152 | } |
| 153 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 154 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 155 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 156 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 158 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 160 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 162 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 166 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 168 | cout << "Other error messages logged for this test were:" << endl; |
| 169 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 170 | cout << " " << *iter << endl; |
| 171 | } |
| 172 | } |
| 173 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 174 | /* helpers */ |
| 175 | |
| 176 | void ExpectSuccess() { |
| 177 | // match anything |
| 178 | SetDesiredFailureMsg(~0u, ""); |
| 179 | } |
| 180 | |
| 181 | void VerifyFound() { |
| 182 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 183 | // any other messages. |
| 184 | if (!DesiredMsgFound()) { |
| 185 | DumpFailureMsgs(); |
| 186 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | void VerifyNotFound() { |
| 191 | // ExpectSuccess() configured us to match anything. Any error is a |
| 192 | // failure. |
| 193 | if (DesiredMsgFound()) { |
| 194 | DumpFailureMsgs(); |
| 195 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 196 | } |
| 197 | } |
| 198 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 199 | private: |
| 200 | VkFlags m_msgFlags; |
| 201 | string m_desiredMsg; |
| 202 | string m_failureMsg; |
| 203 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 204 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 205 | bool *m_bailout; |
| 206 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 207 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 209 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 210 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 211 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 212 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 213 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 214 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 215 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 217 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 218 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 219 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 221 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 222 | class VkLayerTest : public VkRenderFramework { |
| 223 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 224 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 225 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 226 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 227 | BsoFailSelect failMask); |
| 228 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 229 | VkPipelineObj &pipelineobj, |
| 230 | VkDescriptorSetObj &descriptorSet, |
| 231 | BsoFailSelect failMask); |
| 232 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 233 | VkDescriptorSetObj &descriptorSet, |
| 234 | BsoFailSelect failMask) { |
| 235 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 236 | failMask); |
| 237 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 238 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 239 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 240 | VkResult BeginCommandBuffer() { |
| 241 | return BeginCommandBuffer(*m_commandBuffer); |
| 242 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 243 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 244 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 245 | uint32_t firstVertex, uint32_t firstInstance) { |
| 246 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 247 | firstInstance); |
| 248 | } |
| 249 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 250 | uint32_t firstIndex, int32_t vertexOffset, |
| 251 | uint32_t firstInstance) { |
| 252 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 253 | vertexOffset, firstInstance); |
| 254 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 255 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 256 | void QueueCommandBuffer(const VkFence &fence) { |
| 257 | m_commandBuffer->QueueCommandBuffer(fence); |
| 258 | } |
| 259 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 260 | VkDeviceSize offset, uint32_t binding) { |
| 261 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 262 | } |
| 263 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 264 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 265 | } |
| 266 | |
| 267 | protected: |
| 268 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 269 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 270 | |
| 271 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_layer_names; |
| 273 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 274 | std::vector<const char *> instance_extension_names; |
| 275 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 276 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 277 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 278 | /* |
| 279 | * Since CreateDbgMsgCallback is an instance level extension call |
| 280 | * any extension / layer that utilizes that feature also needs |
| 281 | * to be enabled at create instance time. |
| 282 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 283 | // Use Threading layer first to protect others from |
| 284 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 292 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 293 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 299 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 301 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 303 | if (m_enableWSI) { |
| 304 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 305 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 306 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 307 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 308 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 309 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 310 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 311 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 312 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 313 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 314 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 315 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 316 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 317 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 318 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 319 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 320 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 321 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 322 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 323 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 324 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 325 | } |
| 326 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 327 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 328 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 329 | this->app_info.pApplicationName = "layer_tests"; |
| 330 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 331 | this->app_info.pEngineName = "unittest"; |
| 332 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 333 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 334 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 335 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 336 | InitFramework(instance_layer_names, device_layer_names, |
| 337 | instance_extension_names, device_extension_names, |
| 338 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | virtual void TearDown() { |
| 342 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 343 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 344 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 345 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 346 | |
| 347 | VkLayerTest() { |
| 348 | m_enableWSI = false; |
| 349 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 350 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 352 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 353 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 354 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 355 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 356 | |
| 357 | /* |
| 358 | * For render test all drawing happens in a single render pass |
| 359 | * on a single command buffer. |
| 360 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 361 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 362 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | return result; |
| 366 | } |
| 367 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 368 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 369 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 370 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 371 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 372 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 373 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 374 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 375 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 376 | |
| 377 | return result; |
| 378 | } |
| 379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 380 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 381 | const char *fragShaderText, |
| 382 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | // Create identity matrix |
| 384 | int i; |
| 385 | struct vktriangle_vs_uniform data; |
| 386 | |
| 387 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 388 | glm::mat4 View = glm::mat4(1.0f); |
| 389 | glm::mat4 Model = glm::mat4(1.0f); |
| 390 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 392 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 393 | |
| 394 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 396 | static const Vertex tri_data[] = { |
| 397 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 398 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 399 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 400 | }; |
| 401 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 402 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | data.position[i][0] = tri_data[i].posX; |
| 404 | data.position[i][1] = tri_data[i].posY; |
| 405 | data.position[i][2] = tri_data[i].posZ; |
| 406 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 407 | data.color[i][0] = tri_data[i].r; |
| 408 | data.color[i][1] = tri_data[i].g; |
| 409 | data.color[i][2] = tri_data[i].b; |
| 410 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 414 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 415 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 416 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 417 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 419 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 420 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 421 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | |
| 423 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 424 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | pipelineobj.AddShader(&vs); |
| 426 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 427 | if (failMask & BsoFailLineWidth) { |
| 428 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 429 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 430 | ia_state.sType = |
| 431 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 432 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 433 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 434 | } |
| 435 | if (failMask & BsoFailDepthBias) { |
| 436 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 437 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 438 | rs_state.sType = |
| 439 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 440 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 441 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 442 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 443 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 444 | // Viewport and scissors must stay in synch or other errors will occur than |
| 445 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 446 | if (failMask & BsoFailViewport) { |
| 447 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 448 | m_viewports.clear(); |
| 449 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 450 | } |
| 451 | if (failMask & BsoFailScissor) { |
| 452 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 453 | m_scissors.clear(); |
| 454 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 455 | } |
| 456 | if (failMask & BsoFailBlend) { |
| 457 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 458 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 459 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 460 | att_state.blendEnable = VK_TRUE; |
| 461 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 462 | } |
| 463 | if (failMask & BsoFailDepthBounds) { |
| 464 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 465 | } |
| 466 | if (failMask & BsoFailStencilReadMask) { |
| 467 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 468 | } |
| 469 | if (failMask & BsoFailStencilWriteMask) { |
| 470 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 471 | } |
| 472 | if (failMask & BsoFailStencilReference) { |
| 473 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 474 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 475 | |
| 476 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 478 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 479 | |
| 480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 481 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 482 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 483 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 484 | |
| 485 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 486 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 487 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 488 | if (failMask & BsoFailCmdClearAttachments) { |
| 489 | VkClearAttachment color_attachment = {}; |
| 490 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 491 | color_attachment.colorAttachment = 1; // Someone who knew what they were doing would use 0 for the index; |
| 492 | VkClearRect clear_rect = {{{0, 0}, {static_cast<uint32_t>(m_width), static_cast<uint32_t>(m_height)}}, 0, 0}; |
| 493 | |
| 494 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 495 | &color_attachment, 1, &clear_rect); |
| 496 | } |
| 497 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 498 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 499 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 501 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 502 | } |
| 503 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 504 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 505 | VkPipelineObj &pipelineobj, |
| 506 | VkDescriptorSetObj &descriptorSet, |
| 507 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 508 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 509 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 510 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 511 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 512 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 513 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 514 | } |
| 515 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 516 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 517 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 518 | // correctly |
| 519 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 520 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 521 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 522 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 523 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 524 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 525 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 526 | |
| 527 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 528 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 529 | ds_ci.pNext = NULL; |
| 530 | ds_ci.depthTestEnable = VK_FALSE; |
| 531 | ds_ci.depthWriteEnable = VK_TRUE; |
| 532 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 533 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 534 | if (failMask & BsoFailDepthBounds) { |
| 535 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 536 | ds_ci.maxDepthBounds = 0.0f; |
| 537 | ds_ci.minDepthBounds = 0.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 538 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 539 | ds_ci.stencilTestEnable = VK_TRUE; |
| 540 | ds_ci.front = stencil; |
| 541 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 542 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 543 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 544 | pipelineobj.SetViewport(m_viewports); |
| 545 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 546 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 547 | VkResult err = pipelineobj.CreateVKPipeline( |
| 548 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 549 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 550 | commandBuffer->BindPipeline(pipelineobj); |
| 551 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 552 | } |
| 553 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 554 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 555 | public: |
| 556 | protected: |
| 557 | VkWsiEnabledLayerTest() { |
| 558 | m_enableWSI = true; |
| 559 | } |
| 560 | }; |
| 561 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 562 | // ******************************************************************************************************************** |
| 563 | // ******************************************************************************************************************** |
| 564 | // ******************************************************************************************************************** |
| 565 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 566 | #if PARAMETER_VALIDATION_TESTS |
| 567 | TEST_F(VkLayerTest, RequiredParameter) { |
| 568 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 569 | "pointer, array, and array count parameters"); |
| 570 | |
| 571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 572 | |
| 573 | m_errorMonitor->SetDesiredFailureMsg( |
| 574 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 575 | "required parameter pFeatures specified as NULL"); |
| 576 | // Specify NULL for a pointer to a handle |
| 577 | // Expected to trigger an error with |
| 578 | // parameter_validation::validate_required_pointer |
| 579 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 580 | m_errorMonitor->VerifyFound(); |
| 581 | |
| 582 | m_errorMonitor->SetDesiredFailureMsg( |
| 583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 584 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 585 | // Specify NULL for pointer to array count |
| 586 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 587 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 588 | m_errorMonitor->VerifyFound(); |
| 589 | |
| 590 | m_errorMonitor->SetDesiredFailureMsg( |
| 591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 592 | "parameter viewportCount must be greater than 0"); |
| 593 | // Specify 0 for a required array count |
| 594 | // Expected to trigger an error with parameter_validation::validate_array |
| 595 | VkViewport view_port = {}; |
| 596 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 597 | m_errorMonitor->VerifyFound(); |
| 598 | |
| 599 | m_errorMonitor->SetDesiredFailureMsg( |
| 600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 601 | "required parameter pViewports specified as NULL"); |
| 602 | // Specify NULL for a required array |
| 603 | // Expected to trigger an error with parameter_validation::validate_array |
| 604 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 605 | m_errorMonitor->VerifyFound(); |
| 606 | |
| 607 | m_errorMonitor->SetDesiredFailureMsg( |
| 608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 609 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 610 | // Specify VK_NULL_HANDLE for a required handle |
| 611 | // Expected to trigger an error with |
| 612 | // parameter_validation::validate_required_handle |
| 613 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 614 | m_errorMonitor->VerifyFound(); |
| 615 | |
| 616 | m_errorMonitor->SetDesiredFailureMsg( |
| 617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 618 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 619 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 620 | // Expected to trigger an error with |
| 621 | // parameter_validation::validate_required_handle_array |
| 622 | VkFence fence = VK_NULL_HANDLE; |
| 623 | vkResetFences(device(), 1, &fence); |
| 624 | m_errorMonitor->VerifyFound(); |
| 625 | |
| 626 | m_errorMonitor->SetDesiredFailureMsg( |
| 627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 628 | "required parameter pAllocateInfo specified as NULL"); |
| 629 | // Specify NULL for a required struct pointer |
| 630 | // Expected to trigger an error with |
| 631 | // parameter_validation::validate_struct_type |
| 632 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 633 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 634 | m_errorMonitor->VerifyFound(); |
| 635 | |
| 636 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 637 | "value of faceMask must not be 0"); |
| 638 | // Specify 0 for a required VkFlags parameter |
| 639 | // Expected to trigger an error with parameter_validation::validate_flags |
| 640 | m_commandBuffer->SetStencilReference(0, 0); |
| 641 | m_errorMonitor->VerifyFound(); |
| 642 | |
| 643 | m_errorMonitor->SetDesiredFailureMsg( |
| 644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 645 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 646 | // Specify 0 for a required VkFlags array entry |
| 647 | // Expected to trigger an error with |
| 648 | // parameter_validation::validate_flags_array |
| 649 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 650 | VkPipelineStageFlags stageFlags = 0; |
| 651 | VkSubmitInfo submitInfo = {}; |
| 652 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 653 | submitInfo.waitSemaphoreCount = 1; |
| 654 | submitInfo.pWaitSemaphores = &semaphore; |
| 655 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 656 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 657 | m_errorMonitor->VerifyFound(); |
| 658 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 659 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 660 | TEST_F(VkLayerTest, ReservedParameter) { |
| 661 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 662 | |
| 663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 664 | |
| 665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 666 | " must be 0"); |
| 667 | // Specify 0 for a reserved VkFlags parameter |
| 668 | // Expected to trigger an error with |
| 669 | // parameter_validation::validate_reserved_flags |
| 670 | VkEvent event_handle = VK_NULL_HANDLE; |
| 671 | VkEventCreateInfo event_info = {}; |
| 672 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 673 | event_info.flags = 1; |
| 674 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 675 | m_errorMonitor->VerifyFound(); |
| 676 | } |
| 677 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 678 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 679 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 680 | "structure's sType field"); |
| 681 | |
| 682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 683 | |
| 684 | m_errorMonitor->SetDesiredFailureMsg( |
| 685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "parameter pAllocateInfo->sType must be"); |
| 687 | // Zero struct memory, effectively setting sType to |
| 688 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 689 | // Expected to trigger an error with |
| 690 | // parameter_validation::validate_struct_type |
| 691 | VkMemoryAllocateInfo alloc_info = {}; |
| 692 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 693 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 694 | m_errorMonitor->VerifyFound(); |
| 695 | |
| 696 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 697 | "parameter pSubmits[0].sType must be"); |
| 698 | // Zero struct memory, effectively setting sType to |
| 699 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 700 | // Expected to trigger an error with |
| 701 | // parameter_validation::validate_struct_type_array |
| 702 | VkSubmitInfo submit_info = {}; |
| 703 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 704 | m_errorMonitor->VerifyFound(); |
| 705 | } |
| 706 | |
| 707 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 708 | TEST_DESCRIPTION( |
| 709 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 710 | |
| 711 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 712 | |
| 713 | m_errorMonitor->SetDesiredFailureMsg( |
| 714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 715 | "value of pAllocateInfo->pNext must be NULL"); |
| 716 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 717 | // NULL |
| 718 | // Expected to trigger an error with |
| 719 | // parameter_validation::validate_struct_pnext |
| 720 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 721 | // Zero-initialization will provide the correct sType |
| 722 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 723 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 724 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 725 | memory_alloc_info.pNext = &app_info; |
| 726 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 727 | m_errorMonitor->VerifyFound(); |
| 728 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 729 | m_errorMonitor->SetDesiredFailureMsg( |
| 730 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 731 | " chain includes a structure with unexpected VkStructureType "); |
| 732 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 733 | // Expected to trigger an error with |
| 734 | // parameter_validation::validate_struct_pnext |
| 735 | VkDescriptorPoolSize ds_type_count = {}; |
| 736 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 737 | ds_type_count.descriptorCount = 1; |
| 738 | |
| 739 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 740 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 741 | ds_pool_ci.pNext = NULL; |
| 742 | ds_pool_ci.maxSets = 1; |
| 743 | ds_pool_ci.poolSizeCount = 1; |
| 744 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 745 | |
| 746 | VkDescriptorPool ds_pool; |
| 747 | VkResult err = |
| 748 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 749 | ASSERT_VK_SUCCESS(err); |
| 750 | |
| 751 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 752 | dsl_binding.binding = 0; |
| 753 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 754 | dsl_binding.descriptorCount = 1; |
| 755 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 756 | dsl_binding.pImmutableSamplers = NULL; |
| 757 | |
| 758 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 759 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 760 | ds_layout_ci.pNext = NULL; |
| 761 | ds_layout_ci.bindingCount = 1; |
| 762 | ds_layout_ci.pBindings = &dsl_binding; |
| 763 | |
| 764 | VkDescriptorSetLayout ds_layout; |
| 765 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 766 | &ds_layout); |
| 767 | ASSERT_VK_SUCCESS(err); |
| 768 | |
| 769 | VkDescriptorSet descriptorSet; |
| 770 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 771 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 772 | ds_alloc_info.descriptorSetCount = 1; |
| 773 | ds_alloc_info.descriptorPool = ds_pool; |
| 774 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 775 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 776 | &descriptorSet); |
| 777 | ASSERT_VK_SUCCESS(err); |
| 778 | |
| 779 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 780 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 781 | pipeline_layout_ci.setLayoutCount = 1; |
| 782 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 783 | |
| 784 | VkPipelineLayout pipeline_layout; |
| 785 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 786 | &pipeline_layout); |
| 787 | ASSERT_VK_SUCCESS(err); |
| 788 | |
| 789 | VkViewport vp = {}; // Just need dummy vp to point to |
| 790 | VkRect2D sc = {}; // dummy scissor to point to |
| 791 | |
| 792 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 793 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 794 | vp_state_ci.scissorCount = 1; |
| 795 | vp_state_ci.pScissors = ≻ |
| 796 | vp_state_ci.viewportCount = 1; |
| 797 | vp_state_ci.pViewports = &vp; |
| 798 | |
| 799 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 800 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 801 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 802 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 803 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 804 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 805 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 806 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 807 | |
| 808 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 809 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 810 | gp_ci.pViewportState = &vp_state_ci; |
| 811 | gp_ci.pRasterizationState = &rs_state_ci; |
| 812 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 813 | gp_ci.layout = pipeline_layout; |
| 814 | gp_ci.renderPass = renderPass(); |
| 815 | |
| 816 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 817 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 818 | pc_ci.initialDataSize = 0; |
| 819 | pc_ci.pInitialData = 0; |
| 820 | |
| 821 | VkPipeline pipeline; |
| 822 | VkPipelineCache pipelineCache; |
| 823 | |
| 824 | err = |
| 825 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 826 | ASSERT_VK_SUCCESS(err); |
| 827 | |
| 828 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 829 | VkApplicationInfo invalid_pnext_struct = {}; |
| 830 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 831 | |
| 832 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 833 | &gp_ci, NULL, &pipeline); |
| 834 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 835 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 836 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 837 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 838 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 839 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 840 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 841 | |
| 842 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 843 | TEST_DESCRIPTION( |
| 844 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 845 | |
| 846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 847 | |
| 848 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 849 | "does not fall within the begin..end " |
| 850 | "range of the core VkFormat " |
| 851 | "enumeration tokens"); |
| 852 | // Specify an invalid VkFormat value |
| 853 | // Expected to trigger an error with |
| 854 | // parameter_validation::validate_ranged_enum |
| 855 | VkFormatProperties format_properties; |
| 856 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 857 | &format_properties); |
| 858 | m_errorMonitor->VerifyFound(); |
| 859 | |
| 860 | m_errorMonitor->SetDesiredFailureMsg( |
| 861 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 862 | "contains flag bits that are not recognized members of"); |
| 863 | // Specify an invalid VkFlags bitmask value |
| 864 | // Expected to trigger an error with parameter_validation::validate_flags |
| 865 | VkImageFormatProperties image_format_properties; |
| 866 | vkGetPhysicalDeviceImageFormatProperties( |
| 867 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 868 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 869 | &image_format_properties); |
| 870 | m_errorMonitor->VerifyFound(); |
| 871 | |
| 872 | m_errorMonitor->SetDesiredFailureMsg( |
| 873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 874 | "contains flag bits that are not recognized members of"); |
| 875 | // Specify an invalid VkFlags array entry |
| 876 | // Expected to trigger an error with |
| 877 | // parameter_validation::validate_flags_array |
| 878 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 879 | VkPipelineStageFlags stage_flags = |
| 880 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 881 | VkSubmitInfo submit_info = {}; |
| 882 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 883 | submit_info.waitSemaphoreCount = 1; |
| 884 | submit_info.pWaitSemaphores = &semaphore; |
| 885 | submit_info.pWaitDstStageMask = &stage_flags; |
| 886 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 887 | m_errorMonitor->VerifyFound(); |
| 888 | |
| 889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 890 | "is neither VK_TRUE nor VK_FALSE"); |
| 891 | // Specify an invalid VkBool32 value |
| 892 | // Expected to trigger a warning with |
| 893 | // parameter_validation::validate_bool32 |
| 894 | VkSampler sampler = VK_NULL_HANDLE; |
| 895 | VkSamplerCreateInfo sampler_info = {}; |
| 896 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 897 | sampler_info.pNext = NULL; |
| 898 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 899 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 900 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 901 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 902 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 903 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 904 | sampler_info.mipLodBias = 1.0; |
| 905 | sampler_info.maxAnisotropy = 1; |
| 906 | sampler_info.compareEnable = VK_FALSE; |
| 907 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 908 | sampler_info.minLod = 1.0; |
| 909 | sampler_info.maxLod = 1.0; |
| 910 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 911 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 912 | // Not VK_TRUE or VK_FALSE |
| 913 | sampler_info.anisotropyEnable = 3; |
| 914 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 915 | m_errorMonitor->VerifyFound(); |
| 916 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 917 | |
| 918 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 919 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 920 | |
| 921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 922 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 923 | // Find an unsupported image format |
| 924 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 925 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 926 | VkFormat format = static_cast<VkFormat>(f); |
| 927 | VkFormatProperties fProps = m_device->format_properties(format); |
| 928 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 929 | fProps.optimalTilingFeatures == 0) { |
| 930 | unsupported = format; |
| 931 | break; |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 936 | m_errorMonitor->SetDesiredFailureMsg( |
| 937 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 938 | "the requested format is not supported on this device"); |
| 939 | // Specify an unsupported VkFormat value to generate a |
| 940 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 941 | // Expected to trigger a warning from |
| 942 | // parameter_validation::validate_result |
| 943 | VkImageFormatProperties image_format_properties; |
| 944 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 945 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 946 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 947 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 948 | m_errorMonitor->VerifyFound(); |
| 949 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 950 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 951 | |
| 952 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 953 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); |
| 954 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 955 | |
| 956 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 957 | |
| 958 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 959 | vk_testing::Buffer buffer; |
| 960 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 961 | |
| 962 | BeginCommandBuffer(); |
| 963 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 965 | " is not a multiple of 4"); |
| 966 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
| 967 | m_errorMonitor->VerifyFound(); |
| 968 | |
| 969 | // Introduce failure by using dataSize that is not multiple of 4 |
| 970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 971 | " is not a multiple of 4"); |
| 972 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
| 973 | m_errorMonitor->VerifyFound(); |
| 974 | |
| 975 | // Introduce failure by using dataSize that is < 0 |
| 976 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 977 | "must be greater than zero and less than or equal to 65536"); |
| 978 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); |
| 979 | m_errorMonitor->VerifyFound(); |
| 980 | |
| 981 | // Introduce failure by using dataSize that is > 65536 |
| 982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 983 | "must be greater than zero and less than or equal to 65536"); |
| 984 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); |
| 985 | m_errorMonitor->VerifyFound(); |
| 986 | |
| 987 | EndCommandBuffer(); |
| 988 | } |
| 989 | |
| 990 | TEST_F(VkLayerTest, FillBufferAlignment) { |
| 991 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); |
| 992 | |
| 993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 994 | |
| 995 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 996 | vk_testing::Buffer buffer; |
| 997 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 998 | |
| 999 | BeginCommandBuffer(); |
| 1000 | |
| 1001 | // Introduce failure by using dstOffset that is not multiple of 4 |
| 1002 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1003 | " is not a multiple of 4"); |
| 1004 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
| 1005 | m_errorMonitor->VerifyFound(); |
| 1006 | |
| 1007 | // Introduce failure by using size that is not multiple of 4 |
| 1008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1009 | " is not a multiple of 4"); |
| 1010 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
| 1011 | m_errorMonitor->VerifyFound(); |
| 1012 | |
| 1013 | // Introduce failure by using size that is zero |
| 1014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1015 | "must be greater than zero"); |
| 1016 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); |
| 1017 | m_errorMonitor->VerifyFound(); |
| 1018 | |
| 1019 | EndCommandBuffer(); |
| 1020 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1021 | #endif // PARAMETER_VALIDATION_TESTS |
| 1022 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1023 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1024 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1025 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1026 | { |
| 1027 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1028 | VkFenceCreateInfo fenceInfo = {}; |
| 1029 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1030 | fenceInfo.pNext = NULL; |
| 1031 | fenceInfo.flags = 0; |
| 1032 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1033 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1034 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1036 | |
| 1037 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 1038 | vk_testing::Buffer buffer; |
| 1039 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1040 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1041 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1042 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1043 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1044 | |
| 1045 | testFence.init(*m_device, fenceInfo); |
| 1046 | |
| 1047 | // Bypass framework since it does the waits automatically |
| 1048 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1049 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1050 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1051 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1052 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1053 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1054 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1055 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1057 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1058 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1059 | |
| 1060 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1061 | ASSERT_VK_SUCCESS( err ); |
| 1062 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1063 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1064 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1066 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1067 | } |
| 1068 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1069 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1070 | { |
| 1071 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1072 | VkFenceCreateInfo fenceInfo = {}; |
| 1073 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1074 | fenceInfo.pNext = NULL; |
| 1075 | fenceInfo.flags = 0; |
| 1076 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1078 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1080 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1082 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1083 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1084 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1085 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1086 | |
| 1087 | testFence.init(*m_device, fenceInfo); |
| 1088 | |
| 1089 | // Bypass framework since it does the waits automatically |
| 1090 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1091 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1092 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1093 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1094 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1095 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1096 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1097 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1098 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1099 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1100 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1101 | |
| 1102 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1103 | ASSERT_VK_SUCCESS( err ); |
| 1104 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1105 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1106 | VkCommandBufferBeginInfo info = {}; |
| 1107 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1108 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1109 | info.renderPass = VK_NULL_HANDLE; |
| 1110 | info.subpass = 0; |
| 1111 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1112 | info.occlusionQueryEnable = VK_FALSE; |
| 1113 | info.queryFlags = 0; |
| 1114 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1115 | |
| 1116 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1117 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1119 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1120 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1121 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1122 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1123 | // This is a positive test. No failures are expected. |
| 1124 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1125 | VkResult err; |
| 1126 | bool pass; |
| 1127 | |
| 1128 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1129 | "the buffer, create an image, and bind the same memory to " |
| 1130 | "it"); |
| 1131 | |
| 1132 | m_errorMonitor->ExpectSuccess(); |
| 1133 | |
| 1134 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1135 | |
| 1136 | VkBuffer buffer; |
| 1137 | VkImage image; |
| 1138 | VkDeviceMemory mem; |
| 1139 | VkMemoryRequirements mem_reqs; |
| 1140 | |
| 1141 | VkBufferCreateInfo buf_info = {}; |
| 1142 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1143 | buf_info.pNext = NULL; |
| 1144 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1145 | buf_info.size = 256; |
| 1146 | buf_info.queueFamilyIndexCount = 0; |
| 1147 | buf_info.pQueueFamilyIndices = NULL; |
| 1148 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1149 | buf_info.flags = 0; |
| 1150 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1151 | ASSERT_VK_SUCCESS(err); |
| 1152 | |
| 1153 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1154 | |
| 1155 | VkMemoryAllocateInfo alloc_info = {}; |
| 1156 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1157 | alloc_info.pNext = NULL; |
| 1158 | alloc_info.memoryTypeIndex = 0; |
| 1159 | |
| 1160 | // Ensure memory is big enough for both bindings |
| 1161 | alloc_info.allocationSize = 0x10000; |
| 1162 | |
| 1163 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1164 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1165 | if (!pass) { |
| 1166 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1167 | return; |
| 1168 | } |
| 1169 | |
| 1170 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1171 | ASSERT_VK_SUCCESS(err); |
| 1172 | |
| 1173 | uint8_t *pData; |
| 1174 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1175 | (void **)&pData); |
| 1176 | ASSERT_VK_SUCCESS(err); |
| 1177 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1178 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1179 | |
| 1180 | vkUnmapMemory(m_device->device(), mem); |
| 1181 | |
| 1182 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1183 | ASSERT_VK_SUCCESS(err); |
| 1184 | |
| 1185 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1186 | // memory. In fact, it was never used by the GPU. |
| 1187 | // Just be be sure, wait for idle. |
| 1188 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1189 | vkDeviceWaitIdle(m_device->device()); |
| 1190 | |
| 1191 | VkImageCreateInfo image_create_info = {}; |
| 1192 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1193 | image_create_info.pNext = NULL; |
| 1194 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1195 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1196 | image_create_info.extent.width = 64; |
| 1197 | image_create_info.extent.height = 64; |
| 1198 | image_create_info.extent.depth = 1; |
| 1199 | image_create_info.mipLevels = 1; |
| 1200 | image_create_info.arrayLayers = 1; |
| 1201 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1202 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1203 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1204 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1205 | image_create_info.queueFamilyIndexCount = 0; |
| 1206 | image_create_info.pQueueFamilyIndices = NULL; |
| 1207 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1208 | image_create_info.flags = 0; |
| 1209 | |
| 1210 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1211 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1212 | mem_alloc.pNext = NULL; |
| 1213 | mem_alloc.allocationSize = 0; |
| 1214 | mem_alloc.memoryTypeIndex = 0; |
| 1215 | |
| 1216 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1217 | * to be textures or it will be the staging image if they are not. |
| 1218 | */ |
| 1219 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1220 | ASSERT_VK_SUCCESS(err); |
| 1221 | |
| 1222 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1223 | |
| 1224 | mem_alloc.allocationSize = mem_reqs.size; |
| 1225 | |
| 1226 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1227 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1228 | if (!pass) { |
| 1229 | vkDestroyImage(m_device->device(), image, NULL); |
| 1230 | return; |
| 1231 | } |
| 1232 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1233 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1234 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1235 | ASSERT_VK_SUCCESS(err); |
| 1236 | |
| 1237 | m_errorMonitor->VerifyNotFound(); |
| 1238 | |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1239 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1240 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1241 | vkDestroyImage(m_device->device(), image, NULL); |
| 1242 | } |
| 1243 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1244 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1245 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1246 | "buffer and image to memory such that they will alias."); |
| 1247 | VkResult err; |
| 1248 | bool pass; |
| 1249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1250 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1251 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1252 | VkImage image; |
| 1253 | VkDeviceMemory mem; // buffer will be bound first |
| 1254 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1255 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1256 | |
| 1257 | VkBufferCreateInfo buf_info = {}; |
| 1258 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1259 | buf_info.pNext = NULL; |
| 1260 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1261 | buf_info.size = 256; |
| 1262 | buf_info.queueFamilyIndexCount = 0; |
| 1263 | buf_info.pQueueFamilyIndices = NULL; |
| 1264 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1265 | buf_info.flags = 0; |
| 1266 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1267 | ASSERT_VK_SUCCESS(err); |
| 1268 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1269 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1270 | |
| 1271 | VkImageCreateInfo image_create_info = {}; |
| 1272 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1273 | image_create_info.pNext = NULL; |
| 1274 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1275 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1276 | image_create_info.extent.width = 64; |
| 1277 | image_create_info.extent.height = 64; |
| 1278 | image_create_info.extent.depth = 1; |
| 1279 | image_create_info.mipLevels = 1; |
| 1280 | image_create_info.arrayLayers = 1; |
| 1281 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1282 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1283 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1284 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1285 | image_create_info.queueFamilyIndexCount = 0; |
| 1286 | image_create_info.pQueueFamilyIndices = NULL; |
| 1287 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1288 | image_create_info.flags = 0; |
| 1289 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1290 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1291 | ASSERT_VK_SUCCESS(err); |
| 1292 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1293 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1294 | |
| 1295 | VkMemoryAllocateInfo alloc_info = {}; |
| 1296 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1297 | alloc_info.pNext = NULL; |
| 1298 | alloc_info.memoryTypeIndex = 0; |
| 1299 | // Ensure memory is big enough for both bindings |
| 1300 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1301 | pass = m_device->phy().set_memory_type( |
| 1302 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1303 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1304 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1305 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1306 | vkDestroyImage(m_device->device(), image, NULL); |
| 1307 | return; |
| 1308 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1309 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1310 | ASSERT_VK_SUCCESS(err); |
| 1311 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1312 | ASSERT_VK_SUCCESS(err); |
| 1313 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1314 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1315 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1316 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1317 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1318 | m_errorMonitor->VerifyFound(); |
| 1319 | |
| 1320 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1321 | // aliasing buffer2 |
| 1322 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1323 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1324 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1325 | ASSERT_VK_SUCCESS(err); |
| 1326 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1327 | ASSERT_VK_SUCCESS(err); |
| 1328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1329 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1330 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1331 | m_errorMonitor->VerifyFound(); |
| 1332 | |
| 1333 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1334 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1335 | vkDestroyImage(m_device->device(), image, NULL); |
| 1336 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1337 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1338 | } |
| 1339 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1340 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1341 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1342 | VkResult err; |
| 1343 | bool pass; |
| 1344 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1345 | |
| 1346 | VkBuffer buffer; |
| 1347 | VkDeviceMemory mem; |
| 1348 | VkMemoryRequirements mem_reqs; |
| 1349 | |
| 1350 | VkBufferCreateInfo buf_info = {}; |
| 1351 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1352 | buf_info.pNext = NULL; |
| 1353 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1354 | buf_info.size = 256; |
| 1355 | buf_info.queueFamilyIndexCount = 0; |
| 1356 | buf_info.pQueueFamilyIndices = NULL; |
| 1357 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1358 | buf_info.flags = 0; |
| 1359 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1360 | ASSERT_VK_SUCCESS(err); |
| 1361 | |
| 1362 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1363 | VkMemoryAllocateInfo alloc_info = {}; |
| 1364 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1365 | alloc_info.pNext = NULL; |
| 1366 | alloc_info.memoryTypeIndex = 0; |
| 1367 | |
| 1368 | // Ensure memory is big enough for both bindings |
| 1369 | static const VkDeviceSize allocation_size = 0x10000; |
| 1370 | alloc_info.allocationSize = allocation_size; |
| 1371 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1372 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1373 | if (!pass) { |
| 1374 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1375 | return; |
| 1376 | } |
| 1377 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1378 | ASSERT_VK_SUCCESS(err); |
| 1379 | |
| 1380 | uint8_t *pData; |
| 1381 | // Attempt to map memory size 0 is invalid |
| 1382 | m_errorMonitor->SetDesiredFailureMsg( |
| 1383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1384 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1385 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1386 | m_errorMonitor->VerifyFound(); |
| 1387 | // Map memory twice |
| 1388 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1389 | (void **)&pData); |
| 1390 | ASSERT_VK_SUCCESS(err); |
| 1391 | m_errorMonitor->SetDesiredFailureMsg( |
| 1392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1393 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1394 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1395 | (void **)&pData); |
| 1396 | m_errorMonitor->VerifyFound(); |
| 1397 | |
| 1398 | // Unmap the memory to avoid re-map error |
| 1399 | vkUnmapMemory(m_device->device(), mem); |
| 1400 | // overstep allocation with VK_WHOLE_SIZE |
| 1401 | m_errorMonitor->SetDesiredFailureMsg( |
| 1402 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1403 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1404 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1405 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1406 | m_errorMonitor->VerifyFound(); |
| 1407 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1408 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1409 | " oversteps total array size 0x"); |
| 1410 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1411 | (void **)&pData); |
| 1412 | m_errorMonitor->VerifyFound(); |
| 1413 | // Now error due to unmapping memory that's not mapped |
| 1414 | m_errorMonitor->SetDesiredFailureMsg( |
| 1415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1416 | "Unmapping Memory without memory being mapped: "); |
| 1417 | vkUnmapMemory(m_device->device(), mem); |
| 1418 | m_errorMonitor->VerifyFound(); |
| 1419 | // Now map memory and cause errors due to flushing invalid ranges |
| 1420 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1421 | (void **)&pData); |
| 1422 | ASSERT_VK_SUCCESS(err); |
| 1423 | VkMappedMemoryRange mmr = {}; |
| 1424 | mmr.memory = mem; |
| 1425 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1426 | m_errorMonitor->SetDesiredFailureMsg( |
| 1427 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1428 | ") is less than Memory Object's offset ("); |
| 1429 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1430 | m_errorMonitor->VerifyFound(); |
| 1431 | // Now flush range that oversteps mapped range |
| 1432 | vkUnmapMemory(m_device->device(), mem); |
| 1433 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1434 | ASSERT_VK_SUCCESS(err); |
| 1435 | mmr.offset = 16; |
| 1436 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1437 | m_errorMonitor->SetDesiredFailureMsg( |
| 1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1439 | ") exceeds the Memory Object's upper-bound ("); |
| 1440 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1441 | m_errorMonitor->VerifyFound(); |
| 1442 | |
| 1443 | pass = |
| 1444 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1445 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1446 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1447 | if (!pass) { |
| 1448 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1449 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1450 | return; |
| 1451 | } |
| 1452 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1453 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1454 | |
| 1455 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1456 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1457 | } |
| 1458 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1459 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1460 | VkResult err; |
| 1461 | bool pass; |
| 1462 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1463 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1464 | // following declaration (which is temporarily being moved below): |
| 1465 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1466 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1467 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1468 | uint32_t swapchain_image_count = 0; |
| 1469 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1470 | uint32_t image_index = 0; |
| 1471 | // VkPresentInfoKHR present_info = {}; |
| 1472 | |
| 1473 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1474 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1475 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1476 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1477 | // Use the functions from the VK_KHR_android_surface extension without |
| 1478 | // enabling that extension: |
| 1479 | |
| 1480 | // Create a surface: |
| 1481 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1482 | m_errorMonitor->SetDesiredFailureMsg( |
| 1483 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1484 | "extension was not enabled for this"); |
| 1485 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1486 | &surface); |
| 1487 | pass = (err != VK_SUCCESS); |
| 1488 | ASSERT_TRUE(pass); |
| 1489 | m_errorMonitor->VerifyFound(); |
| 1490 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1491 | |
| 1492 | |
| 1493 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1494 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1495 | // that extension: |
| 1496 | |
| 1497 | // Create a surface: |
| 1498 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1499 | m_errorMonitor->SetDesiredFailureMsg( |
| 1500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1501 | "extension was not enabled for this"); |
| 1502 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1503 | pass = (err != VK_SUCCESS); |
| 1504 | ASSERT_TRUE(pass); |
| 1505 | m_errorMonitor->VerifyFound(); |
| 1506 | |
| 1507 | // Tell whether an mir_connection supports presentation: |
| 1508 | MirConnection *mir_connection = NULL; |
| 1509 | m_errorMonitor->SetDesiredFailureMsg( |
| 1510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1511 | "extension was not enabled for this"); |
| 1512 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1513 | visual_id); |
| 1514 | m_errorMonitor->VerifyFound(); |
| 1515 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1516 | |
| 1517 | |
| 1518 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1519 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1520 | // enabling that extension: |
| 1521 | |
| 1522 | // Create a surface: |
| 1523 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1524 | m_errorMonitor->SetDesiredFailureMsg( |
| 1525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1526 | "extension was not enabled for this"); |
| 1527 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1528 | &surface); |
| 1529 | pass = (err != VK_SUCCESS); |
| 1530 | ASSERT_TRUE(pass); |
| 1531 | m_errorMonitor->VerifyFound(); |
| 1532 | |
| 1533 | // Tell whether an wayland_display supports presentation: |
| 1534 | struct wl_display wayland_display = {}; |
| 1535 | m_errorMonitor->SetDesiredFailureMsg( |
| 1536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1537 | "extension was not enabled for this"); |
| 1538 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1539 | &wayland_display); |
| 1540 | m_errorMonitor->VerifyFound(); |
| 1541 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1542 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1543 | |
| 1544 | |
| 1545 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1546 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1547 | // TO NON-LINUX PLATFORMS: |
| 1548 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1549 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1550 | // enabling that extension: |
| 1551 | |
| 1552 | // Create a surface: |
| 1553 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1554 | m_errorMonitor->SetDesiredFailureMsg( |
| 1555 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1556 | "extension was not enabled for this"); |
| 1557 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1558 | &surface); |
| 1559 | pass = (err != VK_SUCCESS); |
| 1560 | ASSERT_TRUE(pass); |
| 1561 | m_errorMonitor->VerifyFound(); |
| 1562 | |
| 1563 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1564 | m_errorMonitor->SetDesiredFailureMsg( |
| 1565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1566 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1567 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1568 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1569 | // Set this (for now, until all platforms are supported and tested): |
| 1570 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1571 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1572 | |
| 1573 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1574 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1575 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1576 | // TO NON-LINUX PLATFORMS: |
| 1577 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1578 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1579 | // that extension: |
| 1580 | |
| 1581 | // Create a surface: |
| 1582 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1583 | m_errorMonitor->SetDesiredFailureMsg( |
| 1584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1585 | "extension was not enabled for this"); |
| 1586 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1587 | pass = (err != VK_SUCCESS); |
| 1588 | ASSERT_TRUE(pass); |
| 1589 | m_errorMonitor->VerifyFound(); |
| 1590 | |
| 1591 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1592 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1593 | xcb_visualid_t visual_id = 0; |
| 1594 | m_errorMonitor->SetDesiredFailureMsg( |
| 1595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1596 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1597 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1598 | visual_id); |
| 1599 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1600 | // Set this (for now, until all platforms are supported and tested): |
| 1601 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1602 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1603 | |
| 1604 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1605 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1606 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1607 | // that extension: |
| 1608 | |
| 1609 | // Create a surface: |
| 1610 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1611 | m_errorMonitor->SetDesiredFailureMsg( |
| 1612 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1613 | "extension was not enabled for this"); |
| 1614 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1615 | pass = (err != VK_SUCCESS); |
| 1616 | ASSERT_TRUE(pass); |
| 1617 | m_errorMonitor->VerifyFound(); |
| 1618 | |
| 1619 | // Tell whether an Xlib VisualID supports presentation: |
| 1620 | Display *dpy = NULL; |
| 1621 | VisualID visual = 0; |
| 1622 | m_errorMonitor->SetDesiredFailureMsg( |
| 1623 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1624 | "extension was not enabled for this"); |
| 1625 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1626 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1627 | // Set this (for now, until all platforms are supported and tested): |
| 1628 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1629 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1630 | |
| 1631 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1632 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1633 | // that extension: |
| 1634 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1635 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1636 | // Destroy a surface: |
| 1637 | m_errorMonitor->SetDesiredFailureMsg( |
| 1638 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1639 | "extension was not enabled for this"); |
| 1640 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1641 | m_errorMonitor->VerifyFound(); |
| 1642 | |
| 1643 | // Check if surface supports presentation: |
| 1644 | VkBool32 supported = false; |
| 1645 | m_errorMonitor->SetDesiredFailureMsg( |
| 1646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1647 | "extension was not enabled for this"); |
| 1648 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1649 | pass = (err != VK_SUCCESS); |
| 1650 | ASSERT_TRUE(pass); |
| 1651 | m_errorMonitor->VerifyFound(); |
| 1652 | |
| 1653 | // Check surface capabilities: |
| 1654 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1655 | m_errorMonitor->SetDesiredFailureMsg( |
| 1656 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1657 | "extension was not enabled for this"); |
| 1658 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1659 | &capabilities); |
| 1660 | pass = (err != VK_SUCCESS); |
| 1661 | ASSERT_TRUE(pass); |
| 1662 | m_errorMonitor->VerifyFound(); |
| 1663 | |
| 1664 | // Check surface formats: |
| 1665 | uint32_t format_count = 0; |
| 1666 | VkSurfaceFormatKHR *formats = NULL; |
| 1667 | m_errorMonitor->SetDesiredFailureMsg( |
| 1668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1669 | "extension was not enabled for this"); |
| 1670 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1671 | &format_count, formats); |
| 1672 | pass = (err != VK_SUCCESS); |
| 1673 | ASSERT_TRUE(pass); |
| 1674 | m_errorMonitor->VerifyFound(); |
| 1675 | |
| 1676 | // Check surface present modes: |
| 1677 | uint32_t present_mode_count = 0; |
| 1678 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1679 | m_errorMonitor->SetDesiredFailureMsg( |
| 1680 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1681 | "extension was not enabled for this"); |
| 1682 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1683 | &present_mode_count, present_modes); |
| 1684 | pass = (err != VK_SUCCESS); |
| 1685 | ASSERT_TRUE(pass); |
| 1686 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1687 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1688 | |
| 1689 | |
| 1690 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1691 | // that extension: |
| 1692 | |
| 1693 | // Create a swapchain: |
| 1694 | m_errorMonitor->SetDesiredFailureMsg( |
| 1695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1696 | "extension was not enabled for this"); |
| 1697 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1698 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1699 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1700 | NULL, &swapchain); |
| 1701 | pass = (err != VK_SUCCESS); |
| 1702 | ASSERT_TRUE(pass); |
| 1703 | m_errorMonitor->VerifyFound(); |
| 1704 | |
| 1705 | // Get the images from the swapchain: |
| 1706 | m_errorMonitor->SetDesiredFailureMsg( |
| 1707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1708 | "extension was not enabled for this"); |
| 1709 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1710 | &swapchain_image_count, NULL); |
| 1711 | pass = (err != VK_SUCCESS); |
| 1712 | ASSERT_TRUE(pass); |
| 1713 | m_errorMonitor->VerifyFound(); |
| 1714 | |
| 1715 | // Try to acquire an image: |
| 1716 | m_errorMonitor->SetDesiredFailureMsg( |
| 1717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1718 | "extension was not enabled for this"); |
| 1719 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1720 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1721 | pass = (err != VK_SUCCESS); |
| 1722 | ASSERT_TRUE(pass); |
| 1723 | m_errorMonitor->VerifyFound(); |
| 1724 | |
| 1725 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1726 | // |
| 1727 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1728 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1729 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1730 | |
| 1731 | // Destroy the swapchain: |
| 1732 | m_errorMonitor->SetDesiredFailureMsg( |
| 1733 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1734 | "extension was not enabled for this"); |
| 1735 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1736 | m_errorMonitor->VerifyFound(); |
| 1737 | } |
| 1738 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1739 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1740 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1741 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1742 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1743 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1744 | VkResult err; |
| 1745 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1746 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1747 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1748 | // uint32_t swapchain_image_count = 0; |
| 1749 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1750 | // uint32_t image_index = 0; |
| 1751 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1752 | |
| 1753 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1754 | |
| 1755 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1756 | // order to create a surface, testing all known errors in the process, |
| 1757 | // before successfully creating a surface: |
| 1758 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
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 NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1761 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1762 | pass = (err != VK_SUCCESS); |
| 1763 | ASSERT_TRUE(pass); |
| 1764 | m_errorMonitor->VerifyFound(); |
| 1765 | |
| 1766 | // Next, try to create a surface with the wrong |
| 1767 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1768 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1769 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1770 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1771 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1772 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1773 | pass = (err != VK_SUCCESS); |
| 1774 | ASSERT_TRUE(pass); |
| 1775 | m_errorMonitor->VerifyFound(); |
| 1776 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1777 | // Create a native window, and then correctly create a surface: |
| 1778 | xcb_connection_t *connection; |
| 1779 | xcb_screen_t *screen; |
| 1780 | xcb_window_t xcb_window; |
| 1781 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1782 | |
| 1783 | const xcb_setup_t *setup; |
| 1784 | xcb_screen_iterator_t iter; |
| 1785 | int scr; |
| 1786 | uint32_t value_mask, value_list[32]; |
| 1787 | int width = 1; |
| 1788 | int height = 1; |
| 1789 | |
| 1790 | connection = xcb_connect(NULL, &scr); |
| 1791 | ASSERT_TRUE(connection != NULL); |
| 1792 | setup = xcb_get_setup(connection); |
| 1793 | iter = xcb_setup_roots_iterator(setup); |
| 1794 | while (scr-- > 0) |
| 1795 | xcb_screen_next(&iter); |
| 1796 | screen = iter.data; |
| 1797 | |
| 1798 | xcb_window = xcb_generate_id(connection); |
| 1799 | |
| 1800 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1801 | value_list[0] = screen->black_pixel; |
| 1802 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1803 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1804 | |
| 1805 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1806 | screen->root, 0, 0, width, height, 0, |
| 1807 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1808 | value_mask, value_list); |
| 1809 | |
| 1810 | /* Magic code that will send notification when window is destroyed */ |
| 1811 | xcb_intern_atom_cookie_t cookie = |
| 1812 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1813 | xcb_intern_atom_reply_t *reply = |
| 1814 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1815 | |
| 1816 | xcb_intern_atom_cookie_t cookie2 = |
| 1817 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1818 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1819 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1820 | (*reply).atom, 4, 32, 1, |
| 1821 | &(*atom_wm_delete_window).atom); |
| 1822 | free(reply); |
| 1823 | |
| 1824 | xcb_map_window(connection, xcb_window); |
| 1825 | |
| 1826 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1827 | // runs |
| 1828 | const uint32_t coords[] = {100, 100}; |
| 1829 | xcb_configure_window(connection, xcb_window, |
| 1830 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1831 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1832 | // Finally, try to correctly create a surface: |
| 1833 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1834 | xcb_create_info.pNext = NULL; |
| 1835 | xcb_create_info.flags = 0; |
| 1836 | xcb_create_info.connection = connection; |
| 1837 | xcb_create_info.window = xcb_window; |
| 1838 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1839 | pass = (err == VK_SUCCESS); |
| 1840 | ASSERT_TRUE(pass); |
| 1841 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1842 | // Check if surface supports presentation: |
| 1843 | |
| 1844 | // 1st, do so without having queried the queue families: |
| 1845 | VkBool32 supported = false; |
| 1846 | // TODO: Get the following error to come out: |
| 1847 | m_errorMonitor->SetDesiredFailureMsg( |
| 1848 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1849 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1850 | "function"); |
| 1851 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1852 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1853 | // ASSERT_TRUE(pass); |
| 1854 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1855 | |
| 1856 | // Next, query a queue family index that's too large: |
| 1857 | m_errorMonitor->SetDesiredFailureMsg( |
| 1858 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1859 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1860 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1861 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1862 | pass = (err != VK_SUCCESS); |
| 1863 | ASSERT_TRUE(pass); |
| 1864 | m_errorMonitor->VerifyFound(); |
| 1865 | |
| 1866 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1867 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1868 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1869 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1870 | pass = (err == VK_SUCCESS); |
| 1871 | ASSERT_TRUE(pass); |
| 1872 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1873 | // Before proceeding, try to create a swapchain without having called |
| 1874 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1875 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1876 | swapchain_create_info.pNext = NULL; |
| 1877 | swapchain_create_info.flags = 0; |
| 1878 | m_errorMonitor->SetDesiredFailureMsg( |
| 1879 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1880 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1881 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1882 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1883 | pass = (err != VK_SUCCESS); |
| 1884 | ASSERT_TRUE(pass); |
| 1885 | m_errorMonitor->VerifyFound(); |
| 1886 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1887 | // Get the surface capabilities: |
| 1888 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1889 | |
| 1890 | // Do so correctly (only error logged by this entrypoint is if the |
| 1891 | // extension isn't enabled): |
| 1892 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1893 | &surface_capabilities); |
| 1894 | pass = (err == VK_SUCCESS); |
| 1895 | ASSERT_TRUE(pass); |
| 1896 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1897 | // Get the surface formats: |
| 1898 | uint32_t surface_format_count; |
| 1899 | |
| 1900 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1901 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1902 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1903 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1904 | pass = (err == VK_SUCCESS); |
| 1905 | ASSERT_TRUE(pass); |
| 1906 | m_errorMonitor->VerifyFound(); |
| 1907 | |
| 1908 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1909 | // correctly done a 1st try (to get the count): |
| 1910 | m_errorMonitor->SetDesiredFailureMsg( |
| 1911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1912 | "but no prior positive value has been seen for"); |
| 1913 | surface_format_count = 0; |
| 1914 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1915 | gpu(), surface, &surface_format_count, |
| 1916 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1917 | pass = (err == VK_SUCCESS); |
| 1918 | ASSERT_TRUE(pass); |
| 1919 | m_errorMonitor->VerifyFound(); |
| 1920 | |
| 1921 | // 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] | 1922 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1923 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1924 | pass = (err == VK_SUCCESS); |
| 1925 | ASSERT_TRUE(pass); |
| 1926 | |
| 1927 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1928 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1929 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1930 | |
| 1931 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1932 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1933 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1934 | "that is greater than the value"); |
| 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 | m_errorMonitor->VerifyFound(); |
| 1940 | |
| 1941 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1942 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1943 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1944 | pass = (err == VK_SUCCESS); |
| 1945 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1946 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1947 | surface_formats); |
| 1948 | pass = (err == VK_SUCCESS); |
| 1949 | ASSERT_TRUE(pass); |
| 1950 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1951 | // Get the surface present modes: |
| 1952 | uint32_t surface_present_mode_count; |
| 1953 | |
| 1954 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1955 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1956 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1957 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1958 | pass = (err == VK_SUCCESS); |
| 1959 | ASSERT_TRUE(pass); |
| 1960 | m_errorMonitor->VerifyFound(); |
| 1961 | |
| 1962 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1963 | // correctly done a 1st try (to get the count): |
| 1964 | m_errorMonitor->SetDesiredFailureMsg( |
| 1965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1966 | "but no prior positive value has been seen for"); |
| 1967 | surface_present_mode_count = 0; |
| 1968 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1969 | gpu(), surface, &surface_present_mode_count, |
| 1970 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1971 | pass = (err == VK_SUCCESS); |
| 1972 | ASSERT_TRUE(pass); |
| 1973 | m_errorMonitor->VerifyFound(); |
| 1974 | |
| 1975 | // 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] | 1976 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1977 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1978 | pass = (err == VK_SUCCESS); |
| 1979 | ASSERT_TRUE(pass); |
| 1980 | |
| 1981 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1982 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1983 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1984 | |
| 1985 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1986 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1987 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1988 | "that is greater than the value"); |
| 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 | m_errorMonitor->VerifyFound(); |
| 1994 | |
| 1995 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1996 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1997 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1998 | pass = (err == VK_SUCCESS); |
| 1999 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2000 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 2001 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2002 | pass = (err == VK_SUCCESS); |
| 2003 | ASSERT_TRUE(pass); |
| 2004 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2005 | // Create a swapchain: |
| 2006 | |
| 2007 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2009 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2010 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 2011 | pass = (err != VK_SUCCESS); |
| 2012 | ASSERT_TRUE(pass); |
| 2013 | m_errorMonitor->VerifyFound(); |
| 2014 | |
| 2015 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 2016 | // sType: |
| 2017 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2018 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2019 | "called with the wrong value for"); |
| 2020 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2021 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2022 | pass = (err != VK_SUCCESS); |
| 2023 | ASSERT_TRUE(pass); |
| 2024 | m_errorMonitor->VerifyFound(); |
| 2025 | |
| 2026 | // Next, call with a NULL swapchain pointer: |
| 2027 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 2028 | swapchain_create_info.pNext = NULL; |
| 2029 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2030 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2031 | "called with NULL pointer"); |
| 2032 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2033 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2034 | pass = (err != VK_SUCCESS); |
| 2035 | ASSERT_TRUE(pass); |
| 2036 | m_errorMonitor->VerifyFound(); |
| 2037 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2038 | // TODO: Enhance swapchain layer so that |
| 2039 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2040 | |
| 2041 | // Next, call with a queue family index that's too large: |
| 2042 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 2043 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2044 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 2045 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 2046 | m_errorMonitor->SetDesiredFailureMsg( |
| 2047 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2048 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2049 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2050 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2051 | pass = (err != VK_SUCCESS); |
| 2052 | ASSERT_TRUE(pass); |
| 2053 | m_errorMonitor->VerifyFound(); |
| 2054 | |
| 2055 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 2056 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2057 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2058 | m_errorMonitor->SetDesiredFailureMsg( |
| 2059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2060 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 2061 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2062 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2063 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2064 | pass = (err != VK_SUCCESS); |
| 2065 | ASSERT_TRUE(pass); |
| 2066 | m_errorMonitor->VerifyFound(); |
| 2067 | |
| 2068 | // Next, call with an invalid imageSharingMode: |
| 2069 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 2070 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2071 | m_errorMonitor->SetDesiredFailureMsg( |
| 2072 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2073 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2074 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 2075 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2076 | pass = (err != VK_SUCCESS); |
| 2077 | ASSERT_TRUE(pass); |
| 2078 | m_errorMonitor->VerifyFound(); |
| 2079 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2080 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 2081 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2082 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2083 | queueFamilyIndex[0] = 0; |
| 2084 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2085 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2086 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2087 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2088 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2089 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2090 | // Destroy the swapchain: |
| 2091 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2092 | // TODOs: |
| 2093 | // |
| 2094 | // - Try destroying the device without first destroying the swapchain |
| 2095 | // |
| 2096 | // - Try destroying the device without first destroying the surface |
| 2097 | // |
| 2098 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2099 | |
| 2100 | // Destroy the surface: |
| 2101 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2102 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2103 | // Tear down the window: |
| 2104 | xcb_destroy_window(connection, xcb_window); |
| 2105 | xcb_disconnect(connection); |
| 2106 | |
| 2107 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2108 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2109 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2110 | } |
| 2111 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2112 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2113 | VkResult err; |
| 2114 | bool pass; |
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 | m_errorMonitor->SetDesiredFailureMsg( |
| 2117 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2118 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2119 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2121 | |
| 2122 | // 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] | 2123 | VkImage image; |
| 2124 | VkDeviceMemory mem; |
| 2125 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2127 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2128 | const int32_t tex_width = 32; |
| 2129 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2130 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2131 | VkImageCreateInfo image_create_info = {}; |
| 2132 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2133 | image_create_info.pNext = NULL; |
| 2134 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2135 | image_create_info.format = tex_format; |
| 2136 | image_create_info.extent.width = tex_width; |
| 2137 | image_create_info.extent.height = tex_height; |
| 2138 | image_create_info.extent.depth = 1; |
| 2139 | image_create_info.mipLevels = 1; |
| 2140 | image_create_info.arrayLayers = 1; |
| 2141 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2142 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2143 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2144 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2145 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2146 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2147 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2148 | mem_alloc.pNext = NULL; |
| 2149 | mem_alloc.allocationSize = 0; |
| 2150 | // Introduce failure, do NOT set memProps to |
| 2151 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2152 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2153 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2154 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
| 2156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2157 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2158 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2159 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2161 | pass = |
| 2162 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2163 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2164 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2165 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2166 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2167 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2168 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2169 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2170 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2171 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2172 | ASSERT_VK_SUCCESS(err); |
| 2173 | |
| 2174 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2175 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2176 | ASSERT_VK_SUCCESS(err); |
| 2177 | |
| 2178 | // Map memory as if to initialize the image |
| 2179 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2180 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2181 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2183 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2184 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2185 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2186 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2187 | } |
| 2188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2189 | TEST_F(VkLayerTest, RebindMemory) { |
| 2190 | VkResult err; |
| 2191 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2193 | m_errorMonitor->SetDesiredFailureMsg( |
| 2194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2195 | "which has already been bound to mem object"); |
| 2196 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2197 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2198 | |
| 2199 | // 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] | 2200 | VkImage image; |
| 2201 | VkDeviceMemory mem1; |
| 2202 | VkDeviceMemory mem2; |
| 2203 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2204 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2205 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2206 | const int32_t tex_width = 32; |
| 2207 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2208 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2209 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2210 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2211 | image_create_info.pNext = NULL; |
| 2212 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2213 | image_create_info.format = tex_format; |
| 2214 | image_create_info.extent.width = tex_width; |
| 2215 | image_create_info.extent.height = tex_height; |
| 2216 | image_create_info.extent.depth = 1; |
| 2217 | image_create_info.mipLevels = 1; |
| 2218 | image_create_info.arrayLayers = 1; |
| 2219 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2220 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2221 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2222 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2223 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2224 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2226 | mem_alloc.pNext = NULL; |
| 2227 | mem_alloc.allocationSize = 0; |
| 2228 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2229 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2230 | // Introduce failure, do NOT set memProps to |
| 2231 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2232 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2233 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2234 | ASSERT_VK_SUCCESS(err); |
| 2235 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2236 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2237 | |
| 2238 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2239 | pass = |
| 2240 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2241 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2242 | |
| 2243 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2244 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2245 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2246 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2247 | ASSERT_VK_SUCCESS(err); |
| 2248 | |
| 2249 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2250 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2251 | ASSERT_VK_SUCCESS(err); |
| 2252 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2253 | // Introduce validation failure, try to bind a different memory object to |
| 2254 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2255 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2256 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2257 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2258 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2259 | vkDestroyImage(m_device->device(), image, NULL); |
| 2260 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2261 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2262 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2264 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2265 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2267 | m_errorMonitor->SetDesiredFailureMsg( |
| 2268 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2269 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2270 | |
| 2271 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2272 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2273 | fenceInfo.pNext = NULL; |
| 2274 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2275 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2277 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2278 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2279 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2280 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2281 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2282 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2283 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2284 | |
| 2285 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2286 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2287 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2288 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2289 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2290 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2291 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2292 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2293 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2294 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2295 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2296 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2297 | |
| 2298 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2299 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2300 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2301 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2302 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2303 | // This is a positive test. We used to expect error in this case but spec now |
| 2304 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2305 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2306 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2307 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2308 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2309 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2310 | fenceInfo.pNext = NULL; |
| 2311 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2313 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2314 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2315 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2316 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2317 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2318 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2319 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2320 | |
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 2321 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
| 2322 | { |
| 2323 | m_errorMonitor->ExpectSuccess(); |
| 2324 | |
| 2325 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2326 | VkResult err; |
| 2327 | |
| 2328 | // Record (empty!) command buffer that can be submitted multiple times |
| 2329 | // simultaneously. |
| 2330 | VkCommandBufferBeginInfo cbbi = { |
| 2331 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 2332 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr |
| 2333 | }; |
| 2334 | m_commandBuffer->BeginCommandBuffer(&cbbi); |
| 2335 | m_commandBuffer->EndCommandBuffer(); |
| 2336 | |
| 2337 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; |
| 2338 | VkFence fence; |
| 2339 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); |
| 2340 | ASSERT_VK_SUCCESS(err); |
| 2341 | |
| 2342 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; |
| 2343 | VkSemaphore s1, s2; |
| 2344 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); |
| 2345 | ASSERT_VK_SUCCESS(err); |
| 2346 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); |
| 2347 | ASSERT_VK_SUCCESS(err); |
| 2348 | |
| 2349 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. |
| 2350 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, |
| 2351 | 1, &m_commandBuffer->handle(), 1, &s1 }; |
| 2352 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); |
| 2353 | ASSERT_VK_SUCCESS(err); |
| 2354 | |
| 2355 | // Submit CB again, signaling s2. |
| 2356 | si.pSignalSemaphores = &s2; |
| 2357 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); |
| 2358 | ASSERT_VK_SUCCESS(err); |
| 2359 | |
| 2360 | // Wait for fence. |
| 2361 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2362 | ASSERT_VK_SUCCESS(err); |
| 2363 | |
| 2364 | // CB is still in flight from second submission, but semaphore s1 is no |
| 2365 | // longer in flight. delete it. |
| 2366 | vkDestroySemaphore(m_device->device(), s1, nullptr); |
| 2367 | |
| 2368 | m_errorMonitor->VerifyNotFound(); |
| 2369 | |
| 2370 | // Force device idle and clean up remaining objects |
| 2371 | vkDeviceWaitIdle(m_device->device()); |
| 2372 | vkDestroySemaphore(m_device->device(), s2, nullptr); |
| 2373 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2374 | } |
| 2375 | |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2376 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2377 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2378 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2379 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2380 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2381 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2383 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2384 | |
| 2385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2386 | VkImageObj image(m_device); |
| 2387 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2388 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2389 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2390 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2391 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2392 | VkImageView dsv; |
| 2393 | VkImageViewCreateInfo dsvci = {}; |
| 2394 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2395 | dsvci.image = image.handle(); |
| 2396 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2397 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2398 | dsvci.subresourceRange.layerCount = 1; |
| 2399 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2400 | dsvci.subresourceRange.levelCount = 1; |
| 2401 | dsvci.subresourceRange.aspectMask = |
| 2402 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2403 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2404 | // Create a view with depth / stencil aspect for image with different usage |
| 2405 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2406 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2407 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2408 | |
| 2409 | // Initialize buffer with TRANSFER_DST usage |
| 2410 | vk_testing::Buffer buffer; |
| 2411 | VkMemoryPropertyFlags reqs = 0; |
| 2412 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2413 | VkBufferImageCopy region = {}; |
| 2414 | region.bufferRowLength = 128; |
| 2415 | region.bufferImageHeight = 128; |
| 2416 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2417 | region.imageSubresource.layerCount = 1; |
| 2418 | region.imageExtent.height = 16; |
| 2419 | region.imageExtent.width = 16; |
| 2420 | region.imageExtent.depth = 1; |
| 2421 | |
| 2422 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2423 | "Invalid usage flag for buffer "); |
| 2424 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2425 | // TRANSFER_DST |
| 2426 | BeginCommandBuffer(); |
| 2427 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2428 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2429 | 1, ®ion); |
| 2430 | m_errorMonitor->VerifyFound(); |
| 2431 | |
| 2432 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2433 | "Invalid usage flag for image "); |
| 2434 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2435 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2436 | 1, ®ion); |
| 2437 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2438 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2439 | #endif // MEM_TRACKER_TESTS |
| 2440 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2441 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2442 | |
| 2443 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2444 | VkResult err; |
| 2445 | |
| 2446 | TEST_DESCRIPTION( |
| 2447 | "Create a fence and destroy its device without first destroying the fence."); |
| 2448 | |
| 2449 | // Note that we have to create a new device since destroying the |
| 2450 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2451 | // will destroy the errorMonitor. |
| 2452 | |
| 2453 | m_errorMonitor->SetDesiredFailureMsg( |
| 2454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2455 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2456 | |
| 2457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2458 | |
| 2459 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2460 | m_device->queue_props; |
| 2461 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2462 | queue_info.reserve(queue_props.size()); |
| 2463 | std::vector<std::vector<float>> queue_priorities; |
| 2464 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2465 | VkDeviceQueueCreateInfo qi = {}; |
| 2466 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2467 | qi.pNext = NULL; |
| 2468 | qi.queueFamilyIndex = i; |
| 2469 | qi.queueCount = queue_props[i].queueCount; |
| 2470 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2471 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2472 | queue_info.push_back(qi); |
| 2473 | } |
| 2474 | |
| 2475 | std::vector<const char *> device_layer_names; |
| 2476 | std::vector<const char *> device_extension_names; |
| 2477 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2478 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2479 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2480 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2481 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2482 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2483 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2484 | |
| 2485 | // The sacrificial device object |
| 2486 | VkDevice testDevice; |
| 2487 | VkDeviceCreateInfo device_create_info = {}; |
| 2488 | auto features = m_device->phy().features(); |
| 2489 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2490 | device_create_info.pNext = NULL; |
| 2491 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2492 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2493 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2494 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2495 | device_create_info.pEnabledFeatures = &features; |
| 2496 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2497 | ASSERT_VK_SUCCESS(err); |
| 2498 | |
| 2499 | VkFence fence; |
| 2500 | VkFenceCreateInfo fence_create_info = {}; |
| 2501 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2502 | fence_create_info.pNext = NULL; |
| 2503 | fence_create_info.flags = 0; |
| 2504 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2505 | ASSERT_VK_SUCCESS(err); |
| 2506 | |
| 2507 | // Induce failure by not calling vkDestroyFence |
| 2508 | vkDestroyDevice(testDevice, NULL); |
| 2509 | m_errorMonitor->VerifyFound(); |
| 2510 | } |
| 2511 | |
| 2512 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2513 | |
| 2514 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2515 | "attempt to delete them from another."); |
| 2516 | |
| 2517 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2518 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2519 | |
| 2520 | VkCommandPool command_pool_one; |
| 2521 | VkCommandPool command_pool_two; |
| 2522 | |
| 2523 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2524 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2525 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2526 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2527 | |
| 2528 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2529 | &command_pool_one); |
| 2530 | |
| 2531 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2532 | &command_pool_two); |
| 2533 | |
| 2534 | VkCommandBuffer command_buffer[9]; |
| 2535 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2536 | command_buffer_allocate_info.sType = |
| 2537 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2538 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2539 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2540 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2541 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2542 | command_buffer); |
| 2543 | |
| 2544 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2545 | &command_buffer[3]); |
| 2546 | |
| 2547 | m_errorMonitor->VerifyFound(); |
| 2548 | |
| 2549 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2550 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2551 | } |
| 2552 | |
| 2553 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2554 | VkResult err; |
| 2555 | |
| 2556 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2557 | "attempt to delete them from another."); |
| 2558 | |
| 2559 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2560 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2561 | |
| 2562 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2563 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2564 | |
| 2565 | VkDescriptorPoolSize ds_type_count = {}; |
| 2566 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2567 | ds_type_count.descriptorCount = 1; |
| 2568 | |
| 2569 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2570 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2571 | ds_pool_ci.pNext = NULL; |
| 2572 | ds_pool_ci.flags = 0; |
| 2573 | ds_pool_ci.maxSets = 1; |
| 2574 | ds_pool_ci.poolSizeCount = 1; |
| 2575 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2576 | |
| 2577 | VkDescriptorPool ds_pool_one; |
| 2578 | err = |
| 2579 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2580 | ASSERT_VK_SUCCESS(err); |
| 2581 | |
| 2582 | // Create a second descriptor pool |
| 2583 | VkDescriptorPool ds_pool_two; |
| 2584 | err = |
| 2585 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2586 | ASSERT_VK_SUCCESS(err); |
| 2587 | |
| 2588 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2589 | dsl_binding.binding = 0; |
| 2590 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2591 | dsl_binding.descriptorCount = 1; |
| 2592 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2593 | dsl_binding.pImmutableSamplers = NULL; |
| 2594 | |
| 2595 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2596 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2597 | ds_layout_ci.pNext = NULL; |
| 2598 | ds_layout_ci.bindingCount = 1; |
| 2599 | ds_layout_ci.pBindings = &dsl_binding; |
| 2600 | |
| 2601 | VkDescriptorSetLayout ds_layout; |
| 2602 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2603 | &ds_layout); |
| 2604 | ASSERT_VK_SUCCESS(err); |
| 2605 | |
| 2606 | VkDescriptorSet descriptorSet; |
| 2607 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2608 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2609 | alloc_info.descriptorSetCount = 1; |
| 2610 | alloc_info.descriptorPool = ds_pool_one; |
| 2611 | alloc_info.pSetLayouts = &ds_layout; |
| 2612 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2613 | &descriptorSet); |
| 2614 | ASSERT_VK_SUCCESS(err); |
| 2615 | |
| 2616 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2617 | |
| 2618 | m_errorMonitor->VerifyFound(); |
| 2619 | |
| 2620 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2621 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2622 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2623 | } |
| 2624 | |
| 2625 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2626 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2627 | "Invalid VkImage Object "); |
| 2628 | |
| 2629 | TEST_DESCRIPTION( |
| 2630 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2631 | |
| 2632 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2633 | |
| 2634 | // Pass bogus handle into GetImageMemoryRequirements |
| 2635 | VkMemoryRequirements mem_reqs; |
| 2636 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2637 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2638 | |
| 2639 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2640 | |
| 2641 | m_errorMonitor->VerifyFound(); |
| 2642 | } |
| 2643 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2644 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2645 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2646 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2647 | TEST_DESCRIPTION( |
| 2648 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2649 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2651 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2652 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2654 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2655 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2656 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2658 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2659 | |
| 2660 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2661 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2662 | ds_pool_ci.pNext = NULL; |
| 2663 | ds_pool_ci.maxSets = 1; |
| 2664 | ds_pool_ci.poolSizeCount = 1; |
| 2665 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2666 | |
| 2667 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | err = |
| 2669 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2670 | ASSERT_VK_SUCCESS(err); |
| 2671 | |
| 2672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2673 | dsl_binding.binding = 0; |
| 2674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2675 | dsl_binding.descriptorCount = 1; |
| 2676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2677 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2678 | |
| 2679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2680 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2681 | ds_layout_ci.pNext = NULL; |
| 2682 | ds_layout_ci.bindingCount = 1; |
| 2683 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2684 | |
| 2685 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2686 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2687 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2688 | ASSERT_VK_SUCCESS(err); |
| 2689 | |
| 2690 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2691 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2692 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2693 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2694 | alloc_info.descriptorPool = ds_pool; |
| 2695 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2696 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2697 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2698 | ASSERT_VK_SUCCESS(err); |
| 2699 | |
| 2700 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2702 | pipeline_layout_ci.pNext = NULL; |
| 2703 | pipeline_layout_ci.setLayoutCount = 1; |
| 2704 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2705 | |
| 2706 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2707 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2708 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2709 | ASSERT_VK_SUCCESS(err); |
| 2710 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2711 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2712 | |
| 2713 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2714 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2715 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2716 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2717 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2718 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2719 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2720 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2721 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2722 | } |
| 2723 | |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2724 | TEST_F(VkLayerTest, BindImageInvalidMemoryType) { |
| 2725 | VkResult err; |
| 2726 | |
| 2727 | TEST_DESCRIPTION("Test validation check for an invalid memory type index " |
| 2728 | "during bind[Buffer|Image]Memory time"); |
| 2729 | |
| 2730 | m_errorMonitor->SetDesiredFailureMsg( |
| 2731 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2732 | "for this object type are not compatible with the memory"); |
| 2733 | |
| 2734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2735 | |
| 2736 | // Create an image, allocate memory, set a bad typeIndex and then try to |
| 2737 | // bind it |
| 2738 | VkImage image; |
| 2739 | VkDeviceMemory mem; |
| 2740 | VkMemoryRequirements mem_reqs; |
| 2741 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2742 | const int32_t tex_width = 32; |
| 2743 | const int32_t tex_height = 32; |
| 2744 | |
| 2745 | VkImageCreateInfo image_create_info = {}; |
| 2746 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2747 | image_create_info.pNext = NULL; |
| 2748 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2749 | image_create_info.format = tex_format; |
| 2750 | image_create_info.extent.width = tex_width; |
| 2751 | image_create_info.extent.height = tex_height; |
| 2752 | image_create_info.extent.depth = 1; |
| 2753 | image_create_info.mipLevels = 1; |
| 2754 | image_create_info.arrayLayers = 1; |
| 2755 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2756 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2757 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2758 | image_create_info.flags = 0; |
| 2759 | |
| 2760 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2761 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2762 | mem_alloc.pNext = NULL; |
| 2763 | mem_alloc.allocationSize = 0; |
| 2764 | mem_alloc.memoryTypeIndex = 0; |
| 2765 | |
| 2766 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2767 | ASSERT_VK_SUCCESS(err); |
| 2768 | |
| 2769 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 2770 | mem_alloc.allocationSize = mem_reqs.size; |
| 2771 | // Introduce Failure, select likely invalid TypeIndex |
| 2772 | mem_alloc.memoryTypeIndex = 31; |
| 2773 | |
| 2774 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2775 | ASSERT_VK_SUCCESS(err); |
| 2776 | |
| 2777 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2778 | (void)err; |
| 2779 | |
| 2780 | m_errorMonitor->VerifyFound(); |
| 2781 | |
| 2782 | vkDestroyImage(m_device->device(), image, NULL); |
| 2783 | vkFreeMemory(m_device->device(), mem, NULL); |
| 2784 | } |
| 2785 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2787 | VkResult err; |
| 2788 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2789 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2790 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2791 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2792 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2794 | |
| 2795 | // 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] | 2796 | VkImage image; |
| 2797 | VkDeviceMemory mem; |
| 2798 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2801 | const int32_t tex_width = 32; |
| 2802 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2803 | |
| 2804 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2805 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2806 | image_create_info.pNext = NULL; |
| 2807 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2808 | image_create_info.format = tex_format; |
| 2809 | image_create_info.extent.width = tex_width; |
| 2810 | image_create_info.extent.height = tex_height; |
| 2811 | image_create_info.extent.depth = 1; |
| 2812 | image_create_info.mipLevels = 1; |
| 2813 | image_create_info.arrayLayers = 1; |
| 2814 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2815 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2816 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2817 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2818 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2819 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2821 | mem_alloc.pNext = NULL; |
| 2822 | mem_alloc.allocationSize = 0; |
| 2823 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2824 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2825 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2826 | ASSERT_VK_SUCCESS(err); |
| 2827 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2828 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2829 | |
| 2830 | mem_alloc.allocationSize = mem_reqs.size; |
| 2831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | pass = |
| 2833 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2834 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2835 | |
| 2836 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2837 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2838 | ASSERT_VK_SUCCESS(err); |
| 2839 | |
| 2840 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2841 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2842 | |
| 2843 | // Try to bind free memory that has been freed |
| 2844 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2845 | // This may very well return an error. |
| 2846 | (void)err; |
| 2847 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2848 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2849 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2850 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2851 | } |
| 2852 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2853 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2854 | VkResult err; |
| 2855 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2856 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2857 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2858 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2859 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2860 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2862 | // Create an image object, allocate memory, destroy the object and then try |
| 2863 | // to bind it |
| 2864 | VkImage image; |
| 2865 | VkDeviceMemory mem; |
| 2866 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2868 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2869 | const int32_t tex_width = 32; |
| 2870 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2871 | |
| 2872 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2873 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2874 | image_create_info.pNext = NULL; |
| 2875 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2876 | image_create_info.format = tex_format; |
| 2877 | image_create_info.extent.width = tex_width; |
| 2878 | image_create_info.extent.height = tex_height; |
| 2879 | image_create_info.extent.depth = 1; |
| 2880 | image_create_info.mipLevels = 1; |
| 2881 | image_create_info.arrayLayers = 1; |
| 2882 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2883 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2884 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2885 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2886 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2887 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2889 | mem_alloc.pNext = NULL; |
| 2890 | mem_alloc.allocationSize = 0; |
| 2891 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2892 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2893 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2894 | ASSERT_VK_SUCCESS(err); |
| 2895 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2896 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2897 | |
| 2898 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2899 | pass = |
| 2900 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2901 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2902 | |
| 2903 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2904 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
| 2906 | |
| 2907 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2908 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2909 | ASSERT_VK_SUCCESS(err); |
| 2910 | |
| 2911 | // Now Try to bind memory to this destroyed object |
| 2912 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2913 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2914 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2916 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2917 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2918 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2919 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2920 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2921 | #endif // OBJ_TRACKER_TESTS |
| 2922 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2923 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2924 | |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame^] | 2925 | TEST_F(VkLayerTest, UnusedPreserveAttachment) { |
| 2926 | TEST_DESCRIPTION("Create a framebuffer where a subpass has a preserve " |
| 2927 | "attachment reference of VK_ATTACHMENT_UNUSED"); |
| 2928 | |
| 2929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2930 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2931 | |
| 2932 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2933 | "must not be VK_ATTACHMENT_UNUSED"); |
| 2934 | |
| 2935 | VkAttachmentReference color_attach = {}; |
| 2936 | color_attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 2937 | color_attach.attachment = 0; |
| 2938 | uint32_t preserve_attachment = VK_ATTACHMENT_UNUSED; |
| 2939 | VkSubpassDescription subpass = {}; |
| 2940 | subpass.colorAttachmentCount = 1; |
| 2941 | subpass.pColorAttachments = &color_attach; |
| 2942 | subpass.preserveAttachmentCount = 1; |
| 2943 | subpass.pPreserveAttachments = &preserve_attachment; |
| 2944 | |
| 2945 | VkRenderPassCreateInfo rpci = {}; |
| 2946 | rpci.subpassCount = 1; |
| 2947 | rpci.pSubpasses = &subpass; |
| 2948 | rpci.attachmentCount = 1; |
| 2949 | VkAttachmentDescription attach_desc = {}; |
| 2950 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 2951 | rpci.pAttachments = &attach_desc; |
| 2952 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 2953 | VkRenderPass rp; |
| 2954 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 2955 | |
| 2956 | m_errorMonitor->VerifyFound(); |
| 2957 | |
| 2958 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 2959 | } |
| 2960 | |
| 2961 | TEST_F(VkLayerTest, AttachmentUsageMismatch) { |
| 2962 | TEST_DESCRIPTION("Create a framebuffer where a subpass uses a color image " |
| 2963 | "in the depthStencil attachment point"); |
| 2964 | |
| 2965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2966 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2967 | |
| 2968 | m_errorMonitor->SetDesiredFailureMsg( |
| 2969 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2970 | "conflicts with the image's IMAGE_USAGE flags"); |
| 2971 | |
| 2972 | // Create a renderPass with a depth-stencil attachment created with |
| 2973 | // IMAGE_USAGE_COLOR_ATTACHMENT |
| 2974 | VkAttachmentReference attach = {}; |
| 2975 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 2976 | VkSubpassDescription subpass = {}; |
| 2977 | // Add our color attachment to pDepthStencilAttachment |
| 2978 | subpass.pDepthStencilAttachment = &attach; |
| 2979 | VkRenderPassCreateInfo rpci = {}; |
| 2980 | rpci.subpassCount = 1; |
| 2981 | rpci.pSubpasses = &subpass; |
| 2982 | rpci.attachmentCount = 1; |
| 2983 | VkAttachmentDescription attach_desc = {}; |
| 2984 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 2985 | rpci.pAttachments = &attach_desc; |
| 2986 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 2987 | VkRenderPass rp; |
| 2988 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 2989 | ASSERT_VK_SUCCESS(err); |
| 2990 | |
| 2991 | VkImageView imageView = |
| 2992 | m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
| 2993 | VkFramebufferCreateInfo fb_info = {}; |
| 2994 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 2995 | fb_info.pNext = NULL; |
| 2996 | fb_info.renderPass = rp; |
| 2997 | fb_info.attachmentCount = 1; |
| 2998 | fb_info.pAttachments = &imageView; |
| 2999 | fb_info.width = 100; |
| 3000 | fb_info.height = 100; |
| 3001 | fb_info.layers = 1; |
| 3002 | |
| 3003 | VkFramebuffer fb; |
| 3004 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3005 | |
| 3006 | m_errorMonitor->VerifyFound(); |
| 3007 | |
| 3008 | if (err == VK_SUCCESS) { |
| 3009 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3010 | } |
| 3011 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3012 | } |
| 3013 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3014 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3015 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 3016 | TEST_DESCRIPTION( |
| 3017 | "Wait on a event then set it after the wait has been submitted."); |
| 3018 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3019 | m_errorMonitor->ExpectSuccess(); |
| 3020 | |
| 3021 | VkEvent event; |
| 3022 | VkEventCreateInfo event_create_info{}; |
| 3023 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3024 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3025 | |
| 3026 | VkCommandPool command_pool; |
| 3027 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3028 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3029 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3030 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3031 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3032 | &command_pool); |
| 3033 | |
| 3034 | VkCommandBuffer command_buffer; |
| 3035 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3036 | command_buffer_allocate_info.sType = |
| 3037 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3038 | command_buffer_allocate_info.commandPool = command_pool; |
| 3039 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3040 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3041 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3042 | &command_buffer); |
| 3043 | |
| 3044 | VkQueue queue = VK_NULL_HANDLE; |
| 3045 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3046 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3047 | |
| 3048 | { |
| 3049 | VkCommandBufferBeginInfo begin_info{}; |
| 3050 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3051 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3052 | |
| 3053 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 3054 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3055 | nullptr, 0, nullptr); |
| 3056 | vkCmdResetEvent(command_buffer, event, |
| 3057 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3058 | vkEndCommandBuffer(command_buffer); |
| 3059 | } |
| 3060 | { |
| 3061 | VkSubmitInfo submit_info{}; |
| 3062 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3063 | submit_info.commandBufferCount = 1; |
| 3064 | submit_info.pCommandBuffers = &command_buffer; |
| 3065 | submit_info.signalSemaphoreCount = 0; |
| 3066 | submit_info.pSignalSemaphores = nullptr; |
| 3067 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3068 | } |
| 3069 | { vkSetEvent(m_device->device(), event); } |
| 3070 | |
| 3071 | vkQueueWaitIdle(queue); |
| 3072 | |
| 3073 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3074 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3075 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3076 | |
| 3077 | m_errorMonitor->VerifyNotFound(); |
| 3078 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3079 | // This is a positive test. No errors should be generated. |
| 3080 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 3081 | TEST_DESCRIPTION( |
| 3082 | "Issue a query and copy from it on a second command buffer."); |
| 3083 | |
| 3084 | if ((m_device->queue_props.empty()) || |
| 3085 | (m_device->queue_props[0].queueCount < 2)) |
| 3086 | return; |
| 3087 | |
| 3088 | m_errorMonitor->ExpectSuccess(); |
| 3089 | |
| 3090 | VkQueryPool query_pool; |
| 3091 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 3092 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 3093 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 3094 | query_pool_create_info.queryCount = 1; |
| 3095 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 3096 | &query_pool); |
| 3097 | |
| 3098 | VkCommandPool command_pool; |
| 3099 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3100 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3101 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3102 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3103 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3104 | &command_pool); |
| 3105 | |
| 3106 | VkCommandBuffer command_buffer[2]; |
| 3107 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3108 | command_buffer_allocate_info.sType = |
| 3109 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3110 | command_buffer_allocate_info.commandPool = command_pool; |
| 3111 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3112 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3113 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3114 | command_buffer); |
| 3115 | |
| 3116 | VkQueue queue = VK_NULL_HANDLE; |
| 3117 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3118 | 1, &queue); |
| 3119 | |
| 3120 | uint32_t qfi = 0; |
| 3121 | VkBufferCreateInfo buff_create_info = {}; |
| 3122 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3123 | buff_create_info.size = 1024; |
| 3124 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 3125 | buff_create_info.queueFamilyIndexCount = 1; |
| 3126 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 3127 | |
| 3128 | VkResult err; |
| 3129 | VkBuffer buffer; |
| 3130 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 3131 | ASSERT_VK_SUCCESS(err); |
| 3132 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3133 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3134 | mem_alloc.pNext = NULL; |
| 3135 | mem_alloc.allocationSize = 1024; |
| 3136 | mem_alloc.memoryTypeIndex = 0; |
| 3137 | |
| 3138 | VkMemoryRequirements memReqs; |
| 3139 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 3140 | bool pass = |
| 3141 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 3142 | if (!pass) { |
| 3143 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3144 | return; |
| 3145 | } |
| 3146 | |
| 3147 | VkDeviceMemory mem; |
| 3148 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3149 | ASSERT_VK_SUCCESS(err); |
| 3150 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 3151 | ASSERT_VK_SUCCESS(err); |
| 3152 | |
| 3153 | { |
| 3154 | VkCommandBufferBeginInfo begin_info{}; |
| 3155 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3156 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3157 | |
| 3158 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 3159 | vkCmdWriteTimestamp(command_buffer[0], |
| 3160 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 3161 | |
| 3162 | vkEndCommandBuffer(command_buffer[0]); |
| 3163 | |
| 3164 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3165 | |
| 3166 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 3167 | 0, 0, 0); |
| 3168 | |
| 3169 | vkEndCommandBuffer(command_buffer[1]); |
| 3170 | } |
| 3171 | { |
| 3172 | VkSubmitInfo submit_info{}; |
| 3173 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3174 | submit_info.commandBufferCount = 2; |
| 3175 | submit_info.pCommandBuffers = command_buffer; |
| 3176 | submit_info.signalSemaphoreCount = 0; |
| 3177 | submit_info.pSignalSemaphores = nullptr; |
| 3178 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3179 | } |
| 3180 | |
| 3181 | vkQueueWaitIdle(queue); |
| 3182 | |
| 3183 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 3184 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 3185 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3186 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3187 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3188 | |
| 3189 | m_errorMonitor->VerifyNotFound(); |
| 3190 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3191 | |
| 3192 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 3193 | TEST_DESCRIPTION( |
| 3194 | "Reset an event then set it after the reset has been submitted."); |
| 3195 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3196 | m_errorMonitor->ExpectSuccess(); |
| 3197 | |
| 3198 | VkEvent event; |
| 3199 | VkEventCreateInfo event_create_info{}; |
| 3200 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3201 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3202 | |
| 3203 | VkCommandPool command_pool; |
| 3204 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3205 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3206 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3207 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3208 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3209 | &command_pool); |
| 3210 | |
| 3211 | VkCommandBuffer command_buffer; |
| 3212 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3213 | command_buffer_allocate_info.sType = |
| 3214 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3215 | command_buffer_allocate_info.commandPool = command_pool; |
| 3216 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3217 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3218 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3219 | &command_buffer); |
| 3220 | |
| 3221 | VkQueue queue = VK_NULL_HANDLE; |
| 3222 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3223 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3224 | |
| 3225 | { |
| 3226 | VkCommandBufferBeginInfo begin_info{}; |
| 3227 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3228 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3229 | |
| 3230 | vkCmdResetEvent(command_buffer, event, |
| 3231 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3232 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 3233 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3234 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3235 | nullptr, 0, nullptr); |
| 3236 | vkEndCommandBuffer(command_buffer); |
| 3237 | } |
| 3238 | { |
| 3239 | VkSubmitInfo submit_info{}; |
| 3240 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3241 | submit_info.commandBufferCount = 1; |
| 3242 | submit_info.pCommandBuffers = &command_buffer; |
| 3243 | submit_info.signalSemaphoreCount = 0; |
| 3244 | submit_info.pSignalSemaphores = nullptr; |
| 3245 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3246 | } |
| 3247 | { |
| 3248 | m_errorMonitor->SetDesiredFailureMsg( |
| 3249 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 3250 | "0x1 that is already in use by a " |
| 3251 | "command buffer."); |
| 3252 | vkSetEvent(m_device->device(), event); |
| 3253 | m_errorMonitor->VerifyFound(); |
| 3254 | } |
| 3255 | |
| 3256 | vkQueueWaitIdle(queue); |
| 3257 | |
| 3258 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3259 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3260 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3261 | } |
| 3262 | |
| 3263 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3264 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 3265 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 3266 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 3267 | "previously revealed a bug so running this positive test " |
| 3268 | "to prevent a regression."); |
| 3269 | m_errorMonitor->ExpectSuccess(); |
| 3270 | |
| 3271 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3272 | VkQueue queue = VK_NULL_HANDLE; |
| 3273 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3274 | 0, &queue); |
| 3275 | |
| 3276 | static const uint32_t NUM_OBJECTS = 2; |
| 3277 | static const uint32_t NUM_FRAMES = 3; |
| 3278 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 3279 | VkFence fences[NUM_OBJECTS] = {}; |
| 3280 | |
| 3281 | VkCommandPool cmd_pool; |
| 3282 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 3283 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3284 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3285 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3286 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3287 | nullptr, &cmd_pool); |
| 3288 | ASSERT_VK_SUCCESS(err); |
| 3289 | |
| 3290 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3291 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3292 | cmd_buf_info.commandPool = cmd_pool; |
| 3293 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3294 | cmd_buf_info.commandBufferCount = 1; |
| 3295 | |
| 3296 | VkFenceCreateInfo fence_ci = {}; |
| 3297 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3298 | fence_ci.pNext = nullptr; |
| 3299 | fence_ci.flags = 0; |
| 3300 | |
| 3301 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3302 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3303 | &cmd_buffers[i]); |
| 3304 | ASSERT_VK_SUCCESS(err); |
| 3305 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3306 | ASSERT_VK_SUCCESS(err); |
| 3307 | } |
| 3308 | |
| 3309 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3310 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3311 | // Create empty cmd buffer |
| 3312 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3313 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3314 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3315 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3316 | ASSERT_VK_SUCCESS(err); |
| 3317 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3318 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3319 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3320 | VkSubmitInfo submit_info = {}; |
| 3321 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3322 | submit_info.commandBufferCount = 1; |
| 3323 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3324 | // Submit cmd buffer and wait for fence |
| 3325 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3326 | ASSERT_VK_SUCCESS(err); |
| 3327 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3328 | UINT64_MAX); |
| 3329 | ASSERT_VK_SUCCESS(err); |
| 3330 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3333 | } |
| 3334 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3335 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3336 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3337 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3338 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3339 | } |
| 3340 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3341 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3342 | |
| 3343 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3344 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3345 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3346 | if ((m_device->queue_props.empty()) || |
| 3347 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3348 | return; |
| 3349 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3350 | m_errorMonitor->ExpectSuccess(); |
| 3351 | |
| 3352 | VkSemaphore semaphore; |
| 3353 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3354 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3355 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3356 | &semaphore); |
| 3357 | |
| 3358 | VkCommandPool command_pool; |
| 3359 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3360 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3361 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3362 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3363 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3364 | &command_pool); |
| 3365 | |
| 3366 | VkCommandBuffer command_buffer[2]; |
| 3367 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3368 | command_buffer_allocate_info.sType = |
| 3369 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3370 | command_buffer_allocate_info.commandPool = command_pool; |
| 3371 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3372 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3373 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3374 | command_buffer); |
| 3375 | |
| 3376 | VkQueue queue = VK_NULL_HANDLE; |
| 3377 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3378 | 1, &queue); |
| 3379 | |
| 3380 | { |
| 3381 | VkCommandBufferBeginInfo begin_info{}; |
| 3382 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3383 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3384 | |
| 3385 | vkCmdPipelineBarrier(command_buffer[0], |
| 3386 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3387 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3388 | 0, nullptr, 0, nullptr); |
| 3389 | |
| 3390 | VkViewport viewport{}; |
| 3391 | viewport.maxDepth = 1.0f; |
| 3392 | viewport.minDepth = 0.0f; |
| 3393 | viewport.width = 512; |
| 3394 | viewport.height = 512; |
| 3395 | viewport.x = 0; |
| 3396 | viewport.y = 0; |
| 3397 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3398 | vkEndCommandBuffer(command_buffer[0]); |
| 3399 | } |
| 3400 | { |
| 3401 | VkCommandBufferBeginInfo begin_info{}; |
| 3402 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3403 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3404 | |
| 3405 | VkViewport viewport{}; |
| 3406 | viewport.maxDepth = 1.0f; |
| 3407 | viewport.minDepth = 0.0f; |
| 3408 | viewport.width = 512; |
| 3409 | viewport.height = 512; |
| 3410 | viewport.x = 0; |
| 3411 | viewport.y = 0; |
| 3412 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3413 | vkEndCommandBuffer(command_buffer[1]); |
| 3414 | } |
| 3415 | { |
| 3416 | VkSubmitInfo submit_info{}; |
| 3417 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3418 | submit_info.commandBufferCount = 1; |
| 3419 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3420 | submit_info.signalSemaphoreCount = 1; |
| 3421 | submit_info.pSignalSemaphores = &semaphore; |
| 3422 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3423 | } |
| 3424 | { |
| 3425 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3426 | VkSubmitInfo submit_info{}; |
| 3427 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3428 | submit_info.commandBufferCount = 1; |
| 3429 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3430 | submit_info.waitSemaphoreCount = 1; |
| 3431 | submit_info.pWaitSemaphores = &semaphore; |
| 3432 | submit_info.pWaitDstStageMask = flags; |
| 3433 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3434 | } |
| 3435 | |
| 3436 | vkQueueWaitIdle(m_device->m_queue); |
| 3437 | |
| 3438 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3439 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3440 | &command_buffer[0]); |
| 3441 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3442 | |
| 3443 | m_errorMonitor->VerifyNotFound(); |
| 3444 | } |
| 3445 | |
| 3446 | // This is a positive test. No errors should be generated. |
| 3447 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3448 | |
| 3449 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3450 | "submitted on separate queues, the second having a fence" |
| 3451 | "followed by a QueueWaitIdle."); |
| 3452 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3453 | if ((m_device->queue_props.empty()) || |
| 3454 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3455 | return; |
| 3456 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3457 | m_errorMonitor->ExpectSuccess(); |
| 3458 | |
| 3459 | VkFence fence; |
| 3460 | VkFenceCreateInfo fence_create_info{}; |
| 3461 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3462 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3463 | |
| 3464 | VkSemaphore semaphore; |
| 3465 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3466 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3467 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3468 | &semaphore); |
| 3469 | |
| 3470 | VkCommandPool command_pool; |
| 3471 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3472 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3473 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3474 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3475 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3476 | &command_pool); |
| 3477 | |
| 3478 | VkCommandBuffer command_buffer[2]; |
| 3479 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3480 | command_buffer_allocate_info.sType = |
| 3481 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3482 | command_buffer_allocate_info.commandPool = command_pool; |
| 3483 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3484 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3485 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3486 | command_buffer); |
| 3487 | |
| 3488 | VkQueue queue = VK_NULL_HANDLE; |
| 3489 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3490 | 1, &queue); |
| 3491 | |
| 3492 | { |
| 3493 | VkCommandBufferBeginInfo begin_info{}; |
| 3494 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3495 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3496 | |
| 3497 | vkCmdPipelineBarrier(command_buffer[0], |
| 3498 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3499 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3500 | 0, nullptr, 0, nullptr); |
| 3501 | |
| 3502 | VkViewport viewport{}; |
| 3503 | viewport.maxDepth = 1.0f; |
| 3504 | viewport.minDepth = 0.0f; |
| 3505 | viewport.width = 512; |
| 3506 | viewport.height = 512; |
| 3507 | viewport.x = 0; |
| 3508 | viewport.y = 0; |
| 3509 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3510 | vkEndCommandBuffer(command_buffer[0]); |
| 3511 | } |
| 3512 | { |
| 3513 | VkCommandBufferBeginInfo begin_info{}; |
| 3514 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3515 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3516 | |
| 3517 | VkViewport viewport{}; |
| 3518 | viewport.maxDepth = 1.0f; |
| 3519 | viewport.minDepth = 0.0f; |
| 3520 | viewport.width = 512; |
| 3521 | viewport.height = 512; |
| 3522 | viewport.x = 0; |
| 3523 | viewport.y = 0; |
| 3524 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3525 | vkEndCommandBuffer(command_buffer[1]); |
| 3526 | } |
| 3527 | { |
| 3528 | VkSubmitInfo submit_info{}; |
| 3529 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3530 | submit_info.commandBufferCount = 1; |
| 3531 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3532 | submit_info.signalSemaphoreCount = 1; |
| 3533 | submit_info.pSignalSemaphores = &semaphore; |
| 3534 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3535 | } |
| 3536 | { |
| 3537 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3538 | VkSubmitInfo submit_info{}; |
| 3539 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3540 | submit_info.commandBufferCount = 1; |
| 3541 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3542 | submit_info.waitSemaphoreCount = 1; |
| 3543 | submit_info.pWaitSemaphores = &semaphore; |
| 3544 | submit_info.pWaitDstStageMask = flags; |
| 3545 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3546 | } |
| 3547 | |
| 3548 | vkQueueWaitIdle(m_device->m_queue); |
| 3549 | |
| 3550 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3551 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3552 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3553 | &command_buffer[0]); |
| 3554 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3555 | |
| 3556 | m_errorMonitor->VerifyNotFound(); |
| 3557 | } |
| 3558 | |
| 3559 | // This is a positive test. No errors should be generated. |
| 3560 | TEST_F(VkLayerTest, |
| 3561 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3562 | |
| 3563 | TEST_DESCRIPTION( |
| 3564 | "Two command buffers, each in a separate QueueSubmit call " |
| 3565 | "submitted on separate queues, the second having a fence" |
| 3566 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3567 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3568 | if ((m_device->queue_props.empty()) || |
| 3569 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3570 | return; |
| 3571 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3572 | m_errorMonitor->ExpectSuccess(); |
| 3573 | |
| 3574 | VkFence fence; |
| 3575 | VkFenceCreateInfo fence_create_info{}; |
| 3576 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3577 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3578 | |
| 3579 | VkSemaphore semaphore; |
| 3580 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3581 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3582 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3583 | &semaphore); |
| 3584 | |
| 3585 | VkCommandPool command_pool; |
| 3586 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3587 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3588 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3589 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3590 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3591 | &command_pool); |
| 3592 | |
| 3593 | VkCommandBuffer command_buffer[2]; |
| 3594 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3595 | command_buffer_allocate_info.sType = |
| 3596 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3597 | command_buffer_allocate_info.commandPool = command_pool; |
| 3598 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3599 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3600 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3601 | command_buffer); |
| 3602 | |
| 3603 | VkQueue queue = VK_NULL_HANDLE; |
| 3604 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3605 | 1, &queue); |
| 3606 | |
| 3607 | { |
| 3608 | VkCommandBufferBeginInfo begin_info{}; |
| 3609 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3610 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3611 | |
| 3612 | vkCmdPipelineBarrier(command_buffer[0], |
| 3613 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3614 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3615 | 0, nullptr, 0, nullptr); |
| 3616 | |
| 3617 | VkViewport viewport{}; |
| 3618 | viewport.maxDepth = 1.0f; |
| 3619 | viewport.minDepth = 0.0f; |
| 3620 | viewport.width = 512; |
| 3621 | viewport.height = 512; |
| 3622 | viewport.x = 0; |
| 3623 | viewport.y = 0; |
| 3624 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3625 | vkEndCommandBuffer(command_buffer[0]); |
| 3626 | } |
| 3627 | { |
| 3628 | VkCommandBufferBeginInfo begin_info{}; |
| 3629 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3630 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3631 | |
| 3632 | VkViewport viewport{}; |
| 3633 | viewport.maxDepth = 1.0f; |
| 3634 | viewport.minDepth = 0.0f; |
| 3635 | viewport.width = 512; |
| 3636 | viewport.height = 512; |
| 3637 | viewport.x = 0; |
| 3638 | viewport.y = 0; |
| 3639 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3640 | vkEndCommandBuffer(command_buffer[1]); |
| 3641 | } |
| 3642 | { |
| 3643 | VkSubmitInfo submit_info{}; |
| 3644 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3645 | submit_info.commandBufferCount = 1; |
| 3646 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3647 | submit_info.signalSemaphoreCount = 1; |
| 3648 | submit_info.pSignalSemaphores = &semaphore; |
| 3649 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3650 | } |
| 3651 | { |
| 3652 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3653 | VkSubmitInfo submit_info{}; |
| 3654 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3655 | submit_info.commandBufferCount = 1; |
| 3656 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3657 | submit_info.waitSemaphoreCount = 1; |
| 3658 | submit_info.pWaitSemaphores = &semaphore; |
| 3659 | submit_info.pWaitDstStageMask = flags; |
| 3660 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3661 | } |
| 3662 | |
| 3663 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3664 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3665 | |
| 3666 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3667 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3668 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3669 | &command_buffer[0]); |
| 3670 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3671 | |
| 3672 | m_errorMonitor->VerifyNotFound(); |
| 3673 | } |
| 3674 | |
| 3675 | // This is a positive test. No errors should be generated. |
| 3676 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3677 | |
| 3678 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3679 | "submitted on separate queues, the second having a fence, " |
| 3680 | "followed by a WaitForFences call."); |
| 3681 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3682 | if ((m_device->queue_props.empty()) || |
| 3683 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3684 | return; |
| 3685 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3686 | m_errorMonitor->ExpectSuccess(); |
| 3687 | |
| 3688 | VkFence fence; |
| 3689 | VkFenceCreateInfo fence_create_info{}; |
| 3690 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3691 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3692 | |
| 3693 | VkSemaphore semaphore; |
| 3694 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3695 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3696 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3697 | &semaphore); |
| 3698 | |
| 3699 | VkCommandPool command_pool; |
| 3700 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3701 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3702 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3703 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3704 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3705 | &command_pool); |
| 3706 | |
| 3707 | VkCommandBuffer command_buffer[2]; |
| 3708 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3709 | command_buffer_allocate_info.sType = |
| 3710 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3711 | command_buffer_allocate_info.commandPool = command_pool; |
| 3712 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3713 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3714 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3715 | command_buffer); |
| 3716 | |
| 3717 | VkQueue queue = VK_NULL_HANDLE; |
| 3718 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3719 | 1, &queue); |
| 3720 | |
| 3721 | |
| 3722 | { |
| 3723 | VkCommandBufferBeginInfo begin_info{}; |
| 3724 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3725 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3726 | |
| 3727 | vkCmdPipelineBarrier(command_buffer[0], |
| 3728 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3729 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3730 | 0, nullptr, 0, nullptr); |
| 3731 | |
| 3732 | VkViewport viewport{}; |
| 3733 | viewport.maxDepth = 1.0f; |
| 3734 | viewport.minDepth = 0.0f; |
| 3735 | viewport.width = 512; |
| 3736 | viewport.height = 512; |
| 3737 | viewport.x = 0; |
| 3738 | viewport.y = 0; |
| 3739 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3740 | vkEndCommandBuffer(command_buffer[0]); |
| 3741 | } |
| 3742 | { |
| 3743 | VkCommandBufferBeginInfo begin_info{}; |
| 3744 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3745 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3746 | |
| 3747 | VkViewport viewport{}; |
| 3748 | viewport.maxDepth = 1.0f; |
| 3749 | viewport.minDepth = 0.0f; |
| 3750 | viewport.width = 512; |
| 3751 | viewport.height = 512; |
| 3752 | viewport.x = 0; |
| 3753 | viewport.y = 0; |
| 3754 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3755 | vkEndCommandBuffer(command_buffer[1]); |
| 3756 | } |
| 3757 | { |
| 3758 | VkSubmitInfo submit_info{}; |
| 3759 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3760 | submit_info.commandBufferCount = 1; |
| 3761 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3762 | submit_info.signalSemaphoreCount = 1; |
| 3763 | submit_info.pSignalSemaphores = &semaphore; |
| 3764 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3765 | } |
| 3766 | { |
| 3767 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3768 | VkSubmitInfo submit_info{}; |
| 3769 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3770 | submit_info.commandBufferCount = 1; |
| 3771 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3772 | submit_info.waitSemaphoreCount = 1; |
| 3773 | submit_info.pWaitSemaphores = &semaphore; |
| 3774 | submit_info.pWaitDstStageMask = flags; |
| 3775 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3776 | } |
| 3777 | |
| 3778 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3779 | |
| 3780 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3781 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3782 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3783 | &command_buffer[0]); |
| 3784 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3785 | |
| 3786 | m_errorMonitor->VerifyNotFound(); |
| 3787 | } |
| 3788 | |
| 3789 | // This is a positive test. No errors should be generated. |
| 3790 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3791 | |
| 3792 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3793 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3794 | "second having a fence, " |
| 3795 | "followed by a WaitForFences call."); |
| 3796 | |
| 3797 | m_errorMonitor->ExpectSuccess(); |
| 3798 | |
| 3799 | VkFence fence; |
| 3800 | VkFenceCreateInfo fence_create_info{}; |
| 3801 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3802 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3803 | |
| 3804 | VkSemaphore semaphore; |
| 3805 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3806 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3807 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3808 | &semaphore); |
| 3809 | |
| 3810 | VkCommandPool command_pool; |
| 3811 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3812 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3813 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3814 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3815 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3816 | &command_pool); |
| 3817 | |
| 3818 | VkCommandBuffer command_buffer[2]; |
| 3819 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3820 | command_buffer_allocate_info.sType = |
| 3821 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3822 | command_buffer_allocate_info.commandPool = command_pool; |
| 3823 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3824 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3825 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3826 | command_buffer); |
| 3827 | |
| 3828 | { |
| 3829 | VkCommandBufferBeginInfo begin_info{}; |
| 3830 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3831 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3832 | |
| 3833 | vkCmdPipelineBarrier(command_buffer[0], |
| 3834 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3835 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3836 | 0, nullptr, 0, nullptr); |
| 3837 | |
| 3838 | VkViewport viewport{}; |
| 3839 | viewport.maxDepth = 1.0f; |
| 3840 | viewport.minDepth = 0.0f; |
| 3841 | viewport.width = 512; |
| 3842 | viewport.height = 512; |
| 3843 | viewport.x = 0; |
| 3844 | viewport.y = 0; |
| 3845 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3846 | vkEndCommandBuffer(command_buffer[0]); |
| 3847 | } |
| 3848 | { |
| 3849 | VkCommandBufferBeginInfo begin_info{}; |
| 3850 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3851 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3852 | |
| 3853 | VkViewport viewport{}; |
| 3854 | viewport.maxDepth = 1.0f; |
| 3855 | viewport.minDepth = 0.0f; |
| 3856 | viewport.width = 512; |
| 3857 | viewport.height = 512; |
| 3858 | viewport.x = 0; |
| 3859 | viewport.y = 0; |
| 3860 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3861 | vkEndCommandBuffer(command_buffer[1]); |
| 3862 | } |
| 3863 | { |
| 3864 | VkSubmitInfo submit_info{}; |
| 3865 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3866 | submit_info.commandBufferCount = 1; |
| 3867 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3868 | submit_info.signalSemaphoreCount = 1; |
| 3869 | submit_info.pSignalSemaphores = &semaphore; |
| 3870 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3871 | } |
| 3872 | { |
| 3873 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3874 | VkSubmitInfo submit_info{}; |
| 3875 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3876 | submit_info.commandBufferCount = 1; |
| 3877 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3878 | submit_info.waitSemaphoreCount = 1; |
| 3879 | submit_info.pWaitSemaphores = &semaphore; |
| 3880 | submit_info.pWaitDstStageMask = flags; |
| 3881 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3882 | } |
| 3883 | |
| 3884 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3885 | |
| 3886 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3887 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3888 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3889 | &command_buffer[0]); |
| 3890 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3891 | |
| 3892 | m_errorMonitor->VerifyNotFound(); |
| 3893 | } |
| 3894 | |
| 3895 | // This is a positive test. No errors should be generated. |
| 3896 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3897 | |
| 3898 | TEST_DESCRIPTION( |
| 3899 | "Two command buffers, each in a separate QueueSubmit call " |
| 3900 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3901 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3902 | |
| 3903 | m_errorMonitor->ExpectSuccess(); |
| 3904 | |
| 3905 | VkFence fence; |
| 3906 | VkFenceCreateInfo fence_create_info{}; |
| 3907 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3908 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3909 | |
| 3910 | VkCommandPool command_pool; |
| 3911 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3912 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3913 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3914 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3915 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3916 | &command_pool); |
| 3917 | |
| 3918 | VkCommandBuffer command_buffer[2]; |
| 3919 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3920 | command_buffer_allocate_info.sType = |
| 3921 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3922 | command_buffer_allocate_info.commandPool = command_pool; |
| 3923 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3924 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3925 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3926 | command_buffer); |
| 3927 | |
| 3928 | { |
| 3929 | VkCommandBufferBeginInfo begin_info{}; |
| 3930 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3931 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3932 | |
| 3933 | vkCmdPipelineBarrier(command_buffer[0], |
| 3934 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3935 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3936 | 0, nullptr, 0, nullptr); |
| 3937 | |
| 3938 | VkViewport viewport{}; |
| 3939 | viewport.maxDepth = 1.0f; |
| 3940 | viewport.minDepth = 0.0f; |
| 3941 | viewport.width = 512; |
| 3942 | viewport.height = 512; |
| 3943 | viewport.x = 0; |
| 3944 | viewport.y = 0; |
| 3945 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3946 | vkEndCommandBuffer(command_buffer[0]); |
| 3947 | } |
| 3948 | { |
| 3949 | VkCommandBufferBeginInfo begin_info{}; |
| 3950 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3951 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3952 | |
| 3953 | VkViewport viewport{}; |
| 3954 | viewport.maxDepth = 1.0f; |
| 3955 | viewport.minDepth = 0.0f; |
| 3956 | viewport.width = 512; |
| 3957 | viewport.height = 512; |
| 3958 | viewport.x = 0; |
| 3959 | viewport.y = 0; |
| 3960 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3961 | vkEndCommandBuffer(command_buffer[1]); |
| 3962 | } |
| 3963 | { |
| 3964 | VkSubmitInfo submit_info{}; |
| 3965 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3966 | submit_info.commandBufferCount = 1; |
| 3967 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3968 | submit_info.signalSemaphoreCount = 0; |
| 3969 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3970 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3971 | } |
| 3972 | { |
| 3973 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3974 | VkSubmitInfo submit_info{}; |
| 3975 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3976 | submit_info.commandBufferCount = 1; |
| 3977 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3978 | submit_info.waitSemaphoreCount = 0; |
| 3979 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3980 | submit_info.pWaitDstStageMask = flags; |
| 3981 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3982 | } |
| 3983 | |
| 3984 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3985 | |
| 3986 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3987 | |
| 3988 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3989 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3990 | &command_buffer[0]); |
| 3991 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3992 | |
| 3993 | m_errorMonitor->VerifyNotFound(); |
| 3994 | } |
| 3995 | |
| 3996 | // This is a positive test. No errors should be generated. |
| 3997 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3998 | |
| 3999 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4000 | "on the same queue, the second having a fence, followed " |
| 4001 | "by a WaitForFences call."); |
| 4002 | |
| 4003 | m_errorMonitor->ExpectSuccess(); |
| 4004 | |
| 4005 | VkFence fence; |
| 4006 | VkFenceCreateInfo fence_create_info{}; |
| 4007 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4008 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4009 | |
| 4010 | VkCommandPool command_pool; |
| 4011 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4012 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4013 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4014 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4015 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4016 | &command_pool); |
| 4017 | |
| 4018 | VkCommandBuffer command_buffer[2]; |
| 4019 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4020 | command_buffer_allocate_info.sType = |
| 4021 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4022 | command_buffer_allocate_info.commandPool = command_pool; |
| 4023 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4024 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4025 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4026 | command_buffer); |
| 4027 | |
| 4028 | { |
| 4029 | VkCommandBufferBeginInfo begin_info{}; |
| 4030 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4031 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4032 | |
| 4033 | vkCmdPipelineBarrier(command_buffer[0], |
| 4034 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4035 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4036 | 0, nullptr, 0, nullptr); |
| 4037 | |
| 4038 | VkViewport viewport{}; |
| 4039 | viewport.maxDepth = 1.0f; |
| 4040 | viewport.minDepth = 0.0f; |
| 4041 | viewport.width = 512; |
| 4042 | viewport.height = 512; |
| 4043 | viewport.x = 0; |
| 4044 | viewport.y = 0; |
| 4045 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4046 | vkEndCommandBuffer(command_buffer[0]); |
| 4047 | } |
| 4048 | { |
| 4049 | VkCommandBufferBeginInfo begin_info{}; |
| 4050 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4051 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4052 | |
| 4053 | VkViewport viewport{}; |
| 4054 | viewport.maxDepth = 1.0f; |
| 4055 | viewport.minDepth = 0.0f; |
| 4056 | viewport.width = 512; |
| 4057 | viewport.height = 512; |
| 4058 | viewport.x = 0; |
| 4059 | viewport.y = 0; |
| 4060 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4061 | vkEndCommandBuffer(command_buffer[1]); |
| 4062 | } |
| 4063 | { |
| 4064 | VkSubmitInfo submit_info{}; |
| 4065 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4066 | submit_info.commandBufferCount = 1; |
| 4067 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4068 | submit_info.signalSemaphoreCount = 0; |
| 4069 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4070 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4071 | } |
| 4072 | { |
| 4073 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4074 | VkSubmitInfo submit_info{}; |
| 4075 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4076 | submit_info.commandBufferCount = 1; |
| 4077 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4078 | submit_info.waitSemaphoreCount = 0; |
| 4079 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4080 | submit_info.pWaitDstStageMask = flags; |
| 4081 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4082 | } |
| 4083 | |
| 4084 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4085 | |
| 4086 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4087 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4088 | &command_buffer[0]); |
| 4089 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4090 | |
| 4091 | m_errorMonitor->VerifyNotFound(); |
| 4092 | } |
| 4093 | |
| 4094 | // This is a positive test. No errors should be generated. |
| 4095 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 4096 | |
| 4097 | TEST_DESCRIPTION( |
| 4098 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 4099 | "QueueSubmit call followed by a WaitForFences call."); |
| 4100 | |
| 4101 | m_errorMonitor->ExpectSuccess(); |
| 4102 | |
| 4103 | VkFence fence; |
| 4104 | VkFenceCreateInfo fence_create_info{}; |
| 4105 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4106 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4107 | |
| 4108 | VkSemaphore semaphore; |
| 4109 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4110 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4111 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4112 | &semaphore); |
| 4113 | |
| 4114 | VkCommandPool command_pool; |
| 4115 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4116 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4117 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4118 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4119 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4120 | &command_pool); |
| 4121 | |
| 4122 | VkCommandBuffer command_buffer[2]; |
| 4123 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4124 | command_buffer_allocate_info.sType = |
| 4125 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4126 | command_buffer_allocate_info.commandPool = command_pool; |
| 4127 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4128 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4129 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4130 | command_buffer); |
| 4131 | |
| 4132 | { |
| 4133 | VkCommandBufferBeginInfo begin_info{}; |
| 4134 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4135 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4136 | |
| 4137 | vkCmdPipelineBarrier(command_buffer[0], |
| 4138 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4139 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4140 | 0, nullptr, 0, nullptr); |
| 4141 | |
| 4142 | VkViewport viewport{}; |
| 4143 | viewport.maxDepth = 1.0f; |
| 4144 | viewport.minDepth = 0.0f; |
| 4145 | viewport.width = 512; |
| 4146 | viewport.height = 512; |
| 4147 | viewport.x = 0; |
| 4148 | viewport.y = 0; |
| 4149 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4150 | vkEndCommandBuffer(command_buffer[0]); |
| 4151 | } |
| 4152 | { |
| 4153 | VkCommandBufferBeginInfo begin_info{}; |
| 4154 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4155 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4156 | |
| 4157 | VkViewport viewport{}; |
| 4158 | viewport.maxDepth = 1.0f; |
| 4159 | viewport.minDepth = 0.0f; |
| 4160 | viewport.width = 512; |
| 4161 | viewport.height = 512; |
| 4162 | viewport.x = 0; |
| 4163 | viewport.y = 0; |
| 4164 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4165 | vkEndCommandBuffer(command_buffer[1]); |
| 4166 | } |
| 4167 | { |
| 4168 | VkSubmitInfo submit_info[2]; |
| 4169 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4170 | |
| 4171 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4172 | submit_info[0].pNext = NULL; |
| 4173 | submit_info[0].commandBufferCount = 1; |
| 4174 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 4175 | submit_info[0].signalSemaphoreCount = 1; |
| 4176 | submit_info[0].pSignalSemaphores = &semaphore; |
| 4177 | submit_info[0].waitSemaphoreCount = 0; |
| 4178 | submit_info[0].pWaitSemaphores = NULL; |
| 4179 | submit_info[0].pWaitDstStageMask = 0; |
| 4180 | |
| 4181 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4182 | submit_info[1].pNext = NULL; |
| 4183 | submit_info[1].commandBufferCount = 1; |
| 4184 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 4185 | submit_info[1].waitSemaphoreCount = 1; |
| 4186 | submit_info[1].pWaitSemaphores = &semaphore; |
| 4187 | submit_info[1].pWaitDstStageMask = flags; |
| 4188 | submit_info[1].signalSemaphoreCount = 0; |
| 4189 | submit_info[1].pSignalSemaphores = NULL; |
| 4190 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 4191 | } |
| 4192 | |
| 4193 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4194 | |
| 4195 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4196 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4197 | &command_buffer[0]); |
| 4198 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4199 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4200 | |
| 4201 | m_errorMonitor->VerifyNotFound(); |
| 4202 | } |
| 4203 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4204 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4205 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4206 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 4207 | "state is required but not correctly bound."); |
| 4208 | |
| 4209 | // Dynamic depth bias |
| 4210 | m_errorMonitor->SetDesiredFailureMsg( |
| 4211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4212 | "Dynamic depth bias state not set for this command buffer"); |
| 4213 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4214 | BsoFailDepthBias); |
| 4215 | m_errorMonitor->VerifyFound(); |
| 4216 | } |
| 4217 | |
| 4218 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 4219 | TEST_DESCRIPTION( |
| 4220 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 4221 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4222 | |
| 4223 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4224 | m_errorMonitor->SetDesiredFailureMsg( |
| 4225 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4226 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4227 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4228 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4229 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4230 | } |
| 4231 | |
| 4232 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 4233 | TEST_DESCRIPTION( |
| 4234 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 4235 | "state is required but not correctly bound."); |
| 4236 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4237 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4238 | m_errorMonitor->SetDesiredFailureMsg( |
| 4239 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4240 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4242 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4243 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4244 | } |
| 4245 | |
| 4246 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 4247 | TEST_DESCRIPTION( |
| 4248 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 4249 | "state is required but not correctly bound."); |
| 4250 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4251 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4252 | m_errorMonitor->SetDesiredFailureMsg( |
| 4253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4254 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4255 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4256 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4257 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4258 | } |
| 4259 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4260 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4261 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4262 | "Run a simple draw calls to validate failure when Blend Constants " |
| 4263 | "dynamic state is required but not correctly bound."); |
| 4264 | // Dynamic blend constant state |
| 4265 | m_errorMonitor->SetDesiredFailureMsg( |
| 4266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4267 | "Dynamic blend constants state not set for this command buffer"); |
| 4268 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4269 | BsoFailBlend); |
| 4270 | m_errorMonitor->VerifyFound(); |
| 4271 | } |
| 4272 | |
| 4273 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 4274 | TEST_DESCRIPTION( |
| 4275 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4276 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4277 | if (!m_device->phy().features().depthBounds) { |
| 4278 | printf("Device does not support depthBounds test; skipped.\n"); |
| 4279 | return; |
| 4280 | } |
| 4281 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4282 | m_errorMonitor->SetDesiredFailureMsg( |
| 4283 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4284 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4285 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4286 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4287 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4288 | } |
| 4289 | |
| 4290 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4291 | TEST_DESCRIPTION( |
| 4292 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4293 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4294 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4295 | m_errorMonitor->SetDesiredFailureMsg( |
| 4296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4297 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4298 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4299 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4300 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4301 | } |
| 4302 | |
| 4303 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4304 | TEST_DESCRIPTION( |
| 4305 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4306 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4307 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4308 | m_errorMonitor->SetDesiredFailureMsg( |
| 4309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4310 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4311 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4312 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4313 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4314 | } |
| 4315 | |
| 4316 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4317 | TEST_DESCRIPTION( |
| 4318 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4319 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4320 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | m_errorMonitor->SetDesiredFailureMsg( |
| 4322 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4323 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4324 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4325 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4326 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4327 | } |
| 4328 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4329 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4330 | m_errorMonitor->SetDesiredFailureMsg( |
| 4331 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4332 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4333 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4334 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4336 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4337 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4339 | // We luck out b/c by default the framework creates CB w/ the |
| 4340 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4341 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4342 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4343 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4344 | EndCommandBuffer(); |
| 4345 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4346 | // Bypass framework since it does the waits automatically |
| 4347 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4348 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4349 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4350 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4351 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4352 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4353 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4354 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4355 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4356 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4357 | submit_info.pSignalSemaphores = NULL; |
| 4358 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4359 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4362 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4363 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4364 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4365 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4366 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4367 | } |
| 4368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4369 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4370 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4371 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4372 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4373 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4374 | "Unable to allocate 1 descriptors of " |
| 4375 | "type " |
| 4376 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4377 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4378 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4379 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4381 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4382 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4383 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4384 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4385 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4386 | |
| 4387 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4388 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4389 | ds_pool_ci.pNext = NULL; |
| 4390 | ds_pool_ci.flags = 0; |
| 4391 | ds_pool_ci.maxSets = 1; |
| 4392 | ds_pool_ci.poolSizeCount = 1; |
| 4393 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4394 | |
| 4395 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4396 | err = |
| 4397 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4398 | ASSERT_VK_SUCCESS(err); |
| 4399 | |
| 4400 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4401 | dsl_binding.binding = 0; |
| 4402 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4403 | dsl_binding.descriptorCount = 1; |
| 4404 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4405 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4406 | |
| 4407 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4408 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4409 | ds_layout_ci.pNext = NULL; |
| 4410 | ds_layout_ci.bindingCount = 1; |
| 4411 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4412 | |
| 4413 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4414 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4415 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4416 | ASSERT_VK_SUCCESS(err); |
| 4417 | |
| 4418 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4419 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4420 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4421 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4422 | alloc_info.descriptorPool = ds_pool; |
| 4423 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4424 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4425 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4426 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4427 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4428 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4429 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4430 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4431 | } |
| 4432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4433 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4434 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4436 | m_errorMonitor->SetDesiredFailureMsg( |
| 4437 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4438 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4439 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4440 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4442 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4443 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4444 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4445 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4446 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4447 | |
| 4448 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4449 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4450 | ds_pool_ci.pNext = NULL; |
| 4451 | ds_pool_ci.maxSets = 1; |
| 4452 | ds_pool_ci.poolSizeCount = 1; |
| 4453 | ds_pool_ci.flags = 0; |
| 4454 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4455 | // app can only call vkResetDescriptorPool on this pool.; |
| 4456 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4457 | |
| 4458 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4459 | err = |
| 4460 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4461 | ASSERT_VK_SUCCESS(err); |
| 4462 | |
| 4463 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4464 | dsl_binding.binding = 0; |
| 4465 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4466 | dsl_binding.descriptorCount = 1; |
| 4467 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4468 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4469 | |
| 4470 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4471 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4472 | ds_layout_ci.pNext = NULL; |
| 4473 | ds_layout_ci.bindingCount = 1; |
| 4474 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4475 | |
| 4476 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4478 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4479 | ASSERT_VK_SUCCESS(err); |
| 4480 | |
| 4481 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4482 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4483 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4484 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4485 | alloc_info.descriptorPool = ds_pool; |
| 4486 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4487 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4488 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4489 | ASSERT_VK_SUCCESS(err); |
| 4490 | |
| 4491 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4492 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4493 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4494 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4495 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4496 | } |
| 4497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4498 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4499 | // Attempt to clear Descriptor Pool with bad object. |
| 4500 | // ObjectTracker should catch this. |
| 4501 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4502 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4503 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4504 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4505 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4506 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4507 | } |
| 4508 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4510 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4511 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4512 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4513 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4514 | |
| 4515 | uint64_t fake_set_handle = 0xbaad6001; |
| 4516 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4517 | VkResult err; |
| 4518 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4519 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4520 | |
| 4521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4522 | |
| 4523 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4524 | layout_bindings[0].binding = 0; |
| 4525 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4526 | layout_bindings[0].descriptorCount = 1; |
| 4527 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4528 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4529 | |
| 4530 | VkDescriptorSetLayout descriptor_set_layout; |
| 4531 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4532 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4533 | dslci.pNext = NULL; |
| 4534 | dslci.bindingCount = 1; |
| 4535 | dslci.pBindings = layout_bindings; |
| 4536 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4537 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4538 | |
| 4539 | VkPipelineLayout pipeline_layout; |
| 4540 | VkPipelineLayoutCreateInfo plci = {}; |
| 4541 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4542 | plci.pNext = NULL; |
| 4543 | plci.setLayoutCount = 1; |
| 4544 | plci.pSetLayouts = &descriptor_set_layout; |
| 4545 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4546 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4547 | |
| 4548 | BeginCommandBuffer(); |
| 4549 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4550 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4551 | m_errorMonitor->VerifyFound(); |
| 4552 | EndCommandBuffer(); |
| 4553 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4554 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4555 | } |
| 4556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4557 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4558 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4559 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4560 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4561 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4562 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4563 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4564 | |
| 4565 | VkPipelineLayout pipeline_layout; |
| 4566 | VkPipelineLayoutCreateInfo plci = {}; |
| 4567 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4568 | plci.pNext = NULL; |
| 4569 | plci.setLayoutCount = 1; |
| 4570 | plci.pSetLayouts = &bad_layout; |
| 4571 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4572 | |
| 4573 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4574 | } |
| 4575 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4576 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
| 4577 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " |
| 4578 | "1) A uniform buffer update must have a valid buffer index." |
| 4579 | "2) When using an array of descriptors in a single WriteDescriptor," |
| 4580 | " the descriptor types and stageflags must all be the same." |
| 4581 | "3) Immutable Sampler state must match across descriptors"); |
| 4582 | |
| 4583 | const char *invalid_BufferInfo_ErrorMessage = |
| 4584 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " |
| 4585 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " |
| 4586 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; |
| 4587 | const char *stateFlag_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4588 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4589 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4590 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4591 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4592 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
| 4593 | |
| 4594 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4595 | VkDescriptorPoolSize ds_type_count[4] = {}; |
| 4596 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4597 | ds_type_count[0].descriptorCount = 1; |
| 4598 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4599 | ds_type_count[1].descriptorCount = 1; |
| 4600 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4601 | ds_type_count[2].descriptorCount = 1; |
| 4602 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4603 | ds_type_count[3].descriptorCount = 1; |
| 4604 | |
| 4605 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4606 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4607 | ds_pool_ci.maxSets = 1; |
| 4608 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); |
| 4609 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 4610 | |
| 4611 | VkDescriptorPool ds_pool; |
| 4612 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4613 | ASSERT_VK_SUCCESS(err); |
| 4614 | |
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4615 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4616 | layout_binding[0].binding = 0; |
| 4617 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4618 | layout_binding[0].descriptorCount = 1; |
| 4619 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4620 | layout_binding[0].pImmutableSamplers = NULL; |
| 4621 | |
| 4622 | layout_binding[1].binding = 1; |
| 4623 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4624 | layout_binding[1].descriptorCount = 1; |
| 4625 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 4626 | layout_binding[1].pImmutableSamplers = NULL; |
| 4627 | |
| 4628 | VkSamplerCreateInfo sampler_ci = {}; |
| 4629 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4630 | sampler_ci.pNext = NULL; |
| 4631 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4632 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4633 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4634 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4635 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4636 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4637 | sampler_ci.mipLodBias = 1.0; |
| 4638 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4639 | sampler_ci.maxAnisotropy = 1; |
| 4640 | sampler_ci.compareEnable = VK_FALSE; |
| 4641 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4642 | sampler_ci.minLod = 1.0; |
| 4643 | sampler_ci.maxLod = 1.0; |
| 4644 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4645 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 4646 | VkSampler sampler; |
| 4647 | |
| 4648 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 4649 | ASSERT_VK_SUCCESS(err); |
| 4650 | |
| 4651 | layout_binding[2].binding = 2; |
| 4652 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4653 | layout_binding[2].descriptorCount = 1; |
| 4654 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 4655 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); |
| 4656 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4657 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4658 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4659 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); |
| 4660 | ds_layout_ci.pBindings = layout_binding; |
| 4661 | VkDescriptorSetLayout ds_layout; |
| 4662 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 4663 | ASSERT_VK_SUCCESS(err); |
| 4664 | |
| 4665 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4666 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4667 | alloc_info.descriptorSetCount = 1; |
| 4668 | alloc_info.descriptorPool = ds_pool; |
| 4669 | alloc_info.pSetLayouts = &ds_layout; |
| 4670 | VkDescriptorSet descriptorSet; |
| 4671 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 4672 | ASSERT_VK_SUCCESS(err); |
| 4673 | |
| 4674 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4675 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4676 | pipeline_layout_ci.pNext = NULL; |
| 4677 | pipeline_layout_ci.setLayoutCount = 1; |
| 4678 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4679 | |
| 4680 | VkPipelineLayout pipeline_layout; |
| 4681 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 4682 | ASSERT_VK_SUCCESS(err); |
| 4683 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4684 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4685 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4686 | descriptor_write.dstSet = descriptorSet; |
| 4687 | descriptor_write.dstBinding = 0; |
| 4688 | descriptor_write.descriptorCount = 1; |
| 4689 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4690 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4691 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4692 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4693 | m_errorMonitor->VerifyFound(); |
| 4694 | |
| 4695 | // Create a buffer to update the descriptor with |
| 4696 | uint32_t qfi = 0; |
| 4697 | VkBufferCreateInfo buffCI = {}; |
| 4698 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4699 | buffCI.size = 1024; |
| 4700 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4701 | buffCI.queueFamilyIndexCount = 1; |
| 4702 | buffCI.pQueueFamilyIndices = &qfi; |
| 4703 | |
| 4704 | VkBuffer dyub; |
| 4705 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4706 | ASSERT_VK_SUCCESS(err); |
| 4707 | VkDescriptorBufferInfo buffInfo = {}; |
| 4708 | buffInfo.buffer = dyub; |
| 4709 | buffInfo.offset = 0; |
| 4710 | buffInfo.range = 1024; |
| 4711 | |
| 4712 | descriptor_write.pBufferInfo = &buffInfo; |
| 4713 | descriptor_write.descriptorCount = 2; |
| 4714 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4715 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4716 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
| 4717 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4718 | m_errorMonitor->VerifyFound(); |
| 4719 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4720 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
| 4721 | // the third descriptor contains an immutable sampler |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4722 | descriptor_write.dstBinding = 1; |
| 4723 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4724 | |
| 4725 | |
| 4726 | // Make pImageInfo index non-null to avoid complaints of it missing |
| 4727 | VkDescriptorImageInfo imageInfo = {}; |
| 4728 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4729 | descriptor_write.pImageInfo = &imageInfo; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4730 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
| 4731 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4732 | m_errorMonitor->VerifyFound(); |
| 4733 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4734 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4735 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4736 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4737 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4738 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4739 | } |
| 4740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4741 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4742 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4743 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4744 | // Create a valid cmd buffer |
| 4745 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4746 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4747 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4748 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4749 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4751 | BeginCommandBuffer(); |
| 4752 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4753 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4754 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4755 | // Now issue a draw call with no pipeline bound |
| 4756 | m_errorMonitor->SetDesiredFailureMsg( |
| 4757 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4758 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4759 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4760 | BeginCommandBuffer(); |
| 4761 | Draw(1, 0, 0, 0); |
| 4762 | m_errorMonitor->VerifyFound(); |
| 4763 | // Finally same check once more but with Dispatch/Compute |
| 4764 | m_errorMonitor->SetDesiredFailureMsg( |
| 4765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4766 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4767 | BeginCommandBuffer(); |
| 4768 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4769 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4770 | } |
| 4771 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4772 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4773 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4774 | // CommandBuffer |
| 4775 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4776 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4777 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4778 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4779 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4781 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4782 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4783 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4784 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4785 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4786 | |
| 4787 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4788 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4789 | ds_pool_ci.pNext = NULL; |
| 4790 | ds_pool_ci.maxSets = 1; |
| 4791 | ds_pool_ci.poolSizeCount = 1; |
| 4792 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4793 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4794 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4795 | err = |
| 4796 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4797 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4798 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4799 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4800 | dsl_binding.binding = 0; |
| 4801 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4802 | dsl_binding.descriptorCount = 1; |
| 4803 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4804 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4805 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4806 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4807 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4808 | ds_layout_ci.pNext = NULL; |
| 4809 | ds_layout_ci.bindingCount = 1; |
| 4810 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4811 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4812 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4813 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4814 | ASSERT_VK_SUCCESS(err); |
| 4815 | |
| 4816 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4817 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4818 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4819 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4820 | alloc_info.descriptorPool = ds_pool; |
| 4821 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4822 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4823 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4824 | ASSERT_VK_SUCCESS(err); |
| 4825 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4826 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4827 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4828 | pipeline_layout_ci.pNext = NULL; |
| 4829 | pipeline_layout_ci.setLayoutCount = 1; |
| 4830 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4831 | |
| 4832 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4833 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4834 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4835 | ASSERT_VK_SUCCESS(err); |
| 4836 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4837 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4838 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4839 | // 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] | 4840 | // on more devices |
| 4841 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4842 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4843 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4844 | VkPipelineObj pipe(m_device); |
| 4845 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4846 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4847 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4848 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4849 | |
| 4850 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4851 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4852 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4853 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4854 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4855 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4856 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4857 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4858 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4859 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4860 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4861 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4862 | } |
| 4863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4864 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4865 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4866 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4868 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4870 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4871 | |
| 4872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4873 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4875 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4876 | |
| 4877 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4878 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4879 | ds_pool_ci.pNext = NULL; |
| 4880 | ds_pool_ci.maxSets = 1; |
| 4881 | ds_pool_ci.poolSizeCount = 1; |
| 4882 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4883 | |
| 4884 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4885 | err = |
| 4886 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4887 | ASSERT_VK_SUCCESS(err); |
| 4888 | |
| 4889 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4890 | dsl_binding.binding = 0; |
| 4891 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4892 | dsl_binding.descriptorCount = 1; |
| 4893 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4894 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4895 | |
| 4896 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4897 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4898 | ds_layout_ci.pNext = NULL; |
| 4899 | ds_layout_ci.bindingCount = 1; |
| 4900 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4901 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4902 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4903 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4904 | ASSERT_VK_SUCCESS(err); |
| 4905 | |
| 4906 | VkDescriptorSet descriptorSet; |
| 4907 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4908 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4909 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4910 | alloc_info.descriptorPool = ds_pool; |
| 4911 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4912 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4913 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4914 | ASSERT_VK_SUCCESS(err); |
| 4915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4916 | VkBufferView view = |
| 4917 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4918 | VkWriteDescriptorSet descriptor_write; |
| 4919 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4920 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4921 | descriptor_write.dstSet = descriptorSet; |
| 4922 | descriptor_write.dstBinding = 0; |
| 4923 | descriptor_write.descriptorCount = 1; |
| 4924 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4925 | descriptor_write.pTexelBufferView = &view; |
| 4926 | |
| 4927 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4928 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4929 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4930 | |
| 4931 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4932 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4933 | } |
| 4934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4935 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4936 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4937 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4938 | // 1. No dynamicOffset supplied |
| 4939 | // 2. Too many dynamicOffsets supplied |
| 4940 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4941 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4943 | " requires 1 dynamicOffsets, but only " |
| 4944 | "0 dynamicOffsets are left in " |
| 4945 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4946 | |
| 4947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4948 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4949 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4950 | |
| 4951 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4952 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4953 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4954 | |
| 4955 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4956 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4957 | ds_pool_ci.pNext = NULL; |
| 4958 | ds_pool_ci.maxSets = 1; |
| 4959 | ds_pool_ci.poolSizeCount = 1; |
| 4960 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4961 | |
| 4962 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4963 | err = |
| 4964 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4965 | ASSERT_VK_SUCCESS(err); |
| 4966 | |
| 4967 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4968 | dsl_binding.binding = 0; |
| 4969 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4970 | dsl_binding.descriptorCount = 1; |
| 4971 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4972 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4973 | |
| 4974 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4975 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4976 | ds_layout_ci.pNext = NULL; |
| 4977 | ds_layout_ci.bindingCount = 1; |
| 4978 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4979 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4980 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4981 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4982 | ASSERT_VK_SUCCESS(err); |
| 4983 | |
| 4984 | VkDescriptorSet descriptorSet; |
| 4985 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4986 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4987 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4988 | alloc_info.descriptorPool = ds_pool; |
| 4989 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4990 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4991 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4992 | ASSERT_VK_SUCCESS(err); |
| 4993 | |
| 4994 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4995 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4996 | pipeline_layout_ci.pNext = NULL; |
| 4997 | pipeline_layout_ci.setLayoutCount = 1; |
| 4998 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4999 | |
| 5000 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5001 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5002 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5003 | ASSERT_VK_SUCCESS(err); |
| 5004 | |
| 5005 | // Create a buffer to update the descriptor with |
| 5006 | uint32_t qfi = 0; |
| 5007 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5009 | buffCI.size = 1024; |
| 5010 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5011 | buffCI.queueFamilyIndexCount = 1; |
| 5012 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5013 | |
| 5014 | VkBuffer dyub; |
| 5015 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5016 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5017 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 5018 | // error |
| 5019 | VkMemoryAllocateInfo mem_alloc = {}; |
| 5020 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5021 | mem_alloc.pNext = NULL; |
| 5022 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 5023 | mem_alloc.memoryTypeIndex = 0; |
| 5024 | |
| 5025 | VkMemoryRequirements memReqs; |
| 5026 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 5027 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 5028 | 0); |
| 5029 | if (!pass) { |
| 5030 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5031 | return; |
| 5032 | } |
| 5033 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5034 | VkDeviceMemory mem; |
| 5035 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 5036 | ASSERT_VK_SUCCESS(err); |
| 5037 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 5038 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5039 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5040 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5041 | buffInfo.buffer = dyub; |
| 5042 | buffInfo.offset = 0; |
| 5043 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5044 | |
| 5045 | VkWriteDescriptorSet descriptor_write; |
| 5046 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5047 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5048 | descriptor_write.dstSet = descriptorSet; |
| 5049 | descriptor_write.dstBinding = 0; |
| 5050 | descriptor_write.descriptorCount = 1; |
| 5051 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5052 | descriptor_write.pBufferInfo = &buffInfo; |
| 5053 | |
| 5054 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5055 | |
| 5056 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5057 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5058 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5059 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5060 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5061 | uint32_t pDynOff[2] = {512, 756}; |
| 5062 | // 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] | 5063 | m_errorMonitor->SetDesiredFailureMsg( |
| 5064 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5065 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5066 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5067 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5068 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5069 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5070 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5071 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5072 | " dynamic offset 512 combined with " |
| 5073 | "offset 0 and range 1024 that " |
| 5074 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5075 | // Create PSO to be used for draw-time errors below |
| 5076 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5077 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5078 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5079 | "out gl_PerVertex { \n" |
| 5080 | " vec4 gl_Position;\n" |
| 5081 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5082 | "void main(){\n" |
| 5083 | " gl_Position = vec4(1);\n" |
| 5084 | "}\n"; |
| 5085 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5086 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5087 | "\n" |
| 5088 | "layout(location=0) out vec4 x;\n" |
| 5089 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5090 | "void main(){\n" |
| 5091 | " x = vec4(bar.y);\n" |
| 5092 | "}\n"; |
| 5093 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5094 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5095 | VkPipelineObj pipe(m_device); |
| 5096 | pipe.AddShader(&vs); |
| 5097 | pipe.AddShader(&fs); |
| 5098 | pipe.AddColorAttachment(); |
| 5099 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 5100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5101 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5102 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5103 | // This update should succeed, but offset size of 512 will overstep buffer |
| 5104 | // /w range 1024 & size 1024 |
| 5105 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5106 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5107 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5108 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5109 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5110 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5111 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 5112 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5113 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5114 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5115 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5116 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5117 | } |
| 5118 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5119 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5120 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5122 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5123 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5124 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5125 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5126 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5127 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5128 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5129 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 5130 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 5131 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5132 | // |
| 5133 | // Check for invalid push constant ranges in pipeline layouts. |
| 5134 | // |
| 5135 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5136 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5137 | char const *msg; |
| 5138 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5139 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5140 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 5141 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 5142 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5143 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5144 | "size 0."}, |
| 5145 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5146 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5147 | "size 1."}, |
| 5148 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5149 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5150 | "size 1."}, |
| 5151 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5152 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5153 | "size 0."}, |
| 5154 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5155 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5156 | "offset 1. Offset must"}, |
| 5157 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 5158 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5159 | "with offset "}, |
| 5160 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 5161 | "vkCreatePipelineLayout() call has push constants " |
| 5162 | "index 0 with offset "}, |
| 5163 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 5164 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5165 | "with offset "}, |
| 5166 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 5167 | "vkCreatePipelineLayout() call has push " |
| 5168 | "constants index 0 with offset "}, |
| 5169 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 5170 | "vkCreatePipelineLayout() call has push " |
| 5171 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5172 | }}; |
| 5173 | |
| 5174 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5175 | for (const auto &iter : range_tests) { |
| 5176 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5177 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5178 | iter.msg); |
| 5179 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5180 | NULL, &pipeline_layout); |
| 5181 | m_errorMonitor->VerifyFound(); |
| 5182 | if (VK_SUCCESS == err) { |
| 5183 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5184 | } |
| 5185 | } |
| 5186 | |
| 5187 | // Check for invalid stage flag |
| 5188 | pc_range.offset = 0; |
| 5189 | pc_range.size = 16; |
| 5190 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5191 | m_errorMonitor->SetDesiredFailureMsg( |
| 5192 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5193 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5194 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5195 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5196 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5197 | if (VK_SUCCESS == err) { |
| 5198 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5199 | } |
| 5200 | |
| 5201 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5202 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5203 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5204 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5205 | char const *msg; |
| 5206 | }; |
| 5207 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5208 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5209 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5210 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5211 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5212 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5213 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5214 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 5215 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 5216 | { |
| 5217 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5218 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5219 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5220 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5221 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5222 | "vkCreatePipelineLayout() call has push constants with " |
| 5223 | "overlapping " |
| 5224 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 5225 | }, |
| 5226 | { |
| 5227 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5228 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5229 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5230 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5231 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5232 | "vkCreatePipelineLayout() call has push constants with " |
| 5233 | "overlapping " |
| 5234 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 5235 | }, |
| 5236 | { |
| 5237 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5238 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5239 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5240 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5241 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5242 | "vkCreatePipelineLayout() call has push constants with " |
| 5243 | "overlapping " |
| 5244 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 5245 | }, |
| 5246 | { |
| 5247 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5248 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 5249 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 5250 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 5251 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 5252 | "vkCreatePipelineLayout() call has push constants with " |
| 5253 | "overlapping " |
| 5254 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 5255 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5256 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5257 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5258 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5259 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 5260 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5261 | iter.msg); |
| 5262 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5263 | NULL, &pipeline_layout); |
| 5264 | m_errorMonitor->VerifyFound(); |
| 5265 | if (VK_SUCCESS == err) { |
| 5266 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5267 | } |
| 5268 | } |
| 5269 | |
| 5270 | // 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] | 5271 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 5272 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5273 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5274 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5275 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 5276 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5277 | ""}, |
| 5278 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 5279 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 5280 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 5281 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 5282 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5283 | ""}}}; |
| 5284 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5285 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 5286 | m_errorMonitor->ExpectSuccess(); |
| 5287 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5288 | NULL, &pipeline_layout); |
| 5289 | m_errorMonitor->VerifyNotFound(); |
| 5290 | if (VK_SUCCESS == err) { |
| 5291 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5292 | } |
| 5293 | } |
| 5294 | |
| 5295 | // |
| 5296 | // CmdPushConstants tests |
| 5297 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5298 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5299 | |
| 5300 | // 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] | 5301 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 5302 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5303 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 5304 | "must be greater than zero and a multiple of 4."}, |
| 5305 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5306 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5307 | "must be greater than zero and a multiple of 4."}, |
| 5308 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5309 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5310 | "must be greater than zero and a multiple of 4."}, |
| 5311 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5312 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5313 | "Offset must be a multiple of 4."}, |
| 5314 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5315 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5316 | "Offset must be a multiple of 4."}, |
| 5317 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5318 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5319 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5320 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 5321 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 5322 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5323 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 5324 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 5325 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5326 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 5327 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 5328 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5329 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 5330 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 5331 | "any of the ranges in pipeline layout"}, |
| 5332 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5333 | 0, 16}, |
| 5334 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 5335 | "any of the ranges in pipeline layout"}, |
| 5336 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5337 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5338 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5339 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5340 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5341 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5342 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5343 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5344 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5345 | "vkCmdPushConstants() call has push constants with offset "}, |
| 5346 | }}; |
| 5347 | |
| 5348 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5349 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5350 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5351 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5352 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5353 | pipeline_layout_ci.pushConstantRangeCount = |
| 5354 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5355 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5356 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5357 | &pipeline_layout); |
| 5358 | ASSERT_VK_SUCCESS(err); |
| 5359 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5360 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5361 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5362 | iter.msg); |
| 5363 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5364 | iter.range.stageFlags, iter.range.offset, |
| 5365 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5366 | m_errorMonitor->VerifyFound(); |
| 5367 | } |
| 5368 | |
| 5369 | // Check for invalid stage flag |
| 5370 | m_errorMonitor->SetDesiredFailureMsg( |
| 5371 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5372 | "vkCmdPushConstants() call has no stageFlags set."); |
| 5373 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5374 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5375 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5376 | EndCommandBuffer(); |
| 5377 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5378 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5379 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5380 | // overlapping range tests with cmd |
| 5381 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 5382 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5383 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5384 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5385 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5386 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 5387 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5388 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 5389 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 5390 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5391 | }}; |
| 5392 | const VkPushConstantRange pc_range3[] = { |
| 5393 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5394 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5395 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5396 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5397 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5398 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5399 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5400 | }; |
| 5401 | pipeline_layout_ci.pushConstantRangeCount = |
| 5402 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 5403 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 5404 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5405 | &pipeline_layout); |
| 5406 | ASSERT_VK_SUCCESS(err); |
| 5407 | BeginCommandBuffer(); |
| 5408 | for (const auto &iter : cmd_overlap_tests) { |
| 5409 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5410 | iter.msg); |
| 5411 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5412 | iter.range.stageFlags, iter.range.offset, |
| 5413 | iter.range.size, dummy_values); |
| 5414 | m_errorMonitor->VerifyFound(); |
| 5415 | } |
| 5416 | EndCommandBuffer(); |
| 5417 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5418 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5419 | |
| 5420 | // positive overlapping range tests with cmd |
| 5421 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 5422 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 5423 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 5424 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 5425 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 5426 | }}; |
| 5427 | const VkPushConstantRange pc_range4[] = { |
| 5428 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 5429 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5430 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5431 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5432 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5433 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5434 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5435 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5436 | }; |
| 5437 | pipeline_layout_ci.pushConstantRangeCount = |
| 5438 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 5439 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 5440 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5441 | &pipeline_layout); |
| 5442 | ASSERT_VK_SUCCESS(err); |
| 5443 | BeginCommandBuffer(); |
| 5444 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5445 | m_errorMonitor->ExpectSuccess(); |
| 5446 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5447 | iter.range.stageFlags, iter.range.offset, |
| 5448 | iter.range.size, dummy_values); |
| 5449 | m_errorMonitor->VerifyNotFound(); |
| 5450 | } |
| 5451 | EndCommandBuffer(); |
| 5452 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5453 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5454 | } |
| 5455 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5456 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5457 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5459 | |
| 5460 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5461 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5462 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5463 | |
| 5464 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5465 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5466 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5467 | ds_type_count[0].descriptorCount = 10; |
| 5468 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5469 | ds_type_count[1].descriptorCount = 2; |
| 5470 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5471 | ds_type_count[2].descriptorCount = 2; |
| 5472 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5473 | ds_type_count[3].descriptorCount = 5; |
| 5474 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5475 | // type |
| 5476 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5477 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5478 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5479 | |
| 5480 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5481 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5482 | ds_pool_ci.pNext = NULL; |
| 5483 | ds_pool_ci.maxSets = 5; |
| 5484 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5485 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5486 | |
| 5487 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5488 | err = |
| 5489 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5490 | ASSERT_VK_SUCCESS(err); |
| 5491 | |
| 5492 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5493 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5494 | dsl_binding[0].binding = 0; |
| 5495 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5496 | dsl_binding[0].descriptorCount = 5; |
| 5497 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5498 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5499 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5500 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5501 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5502 | dsl_fs_stage_only.binding = 0; |
| 5503 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5504 | dsl_fs_stage_only.descriptorCount = 5; |
| 5505 | dsl_fs_stage_only.stageFlags = |
| 5506 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5507 | // bind time |
| 5508 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5509 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5510 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5511 | ds_layout_ci.pNext = NULL; |
| 5512 | ds_layout_ci.bindingCount = 1; |
| 5513 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5514 | static const uint32_t NUM_LAYOUTS = 4; |
| 5515 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5516 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5517 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5518 | // layout for error case |
| 5519 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5520 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5521 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5522 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5523 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5524 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5525 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5526 | dsl_binding[0].binding = 0; |
| 5527 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5528 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5529 | dsl_binding[1].binding = 1; |
| 5530 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5531 | dsl_binding[1].descriptorCount = 2; |
| 5532 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5533 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5534 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5535 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5536 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5537 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5538 | ASSERT_VK_SUCCESS(err); |
| 5539 | dsl_binding[0].binding = 0; |
| 5540 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5541 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5542 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5543 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5544 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5545 | ASSERT_VK_SUCCESS(err); |
| 5546 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5547 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5548 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5549 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5550 | ASSERT_VK_SUCCESS(err); |
| 5551 | |
| 5552 | static const uint32_t NUM_SETS = 4; |
| 5553 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5554 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5555 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5556 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5557 | alloc_info.descriptorPool = ds_pool; |
| 5558 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5559 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5560 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5561 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5562 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5563 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5564 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5565 | err = |
| 5566 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5567 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5568 | |
| 5569 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5571 | pipeline_layout_ci.pNext = NULL; |
| 5572 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5573 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5574 | |
| 5575 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5576 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5577 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5578 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5579 | // Create pipelineLayout with only one setLayout |
| 5580 | pipeline_layout_ci.setLayoutCount = 1; |
| 5581 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5582 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5583 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5584 | ASSERT_VK_SUCCESS(err); |
| 5585 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5586 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5587 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5588 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5589 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5590 | ASSERT_VK_SUCCESS(err); |
| 5591 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5592 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5593 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5594 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5595 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5596 | ASSERT_VK_SUCCESS(err); |
| 5597 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5598 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5599 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5601 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5602 | ASSERT_VK_SUCCESS(err); |
| 5603 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5604 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5605 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5606 | pl_bad_s0[1] = ds_layout[1]; |
| 5607 | pipeline_layout_ci.setLayoutCount = 2; |
| 5608 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5609 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5610 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5611 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5612 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5613 | |
| 5614 | // Create a buffer to update the descriptor with |
| 5615 | uint32_t qfi = 0; |
| 5616 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5617 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5618 | buffCI.size = 1024; |
| 5619 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5620 | buffCI.queueFamilyIndexCount = 1; |
| 5621 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5622 | |
| 5623 | VkBuffer dyub; |
| 5624 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5625 | ASSERT_VK_SUCCESS(err); |
| 5626 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5627 | static const uint32_t NUM_BUFFS = 5; |
| 5628 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5629 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5630 | buffInfo[i].buffer = dyub; |
| 5631 | buffInfo[i].offset = 0; |
| 5632 | buffInfo[i].range = 1024; |
| 5633 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | VkImage image; |
| 5635 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5636 | const int32_t tex_width = 32; |
| 5637 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5638 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5639 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5640 | image_create_info.pNext = NULL; |
| 5641 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5642 | image_create_info.format = tex_format; |
| 5643 | image_create_info.extent.width = tex_width; |
| 5644 | image_create_info.extent.height = tex_height; |
| 5645 | image_create_info.extent.depth = 1; |
| 5646 | image_create_info.mipLevels = 1; |
| 5647 | image_create_info.arrayLayers = 1; |
| 5648 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5649 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5650 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5651 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5652 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5653 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5655 | VkMemoryRequirements memReqs; |
| 5656 | VkDeviceMemory imageMem; |
| 5657 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5658 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5660 | memAlloc.pNext = NULL; |
| 5661 | memAlloc.allocationSize = 0; |
| 5662 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5663 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5664 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5665 | pass = |
| 5666 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5667 | ASSERT_TRUE(pass); |
| 5668 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5669 | ASSERT_VK_SUCCESS(err); |
| 5670 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5671 | ASSERT_VK_SUCCESS(err); |
| 5672 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5673 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5674 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5675 | image_view_create_info.image = image; |
| 5676 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5677 | image_view_create_info.format = tex_format; |
| 5678 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5679 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5680 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5681 | image_view_create_info.subresourceRange.aspectMask = |
| 5682 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5683 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5684 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5685 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5686 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5687 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5688 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5689 | imageInfo[0].imageView = view; |
| 5690 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5691 | imageInfo[1].imageView = view; |
| 5692 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5693 | imageInfo[2].imageView = view; |
| 5694 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5695 | imageInfo[3].imageView = view; |
| 5696 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5697 | |
| 5698 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5699 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5700 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5701 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5702 | descriptor_write[0].dstBinding = 0; |
| 5703 | descriptor_write[0].descriptorCount = 5; |
| 5704 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5705 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5706 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5707 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5708 | descriptor_write[1].dstBinding = 0; |
| 5709 | descriptor_write[1].descriptorCount = 2; |
| 5710 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5711 | descriptor_write[1].pImageInfo = imageInfo; |
| 5712 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5713 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5714 | descriptor_write[2].dstBinding = 1; |
| 5715 | descriptor_write[2].descriptorCount = 2; |
| 5716 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5717 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5718 | |
| 5719 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5720 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5721 | // Create PSO to be used for draw-time errors below |
| 5722 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5723 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5724 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5725 | "out gl_PerVertex {\n" |
| 5726 | " vec4 gl_Position;\n" |
| 5727 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5728 | "void main(){\n" |
| 5729 | " gl_Position = vec4(1);\n" |
| 5730 | "}\n"; |
| 5731 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5732 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5733 | "\n" |
| 5734 | "layout(location=0) out vec4 x;\n" |
| 5735 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5736 | "void main(){\n" |
| 5737 | " x = vec4(bar.y);\n" |
| 5738 | "}\n"; |
| 5739 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5740 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5741 | VkPipelineObj pipe(m_device); |
| 5742 | pipe.AddShader(&vs); |
| 5743 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5744 | pipe.AddColorAttachment(); |
| 5745 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5746 | |
| 5747 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5748 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5749 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5750 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5751 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5752 | // of PSO |
| 5753 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5754 | // cmd_pipeline.c |
| 5755 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5756 | // cmd_bind_graphics_pipeline() |
| 5757 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5758 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5759 | // First cause various verify_layout_compatibility() fails |
| 5760 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5761 | // verify_set_layout_compatibility fail cases: |
| 5762 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5763 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5764 | " due to: invalid VkPipelineLayout "); |
| 5765 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5766 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5767 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5768 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5769 | m_errorMonitor->VerifyFound(); |
| 5770 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5771 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5772 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5773 | " attempting to bind set to index 1"); |
| 5774 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5775 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5776 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5777 | m_errorMonitor->VerifyFound(); |
| 5778 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5779 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5780 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5781 | // descriptors |
| 5782 | m_errorMonitor->SetDesiredFailureMsg( |
| 5783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5784 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5785 | vkCmdBindDescriptorSets( |
| 5786 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5787 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5788 | m_errorMonitor->VerifyFound(); |
| 5789 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5790 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5791 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | m_errorMonitor->SetDesiredFailureMsg( |
| 5793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5794 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5795 | vkCmdBindDescriptorSets( |
| 5796 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5797 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5798 | m_errorMonitor->VerifyFound(); |
| 5799 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5800 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5801 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5802 | m_errorMonitor->SetDesiredFailureMsg( |
| 5803 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5804 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5805 | vkCmdBindDescriptorSets( |
| 5806 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5807 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5808 | m_errorMonitor->VerifyFound(); |
| 5809 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5810 | // Cause INFO messages due to disturbing previously bound Sets |
| 5811 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5812 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5813 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5814 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5815 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5816 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5817 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5818 | " previously bound as set #0 was disturbed "); |
| 5819 | vkCmdBindDescriptorSets( |
| 5820 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5821 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5822 | m_errorMonitor->VerifyFound(); |
| 5823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5824 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5825 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5826 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5827 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5828 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5829 | " newly bound as set #0 so set #1 and " |
| 5830 | "any subsequent sets were disturbed "); |
| 5831 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5832 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5833 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5834 | m_errorMonitor->VerifyFound(); |
| 5835 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5836 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | // 1. Error due to not binding required set (we actually use same code as |
| 5838 | // above to disturb set0) |
| 5839 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5840 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5841 | 2, &descriptorSet[0], 0, NULL); |
| 5842 | vkCmdBindDescriptorSets( |
| 5843 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5844 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5845 | m_errorMonitor->SetDesiredFailureMsg( |
| 5846 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5847 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5848 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5849 | m_errorMonitor->VerifyFound(); |
| 5850 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5851 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | // 2. Error due to bound set not being compatible with PSO's |
| 5853 | // VkPipelineLayout (diff stageFlags in this case) |
| 5854 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5855 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5856 | 2, &descriptorSet[0], 0, NULL); |
| 5857 | m_errorMonitor->SetDesiredFailureMsg( |
| 5858 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5859 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5860 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5861 | m_errorMonitor->VerifyFound(); |
| 5862 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5863 | // Remaining clean-up |
| 5864 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5865 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5866 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5867 | } |
| 5868 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5869 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5870 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5871 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5872 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5873 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5874 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 5875 | vkDestroyImage(m_device->device(), image, NULL); |
| 5876 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5877 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5878 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5879 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | m_errorMonitor->SetDesiredFailureMsg( |
| 5882 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5883 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5884 | |
| 5885 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5886 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5887 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5888 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5890 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5891 | } |
| 5892 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5893 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5894 | VkResult err; |
| 5895 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5896 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5897 | m_errorMonitor->SetDesiredFailureMsg( |
| 5898 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5899 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5900 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5901 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5902 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5903 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5904 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5905 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5906 | cmd.commandPool = m_commandPool; |
| 5907 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5908 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5909 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5910 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5911 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5912 | |
| 5913 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5914 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5915 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5916 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5917 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5918 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5919 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5920 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5921 | |
| 5922 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5923 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5924 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5925 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5926 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5927 | } |
| 5928 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5929 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5930 | // Cause error due to Begin while recording CB |
| 5931 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5932 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5933 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5934 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5935 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5936 | |
| 5937 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5938 | |
| 5939 | // Calls AllocateCommandBuffers |
| 5940 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5942 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5943 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5944 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5945 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5946 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5947 | cmd_buf_info.pNext = NULL; |
| 5948 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5949 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5950 | |
| 5951 | // Begin CB to transition to recording state |
| 5952 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5953 | // Can't re-begin. This should trigger error |
| 5954 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5955 | m_errorMonitor->VerifyFound(); |
| 5956 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5958 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5959 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5960 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5961 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5962 | m_errorMonitor->VerifyFound(); |
| 5963 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5964 | m_errorMonitor->SetDesiredFailureMsg( |
| 5965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5966 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5967 | // Transition CB to RECORDED state |
| 5968 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5969 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5970 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5971 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5972 | } |
| 5973 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5974 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5975 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | m_errorMonitor->SetDesiredFailureMsg( |
| 5979 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5980 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5981 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5983 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5984 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5985 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5986 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5987 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5988 | |
| 5989 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5990 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5991 | ds_pool_ci.pNext = NULL; |
| 5992 | ds_pool_ci.maxSets = 1; |
| 5993 | ds_pool_ci.poolSizeCount = 1; |
| 5994 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5995 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5996 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5997 | err = |
| 5998 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5999 | ASSERT_VK_SUCCESS(err); |
| 6000 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6001 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6002 | dsl_binding.binding = 0; |
| 6003 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6004 | dsl_binding.descriptorCount = 1; |
| 6005 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6006 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6007 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6008 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6009 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6010 | ds_layout_ci.pNext = NULL; |
| 6011 | ds_layout_ci.bindingCount = 1; |
| 6012 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6013 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6014 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6015 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6016 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6017 | ASSERT_VK_SUCCESS(err); |
| 6018 | |
| 6019 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6020 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6021 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6022 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6023 | alloc_info.descriptorPool = ds_pool; |
| 6024 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6025 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6026 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6027 | ASSERT_VK_SUCCESS(err); |
| 6028 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6029 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6030 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6031 | pipeline_layout_ci.setLayoutCount = 1; |
| 6032 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6033 | |
| 6034 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6036 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6037 | ASSERT_VK_SUCCESS(err); |
| 6038 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6039 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6040 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6041 | |
| 6042 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6043 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6044 | vp_state_ci.scissorCount = 1; |
| 6045 | vp_state_ci.pScissors = ≻ |
| 6046 | vp_state_ci.viewportCount = 1; |
| 6047 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6048 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6049 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6050 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6051 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6052 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6053 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6054 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6055 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6056 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6057 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6058 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6059 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6060 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6061 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6062 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6063 | gp_ci.layout = pipeline_layout; |
| 6064 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6065 | |
| 6066 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6068 | pc_ci.initialDataSize = 0; |
| 6069 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6070 | |
| 6071 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6072 | VkPipelineCache pipelineCache; |
| 6073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6074 | err = |
| 6075 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6076 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6077 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6078 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6079 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6080 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6081 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6082 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6083 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6084 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6085 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6086 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6087 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 6088 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 6089 | { |
| 6090 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6091 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6092 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6093 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6094 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 6095 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6096 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6098 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6099 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6100 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6101 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6102 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6103 | |
| 6104 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6105 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6106 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6107 | ds_pool_ci.poolSizeCount = 1; |
| 6108 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6109 | |
| 6110 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6111 | err = vkCreateDescriptorPool(m_device->device(), |
| 6112 | 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] | 6113 | ASSERT_VK_SUCCESS(err); |
| 6114 | |
| 6115 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6116 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6117 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6118 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6119 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6120 | dsl_binding.pImmutableSamplers = NULL; |
| 6121 | |
| 6122 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6123 | ds_layout_ci.sType = |
| 6124 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6125 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6126 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6127 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6128 | |
| 6129 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6130 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6131 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6132 | ASSERT_VK_SUCCESS(err); |
| 6133 | |
| 6134 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 6136 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6137 | ASSERT_VK_SUCCESS(err); |
| 6138 | |
| 6139 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6140 | pipeline_layout_ci.sType = |
| 6141 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6142 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6143 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6144 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6145 | |
| 6146 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6147 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6148 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6149 | ASSERT_VK_SUCCESS(err); |
| 6150 | |
| 6151 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 6152 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6154 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 6155 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6156 | // 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] | 6157 | VkShaderObj |
| 6158 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 6159 | this); |
| 6160 | VkShaderObj |
| 6161 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 6162 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6164 | shaderStages[0].sType = |
| 6165 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6166 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6167 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6168 | shaderStages[1].sType = |
| 6169 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6170 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6171 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6172 | shaderStages[2].sType = |
| 6173 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6174 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6175 | shaderStages[2].shader = te.handle(); |
| 6176 | |
| 6177 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6178 | iaCI.sType = |
| 6179 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6180 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6181 | |
| 6182 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 6183 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 6184 | tsCI.patchControlPoints = 0; // This will cause an error |
| 6185 | |
| 6186 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6187 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6188 | gp_ci.pNext = NULL; |
| 6189 | gp_ci.stageCount = 3; |
| 6190 | gp_ci.pStages = shaderStages; |
| 6191 | gp_ci.pVertexInputState = NULL; |
| 6192 | gp_ci.pInputAssemblyState = &iaCI; |
| 6193 | gp_ci.pTessellationState = &tsCI; |
| 6194 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6195 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6196 | gp_ci.pMultisampleState = NULL; |
| 6197 | gp_ci.pDepthStencilState = NULL; |
| 6198 | gp_ci.pColorBlendState = NULL; |
| 6199 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6200 | gp_ci.layout = pipeline_layout; |
| 6201 | gp_ci.renderPass = renderPass(); |
| 6202 | |
| 6203 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6204 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6205 | pc_ci.pNext = NULL; |
| 6206 | pc_ci.initialSize = 0; |
| 6207 | pc_ci.initialData = 0; |
| 6208 | pc_ci.maxSize = 0; |
| 6209 | |
| 6210 | VkPipeline pipeline; |
| 6211 | VkPipelineCache pipelineCache; |
| 6212 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6213 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 6214 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6215 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6216 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6217 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6218 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6219 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6220 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6221 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6222 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6223 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6224 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6225 | } |
| 6226 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6227 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6228 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6229 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6231 | m_errorMonitor->SetDesiredFailureMsg( |
| 6232 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6233 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 6234 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6235 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6236 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6237 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6238 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6239 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6240 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6241 | |
| 6242 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6243 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6244 | ds_pool_ci.maxSets = 1; |
| 6245 | ds_pool_ci.poolSizeCount = 1; |
| 6246 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6247 | |
| 6248 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6249 | err = |
| 6250 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6251 | ASSERT_VK_SUCCESS(err); |
| 6252 | |
| 6253 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6254 | dsl_binding.binding = 0; |
| 6255 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6256 | dsl_binding.descriptorCount = 1; |
| 6257 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6258 | |
| 6259 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6260 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6261 | ds_layout_ci.bindingCount = 1; |
| 6262 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6263 | |
| 6264 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6265 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6266 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6267 | ASSERT_VK_SUCCESS(err); |
| 6268 | |
| 6269 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6270 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6271 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6272 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6273 | alloc_info.descriptorPool = ds_pool; |
| 6274 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6275 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6276 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6277 | ASSERT_VK_SUCCESS(err); |
| 6278 | |
| 6279 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6280 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6281 | pipeline_layout_ci.setLayoutCount = 1; |
| 6282 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6283 | |
| 6284 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6285 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6286 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6287 | ASSERT_VK_SUCCESS(err); |
| 6288 | |
| 6289 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6290 | |
| 6291 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6292 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6293 | vp_state_ci.scissorCount = 0; |
| 6294 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 6295 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6296 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6297 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6298 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6299 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6300 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6301 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6302 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6303 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6304 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6305 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6306 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6307 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6309 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6310 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6311 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6312 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6313 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6314 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6315 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6316 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6317 | |
| 6318 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6319 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6320 | gp_ci.stageCount = 2; |
| 6321 | gp_ci.pStages = shaderStages; |
| 6322 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6323 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6324 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6325 | gp_ci.layout = pipeline_layout; |
| 6326 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6327 | |
| 6328 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6329 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6330 | |
| 6331 | VkPipeline pipeline; |
| 6332 | VkPipelineCache pipelineCache; |
| 6333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6334 | err = |
| 6335 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6336 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6337 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6338 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6339 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6340 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6341 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6342 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6343 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6344 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6345 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6346 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6347 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 6348 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6349 | // 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] | 6350 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6351 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6352 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6353 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | m_errorMonitor->SetDesiredFailureMsg( |
| 6355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6356 | "Gfx Pipeline pViewportState is null. Even if "); |
| 6357 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6360 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6361 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6362 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6363 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6364 | |
| 6365 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6366 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6367 | ds_pool_ci.maxSets = 1; |
| 6368 | ds_pool_ci.poolSizeCount = 1; |
| 6369 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6370 | |
| 6371 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6372 | err = |
| 6373 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6374 | ASSERT_VK_SUCCESS(err); |
| 6375 | |
| 6376 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6377 | dsl_binding.binding = 0; |
| 6378 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6379 | dsl_binding.descriptorCount = 1; |
| 6380 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6381 | |
| 6382 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6383 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6384 | ds_layout_ci.bindingCount = 1; |
| 6385 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6386 | |
| 6387 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6388 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6389 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6390 | ASSERT_VK_SUCCESS(err); |
| 6391 | |
| 6392 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6393 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6394 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6395 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6396 | alloc_info.descriptorPool = ds_pool; |
| 6397 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6398 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6399 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6400 | ASSERT_VK_SUCCESS(err); |
| 6401 | |
| 6402 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6403 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6404 | pipeline_layout_ci.setLayoutCount = 1; |
| 6405 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6406 | |
| 6407 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6408 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6409 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6410 | ASSERT_VK_SUCCESS(err); |
| 6411 | |
| 6412 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6413 | // Set scissor as dynamic to avoid second error |
| 6414 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6415 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6416 | dyn_state_ci.dynamicStateCount = 1; |
| 6417 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6418 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6419 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6420 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6422 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6423 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6424 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6425 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6426 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6427 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6428 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6429 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6430 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6431 | |
| 6432 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6433 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6434 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6435 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6436 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6437 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6438 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6439 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6440 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6441 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6442 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6443 | gp_ci.stageCount = 2; |
| 6444 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6445 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6446 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6447 | // should cause validation error |
| 6448 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6449 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6450 | gp_ci.layout = pipeline_layout; |
| 6451 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6452 | |
| 6453 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6454 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6455 | |
| 6456 | VkPipeline pipeline; |
| 6457 | VkPipelineCache pipelineCache; |
| 6458 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6459 | err = |
| 6460 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6461 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6462 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6463 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6464 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6465 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6466 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6467 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6468 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6469 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6470 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6471 | } |
| 6472 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6473 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6474 | // count |
| 6475 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6476 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | m_errorMonitor->SetDesiredFailureMsg( |
| 6479 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6480 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6481 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6482 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6483 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6484 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6485 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6486 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6487 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6488 | |
| 6489 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6490 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6491 | ds_pool_ci.maxSets = 1; |
| 6492 | ds_pool_ci.poolSizeCount = 1; |
| 6493 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6494 | |
| 6495 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6496 | err = |
| 6497 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6498 | ASSERT_VK_SUCCESS(err); |
| 6499 | |
| 6500 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6501 | dsl_binding.binding = 0; |
| 6502 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6503 | dsl_binding.descriptorCount = 1; |
| 6504 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6505 | |
| 6506 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6507 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6508 | ds_layout_ci.bindingCount = 1; |
| 6509 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6510 | |
| 6511 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6513 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6514 | ASSERT_VK_SUCCESS(err); |
| 6515 | |
| 6516 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6517 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6518 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6519 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6520 | alloc_info.descriptorPool = ds_pool; |
| 6521 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6522 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6523 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6524 | ASSERT_VK_SUCCESS(err); |
| 6525 | |
| 6526 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6527 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6528 | pipeline_layout_ci.setLayoutCount = 1; |
| 6529 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6530 | |
| 6531 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6532 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6533 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6534 | ASSERT_VK_SUCCESS(err); |
| 6535 | |
| 6536 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6537 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6538 | vp_state_ci.viewportCount = 1; |
| 6539 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6540 | vp_state_ci.scissorCount = 1; |
| 6541 | vp_state_ci.pScissors = |
| 6542 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6543 | |
| 6544 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6545 | // Set scissor as dynamic to avoid that error |
| 6546 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6547 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6548 | dyn_state_ci.dynamicStateCount = 1; |
| 6549 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6550 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6551 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6552 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6553 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6554 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6555 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6556 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6557 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6558 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6559 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6560 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6561 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6562 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6563 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6564 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6565 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6566 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6567 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6568 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6569 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6570 | |
| 6571 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6572 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6573 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6574 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6575 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6576 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6577 | rs_ci.pNext = nullptr; |
| 6578 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6579 | VkPipelineColorBlendAttachmentState att = {}; |
| 6580 | att.blendEnable = VK_FALSE; |
| 6581 | att.colorWriteMask = 0xf; |
| 6582 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6583 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6584 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6585 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6586 | cb_ci.attachmentCount = 1; |
| 6587 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6588 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6589 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6590 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6591 | gp_ci.stageCount = 2; |
| 6592 | gp_ci.pStages = shaderStages; |
| 6593 | gp_ci.pVertexInputState = &vi_ci; |
| 6594 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6595 | gp_ci.pViewportState = &vp_state_ci; |
| 6596 | gp_ci.pRasterizationState = &rs_ci; |
| 6597 | gp_ci.pColorBlendState = &cb_ci; |
| 6598 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6599 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6600 | gp_ci.layout = pipeline_layout; |
| 6601 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6602 | |
| 6603 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6604 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6605 | |
| 6606 | VkPipeline pipeline; |
| 6607 | VkPipelineCache pipelineCache; |
| 6608 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6609 | err = |
| 6610 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6611 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6612 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6613 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6614 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6615 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6616 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6617 | // 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] | 6618 | // First need to successfully create the PSO from above by setting |
| 6619 | // pViewports |
| 6620 | m_errorMonitor->SetDesiredFailureMsg( |
| 6621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6622 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6623 | "scissorCount is 1. These counts must match."); |
| 6624 | |
| 6625 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6626 | vp_state_ci.pViewports = &vp; |
| 6627 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6628 | &gp_ci, NULL, &pipeline); |
| 6629 | ASSERT_VK_SUCCESS(err); |
| 6630 | BeginCommandBuffer(); |
| 6631 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6632 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6633 | VkRect2D scissors[2] = {}; // don't care about data |
| 6634 | // Count of 2 doesn't match PSO count of 1 |
| 6635 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6636 | Draw(1, 0, 0, 0); |
| 6637 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6638 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6639 | |
| 6640 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6641 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6642 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6643 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6644 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6645 | } |
| 6646 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6647 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6648 | // viewportCount |
| 6649 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6650 | VkResult err; |
| 6651 | |
| 6652 | m_errorMonitor->SetDesiredFailureMsg( |
| 6653 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6654 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6655 | |
| 6656 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6657 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6658 | |
| 6659 | VkDescriptorPoolSize ds_type_count = {}; |
| 6660 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6661 | ds_type_count.descriptorCount = 1; |
| 6662 | |
| 6663 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6664 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6665 | ds_pool_ci.maxSets = 1; |
| 6666 | ds_pool_ci.poolSizeCount = 1; |
| 6667 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6668 | |
| 6669 | VkDescriptorPool ds_pool; |
| 6670 | err = |
| 6671 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6672 | ASSERT_VK_SUCCESS(err); |
| 6673 | |
| 6674 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6675 | dsl_binding.binding = 0; |
| 6676 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6677 | dsl_binding.descriptorCount = 1; |
| 6678 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6679 | |
| 6680 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6681 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6682 | ds_layout_ci.bindingCount = 1; |
| 6683 | ds_layout_ci.pBindings = &dsl_binding; |
| 6684 | |
| 6685 | VkDescriptorSetLayout ds_layout; |
| 6686 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6687 | &ds_layout); |
| 6688 | ASSERT_VK_SUCCESS(err); |
| 6689 | |
| 6690 | VkDescriptorSet descriptorSet; |
| 6691 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6692 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6693 | alloc_info.descriptorSetCount = 1; |
| 6694 | alloc_info.descriptorPool = ds_pool; |
| 6695 | alloc_info.pSetLayouts = &ds_layout; |
| 6696 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6697 | &descriptorSet); |
| 6698 | ASSERT_VK_SUCCESS(err); |
| 6699 | |
| 6700 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6701 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6702 | pipeline_layout_ci.setLayoutCount = 1; |
| 6703 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6704 | |
| 6705 | VkPipelineLayout pipeline_layout; |
| 6706 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6707 | &pipeline_layout); |
| 6708 | ASSERT_VK_SUCCESS(err); |
| 6709 | |
| 6710 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6711 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6712 | vp_state_ci.scissorCount = 1; |
| 6713 | vp_state_ci.pScissors = |
| 6714 | NULL; // Null scissor w/ count of 1 should cause error |
| 6715 | vp_state_ci.viewportCount = 1; |
| 6716 | vp_state_ci.pViewports = |
| 6717 | NULL; // vp is dynamic (below) so this won't cause error |
| 6718 | |
| 6719 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6720 | // Set scissor as dynamic to avoid that error |
| 6721 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6722 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6723 | dyn_state_ci.dynamicStateCount = 1; |
| 6724 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6725 | |
| 6726 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6727 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6728 | |
| 6729 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6730 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6731 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6732 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6733 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6734 | // but add it to be able to run on more devices |
| 6735 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6736 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6737 | |
| 6738 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6739 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6740 | vi_ci.pNext = nullptr; |
| 6741 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6742 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6743 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6744 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6745 | |
| 6746 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6747 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6748 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6749 | |
| 6750 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6751 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6752 | rs_ci.pNext = nullptr; |
| 6753 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6754 | VkPipelineColorBlendAttachmentState att = {}; |
| 6755 | att.blendEnable = VK_FALSE; |
| 6756 | att.colorWriteMask = 0xf; |
| 6757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6758 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6759 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6760 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6761 | cb_ci.attachmentCount = 1; |
| 6762 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6763 | |
| 6764 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6765 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6766 | gp_ci.stageCount = 2; |
| 6767 | gp_ci.pStages = shaderStages; |
| 6768 | gp_ci.pVertexInputState = &vi_ci; |
| 6769 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6770 | gp_ci.pViewportState = &vp_state_ci; |
| 6771 | gp_ci.pRasterizationState = &rs_ci; |
| 6772 | gp_ci.pColorBlendState = &cb_ci; |
| 6773 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6774 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6775 | gp_ci.layout = pipeline_layout; |
| 6776 | gp_ci.renderPass = renderPass(); |
| 6777 | |
| 6778 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6779 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6780 | |
| 6781 | VkPipeline pipeline; |
| 6782 | VkPipelineCache pipelineCache; |
| 6783 | |
| 6784 | err = |
| 6785 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6786 | ASSERT_VK_SUCCESS(err); |
| 6787 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6788 | &gp_ci, NULL, &pipeline); |
| 6789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6790 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6791 | |
| 6792 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6793 | // First need to successfully create the PSO from above by setting |
| 6794 | // pViewports |
| 6795 | m_errorMonitor->SetDesiredFailureMsg( |
| 6796 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6797 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6798 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6799 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6800 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6801 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6802 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6803 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6804 | ASSERT_VK_SUCCESS(err); |
| 6805 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6806 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6807 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6808 | VkViewport viewports[2] = {}; // don't care about data |
| 6809 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6810 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6811 | Draw(1, 0, 0, 0); |
| 6812 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6813 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6814 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6815 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6816 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6817 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6818 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6819 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6820 | } |
| 6821 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6822 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6823 | VkResult err; |
| 6824 | |
| 6825 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6826 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6827 | |
| 6828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6829 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6830 | |
| 6831 | VkDescriptorPoolSize ds_type_count = {}; |
| 6832 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6833 | ds_type_count.descriptorCount = 1; |
| 6834 | |
| 6835 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6836 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6837 | ds_pool_ci.maxSets = 1; |
| 6838 | ds_pool_ci.poolSizeCount = 1; |
| 6839 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6840 | |
| 6841 | VkDescriptorPool ds_pool; |
| 6842 | err = |
| 6843 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6844 | ASSERT_VK_SUCCESS(err); |
| 6845 | |
| 6846 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6847 | dsl_binding.binding = 0; |
| 6848 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6849 | dsl_binding.descriptorCount = 1; |
| 6850 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6851 | |
| 6852 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6853 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6854 | ds_layout_ci.bindingCount = 1; |
| 6855 | ds_layout_ci.pBindings = &dsl_binding; |
| 6856 | |
| 6857 | VkDescriptorSetLayout ds_layout; |
| 6858 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6859 | &ds_layout); |
| 6860 | ASSERT_VK_SUCCESS(err); |
| 6861 | |
| 6862 | VkDescriptorSet descriptorSet; |
| 6863 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6864 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6865 | alloc_info.descriptorSetCount = 1; |
| 6866 | alloc_info.descriptorPool = ds_pool; |
| 6867 | alloc_info.pSetLayouts = &ds_layout; |
| 6868 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6869 | &descriptorSet); |
| 6870 | ASSERT_VK_SUCCESS(err); |
| 6871 | |
| 6872 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6873 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6874 | pipeline_layout_ci.setLayoutCount = 1; |
| 6875 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6876 | |
| 6877 | VkPipelineLayout pipeline_layout; |
| 6878 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6879 | &pipeline_layout); |
| 6880 | ASSERT_VK_SUCCESS(err); |
| 6881 | |
| 6882 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6883 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6884 | vp_state_ci.scissorCount = 1; |
| 6885 | vp_state_ci.pScissors = NULL; |
| 6886 | vp_state_ci.viewportCount = 1; |
| 6887 | vp_state_ci.pViewports = NULL; |
| 6888 | |
| 6889 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6890 | VK_DYNAMIC_STATE_SCISSOR, |
| 6891 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6892 | // Set scissor as dynamic to avoid that error |
| 6893 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6894 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6895 | dyn_state_ci.dynamicStateCount = 2; |
| 6896 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6897 | |
| 6898 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6899 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6900 | |
| 6901 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6902 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6903 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6904 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6905 | this); // TODO - We shouldn't need a fragment shader |
| 6906 | // but add it to be able to run on more devices |
| 6907 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6908 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6909 | |
| 6910 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6911 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6912 | vi_ci.pNext = nullptr; |
| 6913 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6914 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6915 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6916 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6917 | |
| 6918 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6919 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6920 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6921 | |
| 6922 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6923 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6924 | rs_ci.pNext = nullptr; |
| 6925 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6926 | // Check too low (line width of -1.0f). |
| 6927 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6928 | |
| 6929 | VkPipelineColorBlendAttachmentState att = {}; |
| 6930 | att.blendEnable = VK_FALSE; |
| 6931 | att.colorWriteMask = 0xf; |
| 6932 | |
| 6933 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6934 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6935 | cb_ci.pNext = nullptr; |
| 6936 | cb_ci.attachmentCount = 1; |
| 6937 | cb_ci.pAttachments = &att; |
| 6938 | |
| 6939 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6940 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6941 | gp_ci.stageCount = 2; |
| 6942 | gp_ci.pStages = shaderStages; |
| 6943 | gp_ci.pVertexInputState = &vi_ci; |
| 6944 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6945 | gp_ci.pViewportState = &vp_state_ci; |
| 6946 | gp_ci.pRasterizationState = &rs_ci; |
| 6947 | gp_ci.pColorBlendState = &cb_ci; |
| 6948 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6949 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6950 | gp_ci.layout = pipeline_layout; |
| 6951 | gp_ci.renderPass = renderPass(); |
| 6952 | |
| 6953 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6954 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6955 | |
| 6956 | VkPipeline pipeline; |
| 6957 | VkPipelineCache pipelineCache; |
| 6958 | |
| 6959 | err = |
| 6960 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6961 | ASSERT_VK_SUCCESS(err); |
| 6962 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6963 | &gp_ci, NULL, &pipeline); |
| 6964 | |
| 6965 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6966 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6967 | |
| 6968 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6969 | "Attempt to set lineWidth to 65536"); |
| 6970 | |
| 6971 | // Check too high (line width of 65536.0f). |
| 6972 | rs_ci.lineWidth = 65536.0f; |
| 6973 | |
| 6974 | err = |
| 6975 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6976 | ASSERT_VK_SUCCESS(err); |
| 6977 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6978 | &gp_ci, NULL, &pipeline); |
| 6979 | |
| 6980 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6981 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6982 | |
| 6983 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6984 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6985 | |
| 6986 | dyn_state_ci.dynamicStateCount = 3; |
| 6987 | |
| 6988 | rs_ci.lineWidth = 1.0f; |
| 6989 | |
| 6990 | err = |
| 6991 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6992 | ASSERT_VK_SUCCESS(err); |
| 6993 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6994 | &gp_ci, NULL, &pipeline); |
| 6995 | BeginCommandBuffer(); |
| 6996 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6997 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6998 | |
| 6999 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7000 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7001 | m_errorMonitor->VerifyFound(); |
| 7002 | |
| 7003 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7004 | "Attempt to set lineWidth to 65536"); |
| 7005 | |
| 7006 | // Check too high with dynamic setting. |
| 7007 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 7008 | m_errorMonitor->VerifyFound(); |
| 7009 | EndCommandBuffer(); |
| 7010 | |
| 7011 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7012 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7013 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7014 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7015 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7016 | } |
| 7017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7019 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7020 | m_errorMonitor->SetDesiredFailureMsg( |
| 7021 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7022 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7023 | |
| 7024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7025 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7026 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7027 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7028 | // Don't care about RenderPass handle b/c error should be flagged before |
| 7029 | // that |
| 7030 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 7031 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7033 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7034 | } |
| 7035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7036 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7037 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7038 | m_errorMonitor->SetDesiredFailureMsg( |
| 7039 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7040 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7041 | |
| 7042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7043 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7044 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7045 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7046 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 7047 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7048 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7049 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 7050 | rp_begin.pNext = NULL; |
| 7051 | rp_begin.renderPass = renderPass(); |
| 7052 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7054 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 7055 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7056 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7057 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7058 | } |
| 7059 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7060 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 7061 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 7062 | "the number of renderPass attachments that use loadOp" |
| 7063 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 7064 | |
| 7065 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7066 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7067 | |
| 7068 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 7069 | VkAttachmentReference attach = {}; |
| 7070 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7071 | VkSubpassDescription subpass = {}; |
| 7072 | subpass.inputAttachmentCount = 1; |
| 7073 | subpass.pInputAttachments = &attach; |
| 7074 | VkRenderPassCreateInfo rpci = {}; |
| 7075 | rpci.subpassCount = 1; |
| 7076 | rpci.pSubpasses = &subpass; |
| 7077 | rpci.attachmentCount = 1; |
| 7078 | VkAttachmentDescription attach_desc = {}; |
| 7079 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7080 | // Set loadOp to CLEAR |
| 7081 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 7082 | rpci.pAttachments = &attach_desc; |
| 7083 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 7084 | VkRenderPass rp; |
| 7085 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7086 | |
| 7087 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 7088 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 7089 | hinfo.renderPass = VK_NULL_HANDLE; |
| 7090 | hinfo.subpass = 0; |
| 7091 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 7092 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 7093 | hinfo.queryFlags = 0; |
| 7094 | hinfo.pipelineStatistics = 0; |
| 7095 | VkCommandBufferBeginInfo info = {}; |
| 7096 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 7097 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 7098 | info.pInheritanceInfo = &hinfo; |
| 7099 | |
| 7100 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 7101 | VkRenderPassBeginInfo rp_begin = {}; |
| 7102 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 7103 | rp_begin.pNext = NULL; |
| 7104 | rp_begin.renderPass = renderPass(); |
| 7105 | rp_begin.framebuffer = framebuffer(); |
| 7106 | rp_begin.clearValueCount = 0; // Should be 1 |
| 7107 | |
| 7108 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7109 | " has a clearValueCount of 0 but the " |
| 7110 | "actual number of attachments in " |
| 7111 | "renderPass "); |
| 7112 | |
| 7113 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 7114 | VK_SUBPASS_CONTENTS_INLINE); |
| 7115 | |
| 7116 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 7117 | |
| 7118 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7119 | } |
| 7120 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 7121 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 7122 | |
| 7123 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 7124 | |
| 7125 | m_errorMonitor->SetDesiredFailureMsg( |
| 7126 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7127 | "It is invalid to issue this call inside an active render pass"); |
| 7128 | |
| 7129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7130 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7131 | |
| 7132 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 7133 | BeginCommandBuffer(); |
| 7134 | |
| 7135 | // Call directly into vkEndCommandBuffer instead of the |
| 7136 | // the framework's EndCommandBuffer, which inserts a |
| 7137 | // vkEndRenderPass |
| 7138 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 7139 | |
| 7140 | m_errorMonitor->VerifyFound(); |
| 7141 | |
| 7142 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 7143 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 7144 | } |
| 7145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7146 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7147 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7148 | m_errorMonitor->SetDesiredFailureMsg( |
| 7149 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7150 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7151 | |
| 7152 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7153 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7154 | |
| 7155 | // Renderpass is started here |
| 7156 | BeginCommandBuffer(); |
| 7157 | |
| 7158 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7159 | vk_testing::Buffer dstBuffer; |
| 7160 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7161 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7162 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7163 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7164 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7165 | } |
| 7166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7167 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7168 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7169 | m_errorMonitor->SetDesiredFailureMsg( |
| 7170 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7171 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7172 | |
| 7173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7174 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7175 | |
| 7176 | // Renderpass is started here |
| 7177 | BeginCommandBuffer(); |
| 7178 | |
| 7179 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7180 | vk_testing::Buffer dstBuffer; |
| 7181 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7182 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7183 | VkDeviceSize dstOffset = 0; |
| 7184 | VkDeviceSize dataSize = 1024; |
| 7185 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7187 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 7188 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7189 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7190 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7191 | } |
| 7192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7193 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7194 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7195 | m_errorMonitor->SetDesiredFailureMsg( |
| 7196 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7197 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7198 | |
| 7199 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7200 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7201 | |
| 7202 | // Renderpass is started here |
| 7203 | BeginCommandBuffer(); |
| 7204 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 7205 | VkClearColorValue clear_color; |
| 7206 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7207 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7208 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7209 | const int32_t tex_width = 32; |
| 7210 | const int32_t tex_height = 32; |
| 7211 | VkImageCreateInfo image_create_info = {}; |
| 7212 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7213 | image_create_info.pNext = NULL; |
| 7214 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7215 | image_create_info.format = tex_format; |
| 7216 | image_create_info.extent.width = tex_width; |
| 7217 | image_create_info.extent.height = tex_height; |
| 7218 | image_create_info.extent.depth = 1; |
| 7219 | image_create_info.mipLevels = 1; |
| 7220 | image_create_info.arrayLayers = 1; |
| 7221 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7222 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7223 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7224 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7225 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7226 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7227 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7229 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7230 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7232 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7233 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7234 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7235 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7236 | } |
| 7237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7238 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7239 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7240 | m_errorMonitor->SetDesiredFailureMsg( |
| 7241 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7242 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7243 | |
| 7244 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7245 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7246 | |
| 7247 | // Renderpass is started here |
| 7248 | BeginCommandBuffer(); |
| 7249 | |
| 7250 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 7251 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7252 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 7253 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7254 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 7255 | image_create_info.extent.width = 64; |
| 7256 | image_create_info.extent.height = 64; |
| 7257 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7258 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7259 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7260 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7261 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7262 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7264 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7265 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7267 | vkCmdClearDepthStencilImage( |
| 7268 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7269 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 7270 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7271 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7272 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7273 | } |
| 7274 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7275 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7276 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7277 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7278 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7280 | "vkCmdClearAttachments: This call " |
| 7281 | "must be issued inside an active " |
| 7282 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7283 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7284 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7285 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7286 | |
| 7287 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7288 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7289 | ASSERT_VK_SUCCESS(err); |
| 7290 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7291 | VkClearAttachment color_attachment; |
| 7292 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7293 | color_attachment.clearValue.color.float32[0] = 0; |
| 7294 | color_attachment.clearValue.color.float32[1] = 0; |
| 7295 | color_attachment.clearValue.color.float32[2] = 0; |
| 7296 | color_attachment.clearValue.color.float32[3] = 0; |
| 7297 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7298 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 7299 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7300 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7301 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7302 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7303 | } |
| 7304 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 7305 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 7306 | // Try to add a buffer memory barrier with no buffer. |
| 7307 | m_errorMonitor->SetDesiredFailureMsg( |
| 7308 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7309 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 7310 | |
| 7311 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7312 | BeginCommandBuffer(); |
| 7313 | |
| 7314 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7315 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7316 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7317 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7318 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7319 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7320 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 7321 | buf_barrier.offset = 0; |
| 7322 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7323 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7324 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 7325 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 7326 | |
| 7327 | m_errorMonitor->VerifyFound(); |
| 7328 | } |
| 7329 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 7330 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 7331 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 7332 | |
| 7333 | m_errorMonitor->SetDesiredFailureMsg( |
| 7334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 7335 | |
| 7336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7337 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7338 | |
| 7339 | VkMemoryBarrier mem_barrier = {}; |
| 7340 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 7341 | mem_barrier.pNext = NULL; |
| 7342 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7343 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7344 | BeginCommandBuffer(); |
| 7345 | // BeginCommandBuffer() starts a render pass |
| 7346 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7347 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7348 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 7349 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 7350 | m_errorMonitor->VerifyFound(); |
| 7351 | |
| 7352 | m_errorMonitor->SetDesiredFailureMsg( |
| 7353 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7354 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 7355 | VkImageObj image(m_device); |
| 7356 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 7357 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 7358 | ASSERT_TRUE(image.initialized()); |
| 7359 | VkImageMemoryBarrier img_barrier = {}; |
| 7360 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 7361 | img_barrier.pNext = NULL; |
| 7362 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7363 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7364 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7365 | // New layout can't be UNDEFINED |
| 7366 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 7367 | img_barrier.image = image.handle(); |
| 7368 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7369 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7370 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7371 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7372 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7373 | img_barrier.subresourceRange.layerCount = 1; |
| 7374 | img_barrier.subresourceRange.levelCount = 1; |
| 7375 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7376 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7377 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7378 | nullptr, 1, &img_barrier); |
| 7379 | m_errorMonitor->VerifyFound(); |
| 7380 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7381 | |
| 7382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7383 | "Subresource must have the sum of the " |
| 7384 | "baseArrayLayer"); |
| 7385 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 7386 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 7387 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7388 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7389 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7390 | nullptr, 1, &img_barrier); |
| 7391 | m_errorMonitor->VerifyFound(); |
| 7392 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7393 | |
| 7394 | m_errorMonitor->SetDesiredFailureMsg( |
| 7395 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7396 | "Subresource must have the sum of the baseMipLevel"); |
| 7397 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 7398 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 7399 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7400 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7401 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7402 | nullptr, 1, &img_barrier); |
| 7403 | m_errorMonitor->VerifyFound(); |
| 7404 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7405 | |
| 7406 | m_errorMonitor->SetDesiredFailureMsg( |
| 7407 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7408 | "Buffer Barriers cannot be used during a render pass"); |
| 7409 | vk_testing::Buffer buffer; |
| 7410 | buffer.init(*m_device, 256); |
| 7411 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7412 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7413 | buf_barrier.pNext = NULL; |
| 7414 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7415 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7416 | buf_barrier.buffer = buffer.handle(); |
| 7417 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7418 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7419 | buf_barrier.offset = 0; |
| 7420 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7421 | // Can't send buffer barrier during a render pass |
| 7422 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7423 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7424 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7425 | &buf_barrier, 0, nullptr); |
| 7426 | m_errorMonitor->VerifyFound(); |
| 7427 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7428 | |
| 7429 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7430 | "which is not less than total size"); |
| 7431 | buf_barrier.offset = 257; |
| 7432 | // Offset greater than total size |
| 7433 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7434 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7435 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7436 | &buf_barrier, 0, nullptr); |
| 7437 | m_errorMonitor->VerifyFound(); |
| 7438 | buf_barrier.offset = 0; |
| 7439 | |
| 7440 | m_errorMonitor->SetDesiredFailureMsg( |
| 7441 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 7442 | buf_barrier.size = 257; |
| 7443 | // Size greater than total size |
| 7444 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7445 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7446 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7447 | &buf_barrier, 0, nullptr); |
| 7448 | m_errorMonitor->VerifyFound(); |
| 7449 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7450 | |
| 7451 | m_errorMonitor->SetDesiredFailureMsg( |
| 7452 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7453 | "Image is a depth and stencil format and thus must " |
| 7454 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7455 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7456 | VkDepthStencilObj ds_image(m_device); |
| 7457 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7458 | ASSERT_TRUE(ds_image.initialized()); |
| 7459 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7460 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7461 | img_barrier.image = ds_image.handle(); |
| 7462 | // Leave aspectMask at COLOR on purpose |
| 7463 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7464 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7465 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7466 | nullptr, 1, &img_barrier); |
| 7467 | m_errorMonitor->VerifyFound(); |
| 7468 | } |
| 7469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7470 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7471 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7472 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7473 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7474 | m_errorMonitor->SetDesiredFailureMsg( |
| 7475 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7476 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7477 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7478 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7480 | uint32_t qfi = 0; |
| 7481 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7482 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7483 | buffCI.size = 1024; |
| 7484 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7485 | buffCI.queueFamilyIndexCount = 1; |
| 7486 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7487 | |
| 7488 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7489 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7490 | ASSERT_VK_SUCCESS(err); |
| 7491 | |
| 7492 | BeginCommandBuffer(); |
| 7493 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7494 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7495 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7496 | // 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] | 7497 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7498 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7499 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7500 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7501 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7502 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7503 | } |
| 7504 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7505 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7506 | // Create an out-of-range queueFamilyIndex |
| 7507 | m_errorMonitor->SetDesiredFailureMsg( |
| 7508 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7509 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7510 | "of the indices specified when the device was created, via the " |
| 7511 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7512 | |
| 7513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7515 | VkBufferCreateInfo buffCI = {}; |
| 7516 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7517 | buffCI.size = 1024; |
| 7518 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7519 | buffCI.queueFamilyIndexCount = 1; |
| 7520 | // Introduce failure by specifying invalid queue_family_index |
| 7521 | uint32_t qfi = 777; |
| 7522 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7523 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7524 | |
| 7525 | VkBuffer ib; |
| 7526 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7527 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7528 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7529 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7530 | } |
| 7531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7532 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7533 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7534 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7535 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7536 | m_errorMonitor->SetDesiredFailureMsg( |
| 7537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7538 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7539 | |
| 7540 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7541 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7542 | |
| 7543 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7544 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7545 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7546 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7547 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7548 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7549 | } |
| 7550 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7551 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7552 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7553 | "that do not have correct usage bits sets."); |
| 7554 | VkResult err; |
| 7555 | |
| 7556 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7557 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7558 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7559 | ds_type_count[i].type = VkDescriptorType(i); |
| 7560 | ds_type_count[i].descriptorCount = 1; |
| 7561 | } |
| 7562 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7563 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7564 | ds_pool_ci.pNext = NULL; |
| 7565 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7566 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7567 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7568 | |
| 7569 | VkDescriptorPool ds_pool; |
| 7570 | err = |
| 7571 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7572 | ASSERT_VK_SUCCESS(err); |
| 7573 | |
| 7574 | // Create 10 layouts where each has a single descriptor of different type |
| 7575 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7576 | {}; |
| 7577 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7578 | dsl_binding[i].binding = 0; |
| 7579 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7580 | dsl_binding[i].descriptorCount = 1; |
| 7581 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7582 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7583 | } |
| 7584 | |
| 7585 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7586 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7587 | ds_layout_ci.pNext = NULL; |
| 7588 | ds_layout_ci.bindingCount = 1; |
| 7589 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7590 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7591 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7592 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7593 | NULL, ds_layouts + i); |
| 7594 | ASSERT_VK_SUCCESS(err); |
| 7595 | } |
| 7596 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7597 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7598 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7599 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7600 | alloc_info.descriptorPool = ds_pool; |
| 7601 | alloc_info.pSetLayouts = ds_layouts; |
| 7602 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7603 | descriptor_sets); |
| 7604 | ASSERT_VK_SUCCESS(err); |
| 7605 | |
| 7606 | // Create a buffer & bufferView to be used for invalid updates |
| 7607 | VkBufferCreateInfo buff_ci = {}; |
| 7608 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7609 | // This usage is not valid for any descriptor type |
| 7610 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7611 | buff_ci.size = 256; |
| 7612 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7613 | VkBuffer buffer; |
| 7614 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7615 | ASSERT_VK_SUCCESS(err); |
| 7616 | |
| 7617 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7618 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7619 | buff_view_ci.buffer = buffer; |
| 7620 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7621 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7622 | VkBufferView buff_view; |
| 7623 | err = |
| 7624 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7625 | ASSERT_VK_SUCCESS(err); |
| 7626 | |
| 7627 | // Create an image to be used for invalid updates |
| 7628 | VkImageCreateInfo image_ci = {}; |
| 7629 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7630 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7631 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7632 | image_ci.extent.width = 64; |
| 7633 | image_ci.extent.height = 64; |
| 7634 | image_ci.extent.depth = 1; |
| 7635 | image_ci.mipLevels = 1; |
| 7636 | image_ci.arrayLayers = 1; |
| 7637 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7638 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7639 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7640 | // This usage is not valid for any descriptor type |
| 7641 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7642 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7643 | VkImage image; |
| 7644 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7645 | ASSERT_VK_SUCCESS(err); |
| 7646 | // Bind memory to image |
| 7647 | VkMemoryRequirements mem_reqs; |
| 7648 | VkDeviceMemory image_mem; |
| 7649 | bool pass; |
| 7650 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7651 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7652 | mem_alloc.pNext = NULL; |
| 7653 | mem_alloc.allocationSize = 0; |
| 7654 | mem_alloc.memoryTypeIndex = 0; |
| 7655 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7656 | mem_alloc.allocationSize = mem_reqs.size; |
| 7657 | pass = |
| 7658 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7659 | ASSERT_TRUE(pass); |
| 7660 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7661 | ASSERT_VK_SUCCESS(err); |
| 7662 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7663 | ASSERT_VK_SUCCESS(err); |
| 7664 | // Now create view for image |
| 7665 | VkImageViewCreateInfo image_view_ci = {}; |
| 7666 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7667 | image_view_ci.image = image; |
| 7668 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7669 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7670 | image_view_ci.subresourceRange.layerCount = 1; |
| 7671 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7672 | image_view_ci.subresourceRange.levelCount = 1; |
| 7673 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7674 | VkImageView image_view; |
| 7675 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7676 | &image_view); |
| 7677 | ASSERT_VK_SUCCESS(err); |
| 7678 | |
| 7679 | VkDescriptorBufferInfo buff_info = {}; |
| 7680 | buff_info.buffer = buffer; |
| 7681 | VkDescriptorImageInfo img_info = {}; |
| 7682 | img_info.imageView = image_view; |
| 7683 | VkWriteDescriptorSet descriptor_write = {}; |
| 7684 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7685 | descriptor_write.dstBinding = 0; |
| 7686 | descriptor_write.descriptorCount = 1; |
| 7687 | descriptor_write.pTexelBufferView = &buff_view; |
| 7688 | descriptor_write.pBufferInfo = &buff_info; |
| 7689 | descriptor_write.pImageInfo = &img_info; |
| 7690 | |
| 7691 | // These error messages align with VkDescriptorType struct |
| 7692 | const char *error_msgs[] = { |
| 7693 | "", // placeholder, no error for SAMPLER descriptor |
| 7694 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7695 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7696 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7697 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7698 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 7699 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7700 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7701 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7702 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7703 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7704 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7705 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7706 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7707 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7708 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7709 | error_msgs[i]); |
| 7710 | |
| 7711 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7712 | NULL); |
| 7713 | |
| 7714 | m_errorMonitor->VerifyFound(); |
| 7715 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7716 | } |
| 7717 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7718 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7719 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7720 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7721 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7722 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7723 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7724 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7725 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7726 | } |
| 7727 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7728 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7729 | // 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] | 7730 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7731 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7732 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7733 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7734 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7735 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7736 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7737 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7738 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7739 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7740 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7741 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7742 | |
| 7743 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7744 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7745 | ds_pool_ci.pNext = NULL; |
| 7746 | ds_pool_ci.maxSets = 1; |
| 7747 | ds_pool_ci.poolSizeCount = 1; |
| 7748 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7749 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7750 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7751 | err = |
| 7752 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7753 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7754 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7755 | dsl_binding.binding = 0; |
| 7756 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7757 | dsl_binding.descriptorCount = 1; |
| 7758 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7759 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7760 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7761 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7762 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7763 | ds_layout_ci.pNext = NULL; |
| 7764 | ds_layout_ci.bindingCount = 1; |
| 7765 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7766 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7767 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7768 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7769 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7770 | ASSERT_VK_SUCCESS(err); |
| 7771 | |
| 7772 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7773 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7774 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7775 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7776 | alloc_info.descriptorPool = ds_pool; |
| 7777 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7778 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7779 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7780 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7781 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7782 | VkSamplerCreateInfo sampler_ci = {}; |
| 7783 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7784 | sampler_ci.pNext = NULL; |
| 7785 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7786 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7787 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7788 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7789 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7790 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7791 | sampler_ci.mipLodBias = 1.0; |
| 7792 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7793 | sampler_ci.maxAnisotropy = 1; |
| 7794 | sampler_ci.compareEnable = VK_FALSE; |
| 7795 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7796 | sampler_ci.minLod = 1.0; |
| 7797 | sampler_ci.maxLod = 1.0; |
| 7798 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7799 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7800 | VkSampler sampler; |
| 7801 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7802 | ASSERT_VK_SUCCESS(err); |
| 7803 | |
| 7804 | VkDescriptorImageInfo info = {}; |
| 7805 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7806 | |
| 7807 | VkWriteDescriptorSet descriptor_write; |
| 7808 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7809 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7810 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7811 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7812 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7813 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7814 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7815 | |
| 7816 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7817 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7818 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7819 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7820 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7821 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7822 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7823 | } |
| 7824 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7825 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7826 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7827 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7829 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7830 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7831 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7832 | "starting at binding offset of 0 combined with update array element " |
| 7833 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7834 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7835 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7836 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7837 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7838 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7839 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7840 | |
| 7841 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7842 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7843 | ds_pool_ci.pNext = NULL; |
| 7844 | ds_pool_ci.maxSets = 1; |
| 7845 | ds_pool_ci.poolSizeCount = 1; |
| 7846 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7847 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7848 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7849 | err = |
| 7850 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7851 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7852 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7853 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7854 | dsl_binding.binding = 0; |
| 7855 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7856 | dsl_binding.descriptorCount = 1; |
| 7857 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7858 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7859 | |
| 7860 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7861 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7862 | ds_layout_ci.pNext = NULL; |
| 7863 | ds_layout_ci.bindingCount = 1; |
| 7864 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7865 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7866 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7867 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7868 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7869 | ASSERT_VK_SUCCESS(err); |
| 7870 | |
| 7871 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7872 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7873 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7874 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7875 | alloc_info.descriptorPool = ds_pool; |
| 7876 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7877 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7878 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7879 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7880 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7881 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7882 | VkDescriptorBufferInfo buff_info = {}; |
| 7883 | buff_info.buffer = |
| 7884 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7885 | buff_info.offset = 0; |
| 7886 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7887 | |
| 7888 | VkWriteDescriptorSet descriptor_write; |
| 7889 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7890 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7891 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7892 | descriptor_write.dstArrayElement = |
| 7893 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7894 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7895 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7896 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7897 | |
| 7898 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7899 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7900 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7901 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7902 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7903 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7904 | } |
| 7905 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7906 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7907 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7908 | // index 2 |
| 7909 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7910 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7911 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7912 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7913 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7914 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7915 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7916 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7917 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7918 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7919 | |
| 7920 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7921 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7922 | ds_pool_ci.pNext = NULL; |
| 7923 | ds_pool_ci.maxSets = 1; |
| 7924 | ds_pool_ci.poolSizeCount = 1; |
| 7925 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7926 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7927 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7928 | err = |
| 7929 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7930 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7931 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7932 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7933 | dsl_binding.binding = 0; |
| 7934 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7935 | dsl_binding.descriptorCount = 1; |
| 7936 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7937 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7938 | |
| 7939 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7940 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7941 | ds_layout_ci.pNext = NULL; |
| 7942 | ds_layout_ci.bindingCount = 1; |
| 7943 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7944 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7945 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7946 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7947 | ASSERT_VK_SUCCESS(err); |
| 7948 | |
| 7949 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7950 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7951 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7952 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7953 | alloc_info.descriptorPool = ds_pool; |
| 7954 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7955 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7956 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7957 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7958 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7959 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7960 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7961 | sampler_ci.pNext = NULL; |
| 7962 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7963 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7964 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7965 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7966 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7967 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7968 | sampler_ci.mipLodBias = 1.0; |
| 7969 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7970 | sampler_ci.maxAnisotropy = 1; |
| 7971 | sampler_ci.compareEnable = VK_FALSE; |
| 7972 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7973 | sampler_ci.minLod = 1.0; |
| 7974 | sampler_ci.maxLod = 1.0; |
| 7975 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7976 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7977 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7978 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7979 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7980 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7981 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7982 | VkDescriptorImageInfo info = {}; |
| 7983 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7984 | |
| 7985 | VkWriteDescriptorSet descriptor_write; |
| 7986 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7987 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7988 | descriptor_write.dstSet = descriptorSet; |
| 7989 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7990 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7991 | // 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] | 7992 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7993 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7994 | |
| 7995 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7996 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7997 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7998 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7999 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8000 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8001 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8002 | } |
| 8003 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8004 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 8005 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 8006 | // types |
| 8007 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8008 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8009 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 8010 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8011 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8013 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8014 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8015 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8016 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8017 | |
| 8018 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8019 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8020 | ds_pool_ci.pNext = NULL; |
| 8021 | ds_pool_ci.maxSets = 1; |
| 8022 | ds_pool_ci.poolSizeCount = 1; |
| 8023 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8024 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8025 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8026 | err = |
| 8027 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8028 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8029 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8030 | dsl_binding.binding = 0; |
| 8031 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8032 | dsl_binding.descriptorCount = 1; |
| 8033 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8034 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8035 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8036 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8037 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8038 | ds_layout_ci.pNext = NULL; |
| 8039 | ds_layout_ci.bindingCount = 1; |
| 8040 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8041 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8042 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8043 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8044 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8045 | ASSERT_VK_SUCCESS(err); |
| 8046 | |
| 8047 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8048 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8049 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8050 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8051 | alloc_info.descriptorPool = ds_pool; |
| 8052 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8053 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8054 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8055 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8056 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8057 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8058 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8059 | sampler_ci.pNext = NULL; |
| 8060 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8061 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8062 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8063 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8064 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8065 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8066 | sampler_ci.mipLodBias = 1.0; |
| 8067 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8068 | sampler_ci.maxAnisotropy = 1; |
| 8069 | sampler_ci.compareEnable = VK_FALSE; |
| 8070 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8071 | sampler_ci.minLod = 1.0; |
| 8072 | sampler_ci.maxLod = 1.0; |
| 8073 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8074 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8075 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8076 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8077 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8078 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8079 | VkDescriptorImageInfo info = {}; |
| 8080 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8081 | |
| 8082 | VkWriteDescriptorSet descriptor_write; |
| 8083 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8084 | descriptor_write.sType = |
| 8085 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8086 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8087 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8088 | // 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] | 8089 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8090 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8091 | |
| 8092 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8094 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8095 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8096 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8097 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8098 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8099 | } |
| 8100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8101 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8102 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8103 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8105 | m_errorMonitor->SetDesiredFailureMsg( |
| 8106 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8107 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8108 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8110 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 8111 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8112 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8113 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8114 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8115 | |
| 8116 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8117 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8118 | ds_pool_ci.pNext = NULL; |
| 8119 | ds_pool_ci.maxSets = 1; |
| 8120 | ds_pool_ci.poolSizeCount = 1; |
| 8121 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8122 | |
| 8123 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8124 | err = |
| 8125 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8126 | ASSERT_VK_SUCCESS(err); |
| 8127 | |
| 8128 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8129 | dsl_binding.binding = 0; |
| 8130 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8131 | dsl_binding.descriptorCount = 1; |
| 8132 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8133 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8134 | |
| 8135 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8136 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8137 | ds_layout_ci.pNext = NULL; |
| 8138 | ds_layout_ci.bindingCount = 1; |
| 8139 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8140 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8141 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8142 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8143 | ASSERT_VK_SUCCESS(err); |
| 8144 | |
| 8145 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8146 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8147 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8148 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8149 | alloc_info.descriptorPool = ds_pool; |
| 8150 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8151 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8152 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8153 | ASSERT_VK_SUCCESS(err); |
| 8154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8155 | VkSampler sampler = |
| 8156 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8157 | |
| 8158 | VkDescriptorImageInfo descriptor_info; |
| 8159 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8160 | descriptor_info.sampler = sampler; |
| 8161 | |
| 8162 | VkWriteDescriptorSet descriptor_write; |
| 8163 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8164 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8165 | descriptor_write.dstSet = descriptorSet; |
| 8166 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8167 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8168 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8169 | descriptor_write.pImageInfo = &descriptor_info; |
| 8170 | |
| 8171 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8173 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8174 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8175 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8176 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8177 | } |
| 8178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8179 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 8180 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 8181 | // imageView |
| 8182 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8183 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8184 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8185 | "Attempted write update to combined " |
| 8186 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 8187 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8188 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8189 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8190 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8191 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8192 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8193 | |
| 8194 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8195 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8196 | ds_pool_ci.pNext = NULL; |
| 8197 | ds_pool_ci.maxSets = 1; |
| 8198 | ds_pool_ci.poolSizeCount = 1; |
| 8199 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8200 | |
| 8201 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8202 | err = |
| 8203 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8204 | ASSERT_VK_SUCCESS(err); |
| 8205 | |
| 8206 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8207 | dsl_binding.binding = 0; |
| 8208 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8209 | dsl_binding.descriptorCount = 1; |
| 8210 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8211 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8212 | |
| 8213 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8214 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8215 | ds_layout_ci.pNext = NULL; |
| 8216 | ds_layout_ci.bindingCount = 1; |
| 8217 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8218 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8219 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8220 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8221 | ASSERT_VK_SUCCESS(err); |
| 8222 | |
| 8223 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8224 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8225 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8226 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8227 | alloc_info.descriptorPool = ds_pool; |
| 8228 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8229 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8230 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8231 | ASSERT_VK_SUCCESS(err); |
| 8232 | |
| 8233 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8234 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8235 | sampler_ci.pNext = NULL; |
| 8236 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8237 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8238 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8239 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8240 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8241 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8242 | sampler_ci.mipLodBias = 1.0; |
| 8243 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8244 | sampler_ci.maxAnisotropy = 1; |
| 8245 | sampler_ci.compareEnable = VK_FALSE; |
| 8246 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8247 | sampler_ci.minLod = 1.0; |
| 8248 | sampler_ci.maxLod = 1.0; |
| 8249 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8250 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8251 | |
| 8252 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8253 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8254 | ASSERT_VK_SUCCESS(err); |
| 8255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | VkImageView view = |
| 8257 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8258 | |
| 8259 | VkDescriptorImageInfo descriptor_info; |
| 8260 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8261 | descriptor_info.sampler = sampler; |
| 8262 | descriptor_info.imageView = view; |
| 8263 | |
| 8264 | VkWriteDescriptorSet descriptor_write; |
| 8265 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8266 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8267 | descriptor_write.dstSet = descriptorSet; |
| 8268 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8269 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8270 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8271 | descriptor_write.pImageInfo = &descriptor_info; |
| 8272 | |
| 8273 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8274 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8275 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8276 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8277 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8278 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8279 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8280 | } |
| 8281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8282 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 8283 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 8284 | // into the other |
| 8285 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8286 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8287 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8288 | " binding #1 with type " |
| 8289 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 8290 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8291 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8293 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8294 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8295 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8296 | ds_type_count[0].descriptorCount = 1; |
| 8297 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8298 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8299 | |
| 8300 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8301 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8302 | ds_pool_ci.pNext = NULL; |
| 8303 | ds_pool_ci.maxSets = 1; |
| 8304 | ds_pool_ci.poolSizeCount = 2; |
| 8305 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8306 | |
| 8307 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8308 | err = |
| 8309 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8310 | ASSERT_VK_SUCCESS(err); |
| 8311 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8312 | dsl_binding[0].binding = 0; |
| 8313 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8314 | dsl_binding[0].descriptorCount = 1; |
| 8315 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 8316 | dsl_binding[0].pImmutableSamplers = NULL; |
| 8317 | dsl_binding[1].binding = 1; |
| 8318 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8319 | dsl_binding[1].descriptorCount = 1; |
| 8320 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 8321 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8322 | |
| 8323 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8324 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8325 | ds_layout_ci.pNext = NULL; |
| 8326 | ds_layout_ci.bindingCount = 2; |
| 8327 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8328 | |
| 8329 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8330 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8331 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8332 | ASSERT_VK_SUCCESS(err); |
| 8333 | |
| 8334 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8335 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8336 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8337 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8338 | alloc_info.descriptorPool = ds_pool; |
| 8339 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8340 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8341 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8342 | ASSERT_VK_SUCCESS(err); |
| 8343 | |
| 8344 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8346 | sampler_ci.pNext = NULL; |
| 8347 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8348 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8349 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8350 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8351 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8352 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8353 | sampler_ci.mipLodBias = 1.0; |
| 8354 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8355 | sampler_ci.maxAnisotropy = 1; |
| 8356 | sampler_ci.compareEnable = VK_FALSE; |
| 8357 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8358 | sampler_ci.minLod = 1.0; |
| 8359 | sampler_ci.maxLod = 1.0; |
| 8360 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8361 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8362 | |
| 8363 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8364 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8365 | ASSERT_VK_SUCCESS(err); |
| 8366 | |
| 8367 | VkDescriptorImageInfo info = {}; |
| 8368 | info.sampler = sampler; |
| 8369 | |
| 8370 | VkWriteDescriptorSet descriptor_write; |
| 8371 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 8372 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8373 | descriptor_write.dstSet = descriptorSet; |
| 8374 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8375 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8376 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8377 | descriptor_write.pImageInfo = &info; |
| 8378 | // This write update should succeed |
| 8379 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8380 | // Now perform a copy update that fails due to type mismatch |
| 8381 | VkCopyDescriptorSet copy_ds_update; |
| 8382 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8383 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8384 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8385 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8386 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8387 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8388 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8389 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8391 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8392 | // 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] | 8393 | m_errorMonitor->SetDesiredFailureMsg( |
| 8394 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8395 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8396 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8397 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8398 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8399 | copy_ds_update.srcBinding = |
| 8400 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8401 | copy_ds_update.dstSet = descriptorSet; |
| 8402 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8403 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8404 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8405 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8406 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8407 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8408 | // 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] | 8409 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 8411 | "update array offset of 0 and update of " |
| 8412 | "5 descriptors oversteps total number " |
| 8413 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8414 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8415 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8416 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8417 | copy_ds_update.srcSet = descriptorSet; |
| 8418 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8419 | copy_ds_update.dstSet = descriptorSet; |
| 8420 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8421 | copy_ds_update.descriptorCount = |
| 8422 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8423 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8424 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8425 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8426 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8427 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8428 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8429 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8430 | } |
| 8431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8432 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 8433 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 8434 | // sampleCount |
| 8435 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8436 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8437 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8438 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8439 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8440 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8441 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8442 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8443 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8444 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8445 | |
| 8446 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8447 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8448 | ds_pool_ci.pNext = NULL; |
| 8449 | ds_pool_ci.maxSets = 1; |
| 8450 | ds_pool_ci.poolSizeCount = 1; |
| 8451 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8452 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8453 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8454 | err = |
| 8455 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8456 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8457 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8458 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8459 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8460 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8461 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8462 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8463 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8464 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8465 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8466 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8467 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8468 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8469 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8470 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8471 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8472 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8473 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8474 | ASSERT_VK_SUCCESS(err); |
| 8475 | |
| 8476 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8477 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8478 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8479 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8480 | alloc_info.descriptorPool = ds_pool; |
| 8481 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8482 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8483 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8484 | ASSERT_VK_SUCCESS(err); |
| 8485 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8486 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8487 | pipe_ms_state_ci.sType = |
| 8488 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8489 | pipe_ms_state_ci.pNext = NULL; |
| 8490 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8491 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8492 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8493 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8494 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8495 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8496 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8497 | pipeline_layout_ci.pNext = NULL; |
| 8498 | pipeline_layout_ci.setLayoutCount = 1; |
| 8499 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8500 | |
| 8501 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8502 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8503 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8504 | ASSERT_VK_SUCCESS(err); |
| 8505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8506 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8507 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8508 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8509 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8510 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8511 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8512 | VkPipelineObj pipe(m_device); |
| 8513 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8514 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8515 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8516 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8517 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8518 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8519 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8520 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8521 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8522 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8523 | // Render triangle (the error should trigger on the attempt to draw). |
| 8524 | Draw(3, 1, 0, 0); |
| 8525 | |
| 8526 | // Finalize recording of the command buffer |
| 8527 | EndCommandBuffer(); |
| 8528 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8529 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8530 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8531 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8532 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8533 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8534 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8535 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8536 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8537 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8538 | // number of color attachments. In this case, we don't add any color |
| 8539 | // blend attachments even though we have a color attachment. |
| 8540 | VkResult err; |
| 8541 | |
| 8542 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8543 | "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] | 8544 | |
| 8545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8546 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8547 | VkDescriptorPoolSize ds_type_count = {}; |
| 8548 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8549 | ds_type_count.descriptorCount = 1; |
| 8550 | |
| 8551 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8552 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8553 | ds_pool_ci.pNext = NULL; |
| 8554 | ds_pool_ci.maxSets = 1; |
| 8555 | ds_pool_ci.poolSizeCount = 1; |
| 8556 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8557 | |
| 8558 | VkDescriptorPool ds_pool; |
| 8559 | err = |
| 8560 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8561 | ASSERT_VK_SUCCESS(err); |
| 8562 | |
| 8563 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8564 | dsl_binding.binding = 0; |
| 8565 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8566 | dsl_binding.descriptorCount = 1; |
| 8567 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8568 | dsl_binding.pImmutableSamplers = NULL; |
| 8569 | |
| 8570 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8571 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8572 | ds_layout_ci.pNext = NULL; |
| 8573 | ds_layout_ci.bindingCount = 1; |
| 8574 | ds_layout_ci.pBindings = &dsl_binding; |
| 8575 | |
| 8576 | VkDescriptorSetLayout ds_layout; |
| 8577 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8578 | &ds_layout); |
| 8579 | ASSERT_VK_SUCCESS(err); |
| 8580 | |
| 8581 | VkDescriptorSet descriptorSet; |
| 8582 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8583 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8584 | alloc_info.descriptorSetCount = 1; |
| 8585 | alloc_info.descriptorPool = ds_pool; |
| 8586 | alloc_info.pSetLayouts = &ds_layout; |
| 8587 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8588 | &descriptorSet); |
| 8589 | ASSERT_VK_SUCCESS(err); |
| 8590 | |
| 8591 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8592 | pipe_ms_state_ci.sType = |
| 8593 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8594 | pipe_ms_state_ci.pNext = NULL; |
| 8595 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8596 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8597 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8598 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8599 | |
| 8600 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8601 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8602 | pipeline_layout_ci.pNext = NULL; |
| 8603 | pipeline_layout_ci.setLayoutCount = 1; |
| 8604 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8605 | |
| 8606 | VkPipelineLayout pipeline_layout; |
| 8607 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8608 | &pipeline_layout); |
| 8609 | ASSERT_VK_SUCCESS(err); |
| 8610 | |
| 8611 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8612 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8613 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8614 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8615 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8616 | // but add it to be able to run on more devices |
| 8617 | VkPipelineObj pipe(m_device); |
| 8618 | pipe.AddShader(&vs); |
| 8619 | pipe.AddShader(&fs); |
| 8620 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8621 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8622 | |
| 8623 | BeginCommandBuffer(); |
| 8624 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8625 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8626 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8627 | // Render triangle (the error should trigger on the attempt to draw). |
| 8628 | Draw(3, 1, 0, 0); |
| 8629 | |
| 8630 | // Finalize recording of the command buffer |
| 8631 | EndCommandBuffer(); |
| 8632 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8633 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8634 | |
| 8635 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8636 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8637 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8638 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8639 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 8640 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 8641 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " |
| 8642 | "structure passed to vkCmdClearAttachments"); |
| 8643 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8644 | "vkCmdClearAttachments() attachment index 1 not found in attachment " |
| 8645 | "reference array of active subpass 0"); |
| 8646 | |
| 8647 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); |
| 8648 | m_errorMonitor->VerifyFound(); |
| 8649 | } |
| 8650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8651 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8652 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8653 | // to issuing a Draw |
| 8654 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8656 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8657 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8658 | "vkCmdClearAttachments() issued on CB object "); |
| 8659 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8660 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8662 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8663 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8664 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8665 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8666 | |
| 8667 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8668 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8669 | ds_pool_ci.pNext = NULL; |
| 8670 | ds_pool_ci.maxSets = 1; |
| 8671 | ds_pool_ci.poolSizeCount = 1; |
| 8672 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8673 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8674 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8675 | err = |
| 8676 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8677 | ASSERT_VK_SUCCESS(err); |
| 8678 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8679 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8680 | dsl_binding.binding = 0; |
| 8681 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8682 | dsl_binding.descriptorCount = 1; |
| 8683 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8684 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8685 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8686 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8687 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8688 | ds_layout_ci.pNext = NULL; |
| 8689 | ds_layout_ci.bindingCount = 1; |
| 8690 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8691 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8692 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8693 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8694 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8695 | ASSERT_VK_SUCCESS(err); |
| 8696 | |
| 8697 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8698 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8699 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8700 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8701 | alloc_info.descriptorPool = ds_pool; |
| 8702 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8703 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8704 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8705 | ASSERT_VK_SUCCESS(err); |
| 8706 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8707 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8708 | pipe_ms_state_ci.sType = |
| 8709 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8710 | pipe_ms_state_ci.pNext = NULL; |
| 8711 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8712 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8713 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8714 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8715 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8716 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8717 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8718 | pipeline_layout_ci.pNext = NULL; |
| 8719 | pipeline_layout_ci.setLayoutCount = 1; |
| 8720 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8721 | |
| 8722 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8723 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8724 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8725 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8727 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8728 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8729 | // 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] | 8730 | // on more devices |
| 8731 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8732 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8733 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8734 | VkPipelineObj pipe(m_device); |
| 8735 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8736 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8737 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8738 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8739 | |
| 8740 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8742 | // Main thing we care about for this test is that the VkImage obj we're |
| 8743 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8744 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8745 | VkClearAttachment color_attachment; |
| 8746 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8747 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8748 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8749 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8750 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8751 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8752 | VkClearRect clear_rect = { |
| 8753 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8755 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8756 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8758 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8759 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8760 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8761 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8762 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8763 | } |
| 8764 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8765 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8766 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8767 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8768 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8769 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8770 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8771 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8772 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8773 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8774 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8775 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8776 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8777 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8778 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8779 | |
| 8780 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8781 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8782 | ds_pool_ci.pNext = NULL; |
| 8783 | ds_pool_ci.maxSets = 1; |
| 8784 | ds_pool_ci.poolSizeCount = 1; |
| 8785 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8786 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8787 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8788 | err = |
| 8789 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8790 | ASSERT_VK_SUCCESS(err); |
| 8791 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8792 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8793 | dsl_binding.binding = 0; |
| 8794 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8795 | dsl_binding.descriptorCount = 1; |
| 8796 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8797 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8798 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8799 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8800 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8801 | ds_layout_ci.pNext = NULL; |
| 8802 | ds_layout_ci.bindingCount = 1; |
| 8803 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8804 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8805 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8806 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8807 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8808 | ASSERT_VK_SUCCESS(err); |
| 8809 | |
| 8810 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8811 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8812 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8813 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8814 | alloc_info.descriptorPool = ds_pool; |
| 8815 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8816 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8817 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8818 | ASSERT_VK_SUCCESS(err); |
| 8819 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8820 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8821 | pipe_ms_state_ci.sType = |
| 8822 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8823 | pipe_ms_state_ci.pNext = NULL; |
| 8824 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8825 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8826 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8827 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8828 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8829 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8830 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8831 | pipeline_layout_ci.pNext = NULL; |
| 8832 | pipeline_layout_ci.setLayoutCount = 1; |
| 8833 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8834 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8835 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8836 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8837 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8838 | ASSERT_VK_SUCCESS(err); |
| 8839 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8840 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8841 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8842 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8843 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8844 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8845 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8846 | VkPipelineObj pipe(m_device); |
| 8847 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8848 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8849 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8850 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8851 | pipe.SetViewport(m_viewports); |
| 8852 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8853 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8854 | |
| 8855 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8856 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8857 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8858 | // Don't care about actual data, just need to get to draw to flag error |
| 8859 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8860 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8861 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8862 | 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] | 8863 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8865 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8866 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8867 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8868 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8869 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8870 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8871 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8872 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8873 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8874 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8875 | "images in the wrong layout when they're copied or transitioned."); |
| 8876 | // 3 in ValidateCmdBufImageLayouts |
| 8877 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8878 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8879 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8880 | m_errorMonitor->SetDesiredFailureMsg( |
| 8881 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8882 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8883 | |
| 8884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8885 | // Create src & dst images to use for copy operations |
| 8886 | VkImage src_image; |
| 8887 | VkImage dst_image; |
| 8888 | |
| 8889 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8890 | const int32_t tex_width = 32; |
| 8891 | const int32_t tex_height = 32; |
| 8892 | |
| 8893 | VkImageCreateInfo image_create_info = {}; |
| 8894 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8895 | image_create_info.pNext = NULL; |
| 8896 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8897 | image_create_info.format = tex_format; |
| 8898 | image_create_info.extent.width = tex_width; |
| 8899 | image_create_info.extent.height = tex_height; |
| 8900 | image_create_info.extent.depth = 1; |
| 8901 | image_create_info.mipLevels = 1; |
| 8902 | image_create_info.arrayLayers = 4; |
| 8903 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8904 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8905 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8906 | image_create_info.flags = 0; |
| 8907 | |
| 8908 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8909 | ASSERT_VK_SUCCESS(err); |
| 8910 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8911 | ASSERT_VK_SUCCESS(err); |
| 8912 | |
| 8913 | BeginCommandBuffer(); |
| 8914 | VkImageCopy copyRegion; |
| 8915 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8916 | copyRegion.srcSubresource.mipLevel = 0; |
| 8917 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8918 | copyRegion.srcSubresource.layerCount = 1; |
| 8919 | copyRegion.srcOffset.x = 0; |
| 8920 | copyRegion.srcOffset.y = 0; |
| 8921 | copyRegion.srcOffset.z = 0; |
| 8922 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8923 | copyRegion.dstSubresource.mipLevel = 0; |
| 8924 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8925 | copyRegion.dstSubresource.layerCount = 1; |
| 8926 | copyRegion.dstOffset.x = 0; |
| 8927 | copyRegion.dstOffset.y = 0; |
| 8928 | copyRegion.dstOffset.z = 0; |
| 8929 | copyRegion.extent.width = 1; |
| 8930 | copyRegion.extent.height = 1; |
| 8931 | copyRegion.extent.depth = 1; |
| 8932 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8933 | m_errorMonitor->VerifyFound(); |
| 8934 | // Now cause error due to src image layout changing |
| 8935 | m_errorMonitor->SetDesiredFailureMsg( |
| 8936 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8937 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8938 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8939 | m_errorMonitor->VerifyFound(); |
| 8940 | // Final src error is due to bad layout type |
| 8941 | m_errorMonitor->SetDesiredFailureMsg( |
| 8942 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8943 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8944 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8945 | m_errorMonitor->VerifyFound(); |
| 8946 | // Now verify same checks for dst |
| 8947 | m_errorMonitor->SetDesiredFailureMsg( |
| 8948 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8949 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8950 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8951 | m_errorMonitor->VerifyFound(); |
| 8952 | // Now cause error due to src image layout changing |
| 8953 | m_errorMonitor->SetDesiredFailureMsg( |
| 8954 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8955 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8956 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8957 | m_errorMonitor->VerifyFound(); |
| 8958 | m_errorMonitor->SetDesiredFailureMsg( |
| 8959 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8960 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8961 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8962 | m_errorMonitor->VerifyFound(); |
| 8963 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8964 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8965 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8966 | image_barrier[0].image = src_image; |
| 8967 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8968 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8969 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8970 | m_errorMonitor->SetDesiredFailureMsg( |
| 8971 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8972 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8973 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8974 | m_errorMonitor->VerifyFound(); |
| 8975 | |
| 8976 | // Finally some layout errors at RenderPass create time |
| 8977 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8978 | VkAttachmentReference attach = {}; |
| 8979 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8980 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8981 | VkSubpassDescription subpass = {}; |
| 8982 | subpass.inputAttachmentCount = 1; |
| 8983 | subpass.pInputAttachments = &attach; |
| 8984 | VkRenderPassCreateInfo rpci = {}; |
| 8985 | rpci.subpassCount = 1; |
| 8986 | rpci.pSubpasses = &subpass; |
| 8987 | rpci.attachmentCount = 1; |
| 8988 | VkAttachmentDescription attach_desc = {}; |
| 8989 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8990 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8991 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8992 | VkRenderPass rp; |
| 8993 | m_errorMonitor->SetDesiredFailureMsg( |
| 8994 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8995 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8996 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8997 | m_errorMonitor->VerifyFound(); |
| 8998 | // error w/ non-general layout |
| 8999 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9000 | |
| 9001 | m_errorMonitor->SetDesiredFailureMsg( |
| 9002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9003 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 9004 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9005 | m_errorMonitor->VerifyFound(); |
| 9006 | subpass.inputAttachmentCount = 0; |
| 9007 | subpass.colorAttachmentCount = 1; |
| 9008 | subpass.pColorAttachments = &attach; |
| 9009 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9010 | // perf warning for GENERAL layout on color attachment |
| 9011 | m_errorMonitor->SetDesiredFailureMsg( |
| 9012 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9013 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 9014 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9015 | m_errorMonitor->VerifyFound(); |
| 9016 | // error w/ non-color opt or GENERAL layout for color attachment |
| 9017 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9018 | m_errorMonitor->SetDesiredFailureMsg( |
| 9019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9020 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9021 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9022 | m_errorMonitor->VerifyFound(); |
| 9023 | subpass.colorAttachmentCount = 0; |
| 9024 | subpass.pDepthStencilAttachment = &attach; |
| 9025 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9026 | // perf warning for GENERAL layout on DS attachment |
| 9027 | m_errorMonitor->SetDesiredFailureMsg( |
| 9028 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9029 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 9030 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9031 | m_errorMonitor->VerifyFound(); |
| 9032 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 9033 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9034 | m_errorMonitor->SetDesiredFailureMsg( |
| 9035 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9036 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9037 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9038 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 9039 | // For this error we need a valid renderpass so create default one |
| 9040 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9041 | attach.attachment = 0; |
| 9042 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9043 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9044 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 9045 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 9046 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 9047 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 9048 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 9049 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9050 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9051 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9052 | " with invalid first layout " |
| 9053 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 9054 | "ONLY_OPTIMAL"); |
| 9055 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9056 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 9057 | |
| 9058 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 9059 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 9060 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9061 | #endif // DRAW_STATE_TESTS |
| 9062 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 9063 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9064 | #if GTEST_IS_THREADSAFE |
| 9065 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9066 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9067 | VkEvent event; |
| 9068 | bool bailout; |
| 9069 | }; |
| 9070 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9071 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 9072 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9074 | for (int i = 0; i < 10000; i++) { |
| 9075 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 9076 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9077 | if (data->bailout) { |
| 9078 | break; |
| 9079 | } |
| 9080 | } |
| 9081 | return NULL; |
| 9082 | } |
| 9083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9084 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9085 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9086 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9087 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9088 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9089 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9090 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9091 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 9092 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9093 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9094 | // Calls AllocateCommandBuffers |
| 9095 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9096 | |
| 9097 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9098 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9099 | |
| 9100 | VkEventCreateInfo event_info; |
| 9101 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9102 | VkResult err; |
| 9103 | |
| 9104 | memset(&event_info, 0, sizeof(event_info)); |
| 9105 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 9106 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9107 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9108 | ASSERT_VK_SUCCESS(err); |
| 9109 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9110 | err = vkResetEvent(device(), event); |
| 9111 | ASSERT_VK_SUCCESS(err); |
| 9112 | |
| 9113 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9114 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9115 | data.event = event; |
| 9116 | data.bailout = false; |
| 9117 | m_errorMonitor->SetBailout(&data.bailout); |
| 9118 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9119 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9120 | // Add many entries to command buffer from this thread at the same time. |
| 9121 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9122 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9123 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9124 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9125 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 9126 | m_errorMonitor->SetBailout(NULL); |
| 9127 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9128 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9130 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9131 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9132 | #endif // GTEST_IS_THREADSAFE |
| 9133 | #endif // THREADING_TESTS |
| 9134 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9135 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9136 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9137 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9138 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9139 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9141 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9142 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9143 | VkShaderModule module; |
| 9144 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9145 | struct icd_spv_header spv; |
| 9146 | |
| 9147 | spv.magic = ICD_SPV_MAGIC; |
| 9148 | spv.version = ICD_SPV_VERSION; |
| 9149 | spv.gen_magic = 0; |
| 9150 | |
| 9151 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9152 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9153 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9154 | moduleCreateInfo.codeSize = 4; |
| 9155 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9156 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9157 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9158 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9159 | } |
| 9160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9161 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9163 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9164 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9165 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9166 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9167 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9168 | VkShaderModule module; |
| 9169 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9170 | struct icd_spv_header spv; |
| 9171 | |
| 9172 | spv.magic = ~ICD_SPV_MAGIC; |
| 9173 | spv.version = ICD_SPV_VERSION; |
| 9174 | spv.gen_magic = 0; |
| 9175 | |
| 9176 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9177 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9178 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9179 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9180 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9181 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9183 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9184 | } |
| 9185 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9186 | #if 0 |
| 9187 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9188 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9189 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9190 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9191 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9193 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9194 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9195 | VkShaderModule module; |
| 9196 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9197 | struct icd_spv_header spv; |
| 9198 | |
| 9199 | spv.magic = ICD_SPV_MAGIC; |
| 9200 | spv.version = ~ICD_SPV_VERSION; |
| 9201 | spv.gen_magic = 0; |
| 9202 | |
| 9203 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9204 | moduleCreateInfo.pNext = NULL; |
| 9205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9206 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9207 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9208 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9209 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9210 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9211 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9212 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9213 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9215 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9216 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9217 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9218 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9220 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9221 | |
| 9222 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9223 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9224 | "\n" |
| 9225 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9226 | "out gl_PerVertex {\n" |
| 9227 | " vec4 gl_Position;\n" |
| 9228 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9229 | "void main(){\n" |
| 9230 | " gl_Position = vec4(1);\n" |
| 9231 | " x = 0;\n" |
| 9232 | "}\n"; |
| 9233 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9234 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9235 | "\n" |
| 9236 | "layout(location=0) out vec4 color;\n" |
| 9237 | "void main(){\n" |
| 9238 | " color = vec4(1);\n" |
| 9239 | "}\n"; |
| 9240 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9241 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9242 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9243 | |
| 9244 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9245 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9246 | pipe.AddShader(&vs); |
| 9247 | pipe.AddShader(&fs); |
| 9248 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9249 | VkDescriptorSetObj descriptorSet(m_device); |
| 9250 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9251 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9252 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9253 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9254 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9255 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9256 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9257 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9258 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9259 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9260 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9261 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9262 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9263 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9264 | |
| 9265 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9266 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9267 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9268 | "out gl_PerVertex {\n" |
| 9269 | " vec4 gl_Position;\n" |
| 9270 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9271 | "void main(){\n" |
| 9272 | " gl_Position = vec4(1);\n" |
| 9273 | "}\n"; |
| 9274 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9275 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9276 | "\n" |
| 9277 | "layout(location=0) in float x;\n" |
| 9278 | "layout(location=0) out vec4 color;\n" |
| 9279 | "void main(){\n" |
| 9280 | " color = vec4(x);\n" |
| 9281 | "}\n"; |
| 9282 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9283 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9284 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9285 | |
| 9286 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9287 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9288 | pipe.AddShader(&vs); |
| 9289 | pipe.AddShader(&fs); |
| 9290 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9291 | VkDescriptorSetObj descriptorSet(m_device); |
| 9292 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9293 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9294 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9295 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9297 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9298 | } |
| 9299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9300 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9301 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9302 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9303 | |
| 9304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9305 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9306 | |
| 9307 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9308 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9309 | "\n" |
| 9310 | "out gl_PerVertex {\n" |
| 9311 | " vec4 gl_Position;\n" |
| 9312 | "};\n" |
| 9313 | "void main(){\n" |
| 9314 | " gl_Position = vec4(1);\n" |
| 9315 | "}\n"; |
| 9316 | char const *fsSource = |
| 9317 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9318 | "\n" |
| 9319 | "in block { layout(location=0) float x; } ins;\n" |
| 9320 | "layout(location=0) out vec4 color;\n" |
| 9321 | "void main(){\n" |
| 9322 | " color = vec4(ins.x);\n" |
| 9323 | "}\n"; |
| 9324 | |
| 9325 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9326 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9327 | |
| 9328 | VkPipelineObj pipe(m_device); |
| 9329 | pipe.AddColorAttachment(); |
| 9330 | pipe.AddShader(&vs); |
| 9331 | pipe.AddShader(&fs); |
| 9332 | |
| 9333 | VkDescriptorSetObj descriptorSet(m_device); |
| 9334 | descriptorSet.AppendDummy(); |
| 9335 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9336 | |
| 9337 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9338 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9339 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9340 | } |
| 9341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9342 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9343 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9344 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9345 | "output arr[2] of float32' vs 'ptr to " |
| 9346 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9347 | |
| 9348 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9349 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9350 | |
| 9351 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9352 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9353 | "\n" |
| 9354 | "layout(location=0) out float x[2];\n" |
| 9355 | "out gl_PerVertex {\n" |
| 9356 | " vec4 gl_Position;\n" |
| 9357 | "};\n" |
| 9358 | "void main(){\n" |
| 9359 | " x[0] = 0; x[1] = 0;\n" |
| 9360 | " gl_Position = vec4(1);\n" |
| 9361 | "}\n"; |
| 9362 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9363 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9364 | "\n" |
| 9365 | "layout(location=0) in float x[3];\n" |
| 9366 | "layout(location=0) out vec4 color;\n" |
| 9367 | "void main(){\n" |
| 9368 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 9369 | "}\n"; |
| 9370 | |
| 9371 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9372 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9373 | |
| 9374 | VkPipelineObj pipe(m_device); |
| 9375 | pipe.AddColorAttachment(); |
| 9376 | pipe.AddShader(&vs); |
| 9377 | pipe.AddShader(&fs); |
| 9378 | |
| 9379 | VkDescriptorSetObj descriptorSet(m_device); |
| 9380 | descriptorSet.AppendDummy(); |
| 9381 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9382 | |
| 9383 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9384 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9385 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9386 | } |
| 9387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9388 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9389 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9390 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9391 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9392 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9393 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9394 | |
| 9395 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9396 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9397 | "\n" |
| 9398 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9399 | "out gl_PerVertex {\n" |
| 9400 | " vec4 gl_Position;\n" |
| 9401 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9402 | "void main(){\n" |
| 9403 | " x = 0;\n" |
| 9404 | " gl_Position = vec4(1);\n" |
| 9405 | "}\n"; |
| 9406 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9407 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9408 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9409 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9410 | "layout(location=0) out vec4 color;\n" |
| 9411 | "void main(){\n" |
| 9412 | " color = vec4(x);\n" |
| 9413 | "}\n"; |
| 9414 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9415 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9416 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9417 | |
| 9418 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9419 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9420 | pipe.AddShader(&vs); |
| 9421 | pipe.AddShader(&fs); |
| 9422 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9423 | VkDescriptorSetObj descriptorSet(m_device); |
| 9424 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9425 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9426 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9427 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9428 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9429 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9430 | } |
| 9431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9432 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9433 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9434 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9435 | |
| 9436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9437 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9438 | |
| 9439 | char const *vsSource = |
| 9440 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9441 | "\n" |
| 9442 | "out block { layout(location=0) int x; } outs;\n" |
| 9443 | "out gl_PerVertex {\n" |
| 9444 | " vec4 gl_Position;\n" |
| 9445 | "};\n" |
| 9446 | "void main(){\n" |
| 9447 | " outs.x = 0;\n" |
| 9448 | " gl_Position = vec4(1);\n" |
| 9449 | "}\n"; |
| 9450 | char const *fsSource = |
| 9451 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9452 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9453 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9454 | "layout(location=0) out vec4 color;\n" |
| 9455 | "void main(){\n" |
| 9456 | " color = vec4(ins.x);\n" |
| 9457 | "}\n"; |
| 9458 | |
| 9459 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9460 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9461 | |
| 9462 | VkPipelineObj pipe(m_device); |
| 9463 | pipe.AddColorAttachment(); |
| 9464 | pipe.AddShader(&vs); |
| 9465 | pipe.AddShader(&fs); |
| 9466 | |
| 9467 | VkDescriptorSetObj descriptorSet(m_device); |
| 9468 | descriptorSet.AppendDummy(); |
| 9469 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9470 | |
| 9471 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9473 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9474 | } |
| 9475 | |
| 9476 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9477 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9478 | "location 0.0 which is not written by vertex shader"); |
| 9479 | |
| 9480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9482 | |
| 9483 | char const *vsSource = |
| 9484 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9485 | "\n" |
| 9486 | "out block { layout(location=1) float x; } outs;\n" |
| 9487 | "out gl_PerVertex {\n" |
| 9488 | " vec4 gl_Position;\n" |
| 9489 | "};\n" |
| 9490 | "void main(){\n" |
| 9491 | " outs.x = 0;\n" |
| 9492 | " gl_Position = vec4(1);\n" |
| 9493 | "}\n"; |
| 9494 | char const *fsSource = |
| 9495 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9496 | "\n" |
| 9497 | "in block { layout(location=0) float x; } ins;\n" |
| 9498 | "layout(location=0) out vec4 color;\n" |
| 9499 | "void main(){\n" |
| 9500 | " color = vec4(ins.x);\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 | VkDescriptorSetObj descriptorSet(m_device); |
| 9512 | descriptorSet.AppendDummy(); |
| 9513 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9514 | |
| 9515 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9516 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9517 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9518 | } |
| 9519 | |
| 9520 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9521 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9522 | "location 0.1 which is not written by vertex shader"); |
| 9523 | |
| 9524 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9525 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9526 | |
| 9527 | char const *vsSource = |
| 9528 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9529 | "\n" |
| 9530 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9531 | "out gl_PerVertex {\n" |
| 9532 | " vec4 gl_Position;\n" |
| 9533 | "};\n" |
| 9534 | "void main(){\n" |
| 9535 | " outs.x = 0;\n" |
| 9536 | " gl_Position = vec4(1);\n" |
| 9537 | "}\n"; |
| 9538 | char const *fsSource = |
| 9539 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9540 | "\n" |
| 9541 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9542 | "layout(location=0) out vec4 color;\n" |
| 9543 | "void main(){\n" |
| 9544 | " color = vec4(ins.x);\n" |
| 9545 | "}\n"; |
| 9546 | |
| 9547 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9548 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9549 | |
| 9550 | VkPipelineObj pipe(m_device); |
| 9551 | pipe.AddColorAttachment(); |
| 9552 | pipe.AddShader(&vs); |
| 9553 | pipe.AddShader(&fs); |
| 9554 | |
| 9555 | VkDescriptorSetObj descriptorSet(m_device); |
| 9556 | descriptorSet.AppendDummy(); |
| 9557 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9558 | |
| 9559 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9560 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9561 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9562 | } |
| 9563 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9564 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9565 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9566 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9567 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9568 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9569 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9570 | |
| 9571 | VkVertexInputBindingDescription input_binding; |
| 9572 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9573 | |
| 9574 | VkVertexInputAttributeDescription input_attrib; |
| 9575 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9576 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9577 | |
| 9578 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9579 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9580 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9581 | "out gl_PerVertex {\n" |
| 9582 | " vec4 gl_Position;\n" |
| 9583 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9584 | "void main(){\n" |
| 9585 | " gl_Position = vec4(1);\n" |
| 9586 | "}\n"; |
| 9587 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9588 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9589 | "\n" |
| 9590 | "layout(location=0) out vec4 color;\n" |
| 9591 | "void main(){\n" |
| 9592 | " color = vec4(1);\n" |
| 9593 | "}\n"; |
| 9594 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9595 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9596 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9597 | |
| 9598 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9599 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9600 | pipe.AddShader(&vs); |
| 9601 | pipe.AddShader(&fs); |
| 9602 | |
| 9603 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9604 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9605 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9606 | VkDescriptorSetObj descriptorSet(m_device); |
| 9607 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9608 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9609 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9610 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9611 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9612 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9613 | } |
| 9614 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9615 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9616 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9617 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9618 | |
| 9619 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9620 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9621 | |
| 9622 | VkVertexInputBindingDescription input_binding; |
| 9623 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9624 | |
| 9625 | VkVertexInputAttributeDescription input_attrib; |
| 9626 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9627 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9628 | |
| 9629 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9630 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9631 | "\n" |
| 9632 | "layout(location=1) in float x;\n" |
| 9633 | "out gl_PerVertex {\n" |
| 9634 | " vec4 gl_Position;\n" |
| 9635 | "};\n" |
| 9636 | "void main(){\n" |
| 9637 | " gl_Position = vec4(x);\n" |
| 9638 | "}\n"; |
| 9639 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9640 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9641 | "\n" |
| 9642 | "layout(location=0) out vec4 color;\n" |
| 9643 | "void main(){\n" |
| 9644 | " color = vec4(1);\n" |
| 9645 | "}\n"; |
| 9646 | |
| 9647 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9648 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9649 | |
| 9650 | VkPipelineObj pipe(m_device); |
| 9651 | pipe.AddColorAttachment(); |
| 9652 | pipe.AddShader(&vs); |
| 9653 | pipe.AddShader(&fs); |
| 9654 | |
| 9655 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9656 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9657 | |
| 9658 | VkDescriptorSetObj descriptorSet(m_device); |
| 9659 | descriptorSet.AppendDummy(); |
| 9660 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9661 | |
| 9662 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9663 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9664 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9665 | } |
| 9666 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9667 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9668 | m_errorMonitor->SetDesiredFailureMsg( |
| 9669 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9670 | "VS consumes input at location 0 but not provided"); |
| 9671 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9673 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9674 | |
| 9675 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9676 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9677 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9678 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9679 | "out gl_PerVertex {\n" |
| 9680 | " vec4 gl_Position;\n" |
| 9681 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9682 | "void main(){\n" |
| 9683 | " gl_Position = x;\n" |
| 9684 | "}\n"; |
| 9685 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9686 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9687 | "\n" |
| 9688 | "layout(location=0) out vec4 color;\n" |
| 9689 | "void main(){\n" |
| 9690 | " color = vec4(1);\n" |
| 9691 | "}\n"; |
| 9692 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9693 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9694 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9695 | |
| 9696 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9697 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9698 | pipe.AddShader(&vs); |
| 9699 | pipe.AddShader(&fs); |
| 9700 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9701 | VkDescriptorSetObj descriptorSet(m_device); |
| 9702 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9703 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9704 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9705 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9706 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9707 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9708 | } |
| 9709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9710 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9711 | m_errorMonitor->SetDesiredFailureMsg( |
| 9712 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9713 | "location 0 does not match VS input type"); |
| 9714 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9716 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9717 | |
| 9718 | VkVertexInputBindingDescription input_binding; |
| 9719 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9720 | |
| 9721 | VkVertexInputAttributeDescription input_attrib; |
| 9722 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9723 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9724 | |
| 9725 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9726 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9727 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9728 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9729 | "out gl_PerVertex {\n" |
| 9730 | " vec4 gl_Position;\n" |
| 9731 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9732 | "void main(){\n" |
| 9733 | " gl_Position = vec4(x);\n" |
| 9734 | "}\n"; |
| 9735 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9736 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9737 | "\n" |
| 9738 | "layout(location=0) out vec4 color;\n" |
| 9739 | "void main(){\n" |
| 9740 | " color = vec4(1);\n" |
| 9741 | "}\n"; |
| 9742 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9743 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9744 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9745 | |
| 9746 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9747 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9748 | pipe.AddShader(&vs); |
| 9749 | pipe.AddShader(&fs); |
| 9750 | |
| 9751 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9752 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9753 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9754 | VkDescriptorSetObj descriptorSet(m_device); |
| 9755 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9756 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9757 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9758 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9759 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9760 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9761 | } |
| 9762 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9763 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9764 | m_errorMonitor->SetDesiredFailureMsg( |
| 9765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9766 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9767 | |
| 9768 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9769 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9770 | |
| 9771 | char const *vsSource = |
| 9772 | "#version 450\n" |
| 9773 | "\n" |
| 9774 | "out gl_PerVertex {\n" |
| 9775 | " vec4 gl_Position;\n" |
| 9776 | "};\n" |
| 9777 | "void main(){\n" |
| 9778 | " gl_Position = vec4(1);\n" |
| 9779 | "}\n"; |
| 9780 | char const *fsSource = |
| 9781 | "#version 450\n" |
| 9782 | "\n" |
| 9783 | "layout(location=0) out vec4 color;\n" |
| 9784 | "void main(){\n" |
| 9785 | " color = vec4(1);\n" |
| 9786 | "}\n"; |
| 9787 | |
| 9788 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9789 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9790 | |
| 9791 | VkPipelineObj pipe(m_device); |
| 9792 | pipe.AddColorAttachment(); |
| 9793 | pipe.AddShader(&vs); |
| 9794 | pipe.AddShader(&vs); |
| 9795 | pipe.AddShader(&fs); |
| 9796 | |
| 9797 | VkDescriptorSetObj descriptorSet(m_device); |
| 9798 | descriptorSet.AppendDummy(); |
| 9799 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9800 | |
| 9801 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9802 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9803 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9804 | } |
| 9805 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9806 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9807 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9808 | |
| 9809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9810 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9811 | |
| 9812 | VkVertexInputBindingDescription input_binding; |
| 9813 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9814 | |
| 9815 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9816 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9817 | |
| 9818 | for (int i = 0; i < 2; i++) { |
| 9819 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9820 | input_attribs[i].location = i; |
| 9821 | } |
| 9822 | |
| 9823 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9824 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9825 | "\n" |
| 9826 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9827 | "out gl_PerVertex {\n" |
| 9828 | " vec4 gl_Position;\n" |
| 9829 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9830 | "void main(){\n" |
| 9831 | " gl_Position = x[0] + x[1];\n" |
| 9832 | "}\n"; |
| 9833 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9834 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9835 | "\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 fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9843 | |
| 9844 | VkPipelineObj pipe(m_device); |
| 9845 | pipe.AddColorAttachment(); |
| 9846 | pipe.AddShader(&vs); |
| 9847 | pipe.AddShader(&fs); |
| 9848 | |
| 9849 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9850 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9851 | |
| 9852 | VkDescriptorSetObj descriptorSet(m_device); |
| 9853 | descriptorSet.AppendDummy(); |
| 9854 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9855 | |
| 9856 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9857 | |
| 9858 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9859 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9860 | } |
| 9861 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9862 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9863 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9864 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9865 | |
| 9866 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9867 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9868 | |
| 9869 | VkVertexInputBindingDescription input_binding; |
| 9870 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9871 | |
| 9872 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9873 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9874 | |
| 9875 | for (int i = 0; i < 2; i++) { |
| 9876 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9877 | input_attribs[i].location = i; |
| 9878 | } |
| 9879 | |
| 9880 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9881 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9882 | "\n" |
| 9883 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9884 | "out gl_PerVertex {\n" |
| 9885 | " vec4 gl_Position;\n" |
| 9886 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9887 | "void main(){\n" |
| 9888 | " gl_Position = x[0] + x[1];\n" |
| 9889 | "}\n"; |
| 9890 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9891 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9892 | "\n" |
| 9893 | "layout(location=0) out vec4 color;\n" |
| 9894 | "void main(){\n" |
| 9895 | " color = vec4(1);\n" |
| 9896 | "}\n"; |
| 9897 | |
| 9898 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9899 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9900 | |
| 9901 | VkPipelineObj pipe(m_device); |
| 9902 | pipe.AddColorAttachment(); |
| 9903 | pipe.AddShader(&vs); |
| 9904 | pipe.AddShader(&fs); |
| 9905 | |
| 9906 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9907 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9908 | |
| 9909 | VkDescriptorSetObj descriptorSet(m_device); |
| 9910 | descriptorSet.AppendDummy(); |
| 9911 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9912 | |
| 9913 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9914 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9915 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9916 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9917 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9918 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9919 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9920 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9921 | |
| 9922 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9923 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9924 | |
| 9925 | char const *vsSource = |
| 9926 | "#version 450\n" |
| 9927 | "out gl_PerVertex {\n" |
| 9928 | " vec4 gl_Position;\n" |
| 9929 | "};\n" |
| 9930 | "void main(){\n" |
| 9931 | " gl_Position = vec4(0);\n" |
| 9932 | "}\n"; |
| 9933 | char const *fsSource = |
| 9934 | "#version 450\n" |
| 9935 | "\n" |
| 9936 | "layout(location=0) out vec4 color;\n" |
| 9937 | "void main(){\n" |
| 9938 | " color = vec4(1);\n" |
| 9939 | "}\n"; |
| 9940 | |
| 9941 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9942 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9943 | |
| 9944 | VkPipelineObj pipe(m_device); |
| 9945 | pipe.AddColorAttachment(); |
| 9946 | pipe.AddShader(&vs); |
| 9947 | pipe.AddShader(&fs); |
| 9948 | |
| 9949 | VkDescriptorSetObj descriptorSet(m_device); |
| 9950 | descriptorSet.AppendDummy(); |
| 9951 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9952 | |
| 9953 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9954 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9955 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9956 | } |
| 9957 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9958 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9959 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9960 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9961 | |
| 9962 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9963 | |
| 9964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9965 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9966 | |
| 9967 | char const *vsSource = |
| 9968 | "#version 450\n" |
| 9969 | "out gl_PerVertex {\n" |
| 9970 | " vec4 gl_Position;\n" |
| 9971 | "};\n" |
| 9972 | "layout(location=0) out vec3 x;\n" |
| 9973 | "layout(location=1) out ivec3 y;\n" |
| 9974 | "layout(location=2) out vec3 z;\n" |
| 9975 | "void main(){\n" |
| 9976 | " gl_Position = vec4(0);\n" |
| 9977 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9978 | "}\n"; |
| 9979 | char const *fsSource = |
| 9980 | "#version 450\n" |
| 9981 | "\n" |
| 9982 | "layout(location=0) out vec4 color;\n" |
| 9983 | "layout(location=0) in float x;\n" |
| 9984 | "layout(location=1) flat in int y;\n" |
| 9985 | "layout(location=2) in vec2 z;\n" |
| 9986 | "void main(){\n" |
| 9987 | " color = vec4(1 + x + y + z.x);\n" |
| 9988 | "}\n"; |
| 9989 | |
| 9990 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9991 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9992 | |
| 9993 | VkPipelineObj pipe(m_device); |
| 9994 | pipe.AddColorAttachment(); |
| 9995 | pipe.AddShader(&vs); |
| 9996 | pipe.AddShader(&fs); |
| 9997 | |
| 9998 | VkDescriptorSetObj descriptorSet(m_device); |
| 9999 | descriptorSet.AppendDummy(); |
| 10000 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10001 | |
| 10002 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10003 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10004 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 10005 | } |
| 10006 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10007 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 10008 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10009 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10010 | |
| 10011 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10012 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10013 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10014 | if (!m_device->phy().features().tessellationShader) { |
| 10015 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10016 | return; |
| 10017 | } |
| 10018 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10019 | char const *vsSource = |
| 10020 | "#version 450\n" |
| 10021 | "void main(){}\n"; |
| 10022 | char const *tcsSource = |
| 10023 | "#version 450\n" |
| 10024 | "layout(location=0) out int x[];\n" |
| 10025 | "layout(vertices=3) out;\n" |
| 10026 | "void main(){\n" |
| 10027 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10028 | " gl_TessLevelInner[0] = 1;\n" |
| 10029 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10030 | "}\n"; |
| 10031 | char const *tesSource = |
| 10032 | "#version 450\n" |
| 10033 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10034 | "layout(location=0) in int x[];\n" |
| 10035 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10036 | "void main(){\n" |
| 10037 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10038 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 10039 | "}\n"; |
| 10040 | char const *fsSource = |
| 10041 | "#version 450\n" |
| 10042 | "layout(location=0) out vec4 color;\n" |
| 10043 | "void main(){\n" |
| 10044 | " color = vec4(1);\n" |
| 10045 | "}\n"; |
| 10046 | |
| 10047 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10048 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10049 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10050 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10051 | |
| 10052 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10053 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10054 | nullptr, |
| 10055 | 0, |
| 10056 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10057 | VK_FALSE}; |
| 10058 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10059 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10060 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10061 | nullptr, |
| 10062 | 0, |
| 10063 | 3}; |
| 10064 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10065 | VkPipelineObj pipe(m_device); |
| 10066 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10067 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10068 | pipe.AddColorAttachment(); |
| 10069 | pipe.AddShader(&vs); |
| 10070 | pipe.AddShader(&tcs); |
| 10071 | pipe.AddShader(&tes); |
| 10072 | pipe.AddShader(&fs); |
| 10073 | |
| 10074 | VkDescriptorSetObj descriptorSet(m_device); |
| 10075 | descriptorSet.AppendDummy(); |
| 10076 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10077 | |
| 10078 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10079 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10080 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10081 | } |
| 10082 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 10083 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 10084 | { |
| 10085 | m_errorMonitor->ExpectSuccess(); |
| 10086 | |
| 10087 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10088 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10089 | |
| 10090 | if (!m_device->phy().features().geometryShader) { |
| 10091 | printf("Device does not support geometry shaders; skipped.\n"); |
| 10092 | return; |
| 10093 | } |
| 10094 | |
| 10095 | char const *vsSource = |
| 10096 | "#version 450\n" |
| 10097 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 10098 | "void main(){\n" |
| 10099 | " vs_out.x = vec4(1);\n" |
| 10100 | "}\n"; |
| 10101 | char const *gsSource = |
| 10102 | "#version 450\n" |
| 10103 | "layout(triangles) in;\n" |
| 10104 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 10105 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 10106 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10107 | "void main() {\n" |
| 10108 | " gl_Position = gs_in[0].x;\n" |
| 10109 | " EmitVertex();\n" |
| 10110 | "}\n"; |
| 10111 | char const *fsSource = |
| 10112 | "#version 450\n" |
| 10113 | "layout(location=0) out vec4 color;\n" |
| 10114 | "void main(){\n" |
| 10115 | " color = vec4(1);\n" |
| 10116 | "}\n"; |
| 10117 | |
| 10118 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10119 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 10120 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10121 | |
| 10122 | VkPipelineObj pipe(m_device); |
| 10123 | pipe.AddColorAttachment(); |
| 10124 | pipe.AddShader(&vs); |
| 10125 | pipe.AddShader(&gs); |
| 10126 | pipe.AddShader(&fs); |
| 10127 | |
| 10128 | VkDescriptorSetObj descriptorSet(m_device); |
| 10129 | descriptorSet.AppendDummy(); |
| 10130 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10131 | |
| 10132 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10133 | |
| 10134 | m_errorMonitor->VerifyNotFound(); |
| 10135 | } |
| 10136 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10137 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 10138 | { |
| 10139 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10140 | "is per-vertex in tessellation control shader stage " |
| 10141 | "but per-patch in tessellation evaluation shader stage"); |
| 10142 | |
| 10143 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10144 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10145 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10146 | if (!m_device->phy().features().tessellationShader) { |
| 10147 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10148 | return; |
| 10149 | } |
| 10150 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10151 | char const *vsSource = |
| 10152 | "#version 450\n" |
| 10153 | "void main(){}\n"; |
| 10154 | char const *tcsSource = |
| 10155 | "#version 450\n" |
| 10156 | "layout(location=0) out int x[];\n" |
| 10157 | "layout(vertices=3) out;\n" |
| 10158 | "void main(){\n" |
| 10159 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10160 | " gl_TessLevelInner[0] = 1;\n" |
| 10161 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10162 | "}\n"; |
| 10163 | char const *tesSource = |
| 10164 | "#version 450\n" |
| 10165 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10166 | "layout(location=0) patch in int x;\n" |
| 10167 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10168 | "void main(){\n" |
| 10169 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10170 | " gl_Position.w = x;\n" |
| 10171 | "}\n"; |
| 10172 | char const *fsSource = |
| 10173 | "#version 450\n" |
| 10174 | "layout(location=0) out vec4 color;\n" |
| 10175 | "void main(){\n" |
| 10176 | " color = vec4(1);\n" |
| 10177 | "}\n"; |
| 10178 | |
| 10179 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10180 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10181 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10182 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10183 | |
| 10184 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10185 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10186 | nullptr, |
| 10187 | 0, |
| 10188 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10189 | VK_FALSE}; |
| 10190 | |
| 10191 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10192 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10193 | nullptr, |
| 10194 | 0, |
| 10195 | 3}; |
| 10196 | |
| 10197 | VkPipelineObj pipe(m_device); |
| 10198 | pipe.SetInputAssembly(&iasci); |
| 10199 | pipe.SetTessellation(&tsci); |
| 10200 | pipe.AddColorAttachment(); |
| 10201 | pipe.AddShader(&vs); |
| 10202 | pipe.AddShader(&tcs); |
| 10203 | pipe.AddShader(&tes); |
| 10204 | pipe.AddShader(&fs); |
| 10205 | |
| 10206 | VkDescriptorSetObj descriptorSet(m_device); |
| 10207 | descriptorSet.AppendDummy(); |
| 10208 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10209 | |
| 10210 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10211 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10212 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10213 | } |
| 10214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10215 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 10216 | m_errorMonitor->SetDesiredFailureMsg( |
| 10217 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10218 | "Duplicate vertex input binding descriptions for binding 0"); |
| 10219 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10220 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10221 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10222 | |
| 10223 | /* Two binding descriptions for binding 0 */ |
| 10224 | VkVertexInputBindingDescription input_bindings[2]; |
| 10225 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10226 | |
| 10227 | VkVertexInputAttributeDescription input_attrib; |
| 10228 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10229 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10230 | |
| 10231 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10232 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10233 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10234 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10235 | "out gl_PerVertex {\n" |
| 10236 | " vec4 gl_Position;\n" |
| 10237 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10238 | "void main(){\n" |
| 10239 | " gl_Position = vec4(x);\n" |
| 10240 | "}\n"; |
| 10241 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10242 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10243 | "\n" |
| 10244 | "layout(location=0) out vec4 color;\n" |
| 10245 | "void main(){\n" |
| 10246 | " color = vec4(1);\n" |
| 10247 | "}\n"; |
| 10248 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10249 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10250 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10251 | |
| 10252 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10253 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10254 | pipe.AddShader(&vs); |
| 10255 | pipe.AddShader(&fs); |
| 10256 | |
| 10257 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 10258 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10259 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10260 | VkDescriptorSetObj descriptorSet(m_device); |
| 10261 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10262 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10263 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10264 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10265 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10266 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10267 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 10268 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 10269 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 10270 | m_errorMonitor->ExpectSuccess(); |
| 10271 | |
| 10272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10273 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10274 | |
| 10275 | if (!m_device->phy().features().tessellationShader) { |
| 10276 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 10277 | return; |
| 10278 | } |
| 10279 | |
| 10280 | VkVertexInputBindingDescription input_bindings[1]; |
| 10281 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10282 | |
| 10283 | VkVertexInputAttributeDescription input_attribs[4]; |
| 10284 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 10285 | input_attribs[0].location = 0; |
| 10286 | input_attribs[0].offset = 0; |
| 10287 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10288 | input_attribs[1].location = 2; |
| 10289 | input_attribs[1].offset = 32; |
| 10290 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10291 | input_attribs[2].location = 4; |
| 10292 | input_attribs[2].offset = 64; |
| 10293 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10294 | input_attribs[3].location = 6; |
| 10295 | input_attribs[3].offset = 96; |
| 10296 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10297 | |
| 10298 | char const *vsSource = |
| 10299 | "#version 450\n" |
| 10300 | "\n" |
| 10301 | "layout(location=0) in dmat4 x;\n" |
| 10302 | "out gl_PerVertex {\n" |
| 10303 | " vec4 gl_Position;\n" |
| 10304 | "};\n" |
| 10305 | "void main(){\n" |
| 10306 | " gl_Position = vec4(x[0][0]);\n" |
| 10307 | "}\n"; |
| 10308 | char const *fsSource = |
| 10309 | "#version 450\n" |
| 10310 | "\n" |
| 10311 | "layout(location=0) out vec4 color;\n" |
| 10312 | "void main(){\n" |
| 10313 | " color = vec4(1);\n" |
| 10314 | "}\n"; |
| 10315 | |
| 10316 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10317 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10318 | |
| 10319 | VkPipelineObj pipe(m_device); |
| 10320 | pipe.AddColorAttachment(); |
| 10321 | pipe.AddShader(&vs); |
| 10322 | pipe.AddShader(&fs); |
| 10323 | |
| 10324 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 10325 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 10326 | |
| 10327 | VkDescriptorSetObj descriptorSet(m_device); |
| 10328 | descriptorSet.AppendDummy(); |
| 10329 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10330 | |
| 10331 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10332 | |
| 10333 | m_errorMonitor->VerifyNotFound(); |
| 10334 | } |
| 10335 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10336 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10337 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10338 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10339 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10341 | |
| 10342 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10343 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10344 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10345 | "out gl_PerVertex {\n" |
| 10346 | " vec4 gl_Position;\n" |
| 10347 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10348 | "void main(){\n" |
| 10349 | " gl_Position = vec4(1);\n" |
| 10350 | "}\n"; |
| 10351 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10352 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10353 | "\n" |
| 10354 | "void main(){\n" |
| 10355 | "}\n"; |
| 10356 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10357 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10358 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10359 | |
| 10360 | VkPipelineObj pipe(m_device); |
| 10361 | pipe.AddShader(&vs); |
| 10362 | pipe.AddShader(&fs); |
| 10363 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10364 | /* set up CB 0, not written */ |
| 10365 | pipe.AddColorAttachment(); |
| 10366 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10367 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10368 | VkDescriptorSetObj descriptorSet(m_device); |
| 10369 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10370 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10371 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10372 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10373 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10374 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10375 | } |
| 10376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10377 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10378 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10379 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10380 | "FS writes to output location 1 with no matching attachment"); |
| 10381 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10382 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10383 | |
| 10384 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10385 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10386 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10387 | "out gl_PerVertex {\n" |
| 10388 | " vec4 gl_Position;\n" |
| 10389 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10390 | "void main(){\n" |
| 10391 | " gl_Position = vec4(1);\n" |
| 10392 | "}\n"; |
| 10393 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10394 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10395 | "\n" |
| 10396 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10397 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10398 | "void main(){\n" |
| 10399 | " x = vec4(1);\n" |
| 10400 | " y = vec4(1);\n" |
| 10401 | "}\n"; |
| 10402 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10403 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10404 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10405 | |
| 10406 | VkPipelineObj pipe(m_device); |
| 10407 | pipe.AddShader(&vs); |
| 10408 | pipe.AddShader(&fs); |
| 10409 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10410 | /* set up CB 0, not written */ |
| 10411 | pipe.AddColorAttachment(); |
| 10412 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10413 | /* FS writes CB 1, but we don't configure it */ |
| 10414 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10415 | VkDescriptorSetObj descriptorSet(m_device); |
| 10416 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10417 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10418 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10419 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10420 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10421 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10422 | } |
| 10423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10424 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10425 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10426 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10427 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10428 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10429 | |
| 10430 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10431 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10432 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10433 | "out gl_PerVertex {\n" |
| 10434 | " vec4 gl_Position;\n" |
| 10435 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10436 | "void main(){\n" |
| 10437 | " gl_Position = vec4(1);\n" |
| 10438 | "}\n"; |
| 10439 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10440 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10441 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10442 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10443 | "void main(){\n" |
| 10444 | " x = ivec4(1);\n" |
| 10445 | "}\n"; |
| 10446 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10447 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10448 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10449 | |
| 10450 | VkPipelineObj pipe(m_device); |
| 10451 | pipe.AddShader(&vs); |
| 10452 | pipe.AddShader(&fs); |
| 10453 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10454 | /* set up CB 0; type is UNORM by default */ |
| 10455 | pipe.AddColorAttachment(); |
| 10456 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10457 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10458 | VkDescriptorSetObj descriptorSet(m_device); |
| 10459 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10460 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10461 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10462 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10463 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10464 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10465 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10467 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10469 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10470 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10472 | |
| 10473 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10474 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10475 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10476 | "out gl_PerVertex {\n" |
| 10477 | " vec4 gl_Position;\n" |
| 10478 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10479 | "void main(){\n" |
| 10480 | " gl_Position = vec4(1);\n" |
| 10481 | "}\n"; |
| 10482 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10483 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10484 | "\n" |
| 10485 | "layout(location=0) out vec4 x;\n" |
| 10486 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10487 | "void main(){\n" |
| 10488 | " x = vec4(bar.y);\n" |
| 10489 | "}\n"; |
| 10490 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10491 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10492 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10493 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10494 | VkPipelineObj pipe(m_device); |
| 10495 | pipe.AddShader(&vs); |
| 10496 | pipe.AddShader(&fs); |
| 10497 | |
| 10498 | /* set up CB 0; type is UNORM by default */ |
| 10499 | pipe.AddColorAttachment(); |
| 10500 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10501 | |
| 10502 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10503 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10504 | |
| 10505 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10506 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10507 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10508 | } |
| 10509 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10510 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10511 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10512 | "not declared in layout"); |
| 10513 | |
| 10514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10515 | |
| 10516 | char const *vsSource = |
| 10517 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10518 | "\n" |
| 10519 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10520 | "out gl_PerVertex {\n" |
| 10521 | " vec4 gl_Position;\n" |
| 10522 | "};\n" |
| 10523 | "void main(){\n" |
| 10524 | " gl_Position = vec4(consts.x);\n" |
| 10525 | "}\n"; |
| 10526 | char const *fsSource = |
| 10527 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10528 | "\n" |
| 10529 | "layout(location=0) out vec4 x;\n" |
| 10530 | "void main(){\n" |
| 10531 | " x = vec4(1);\n" |
| 10532 | "}\n"; |
| 10533 | |
| 10534 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10535 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10536 | |
| 10537 | VkPipelineObj pipe(m_device); |
| 10538 | pipe.AddShader(&vs); |
| 10539 | pipe.AddShader(&fs); |
| 10540 | |
| 10541 | /* set up CB 0; type is UNORM by default */ |
| 10542 | pipe.AddColorAttachment(); |
| 10543 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10544 | |
| 10545 | VkDescriptorSetObj descriptorSet(m_device); |
| 10546 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10547 | |
| 10548 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10549 | |
| 10550 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10551 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10552 | } |
| 10553 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10554 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10555 | m_errorMonitor->SetDesiredFailureMsg( |
| 10556 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10557 | "Shader uses descriptor slot 0.0"); |
| 10558 | |
| 10559 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10560 | |
| 10561 | char const *csSource = |
| 10562 | "#version 450\n" |
| 10563 | "\n" |
| 10564 | "layout(local_size_x=1) in;\n" |
| 10565 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10566 | "void main(){\n" |
| 10567 | " x = vec4(1);\n" |
| 10568 | "}\n"; |
| 10569 | |
| 10570 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10571 | |
| 10572 | VkDescriptorSetObj descriptorSet(m_device); |
| 10573 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10574 | |
| 10575 | VkComputePipelineCreateInfo cpci = { |
| 10576 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10577 | nullptr, 0, { |
| 10578 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10579 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10580 | cs.handle(), "main", nullptr |
| 10581 | }, |
| 10582 | descriptorSet.GetPipelineLayout(), |
| 10583 | VK_NULL_HANDLE, -1 |
| 10584 | }; |
| 10585 | |
| 10586 | VkPipeline pipe; |
| 10587 | VkResult err = vkCreateComputePipelines( |
| 10588 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10589 | |
| 10590 | m_errorMonitor->VerifyFound(); |
| 10591 | |
| 10592 | if (err == VK_SUCCESS) { |
| 10593 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10594 | } |
| 10595 | } |
| 10596 | |
| 10597 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10598 | m_errorMonitor->ExpectSuccess(); |
| 10599 | |
| 10600 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10601 | |
| 10602 | char const *csSource = |
| 10603 | "#version 450\n" |
| 10604 | "\n" |
| 10605 | "layout(local_size_x=1) in;\n" |
| 10606 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10607 | "void main(){\n" |
| 10608 | " // x is not used.\n" |
| 10609 | "}\n"; |
| 10610 | |
| 10611 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10612 | |
| 10613 | VkDescriptorSetObj descriptorSet(m_device); |
| 10614 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10615 | |
| 10616 | VkComputePipelineCreateInfo cpci = { |
| 10617 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10618 | nullptr, 0, { |
| 10619 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10620 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10621 | cs.handle(), "main", nullptr |
| 10622 | }, |
| 10623 | descriptorSet.GetPipelineLayout(), |
| 10624 | VK_NULL_HANDLE, -1 |
| 10625 | }; |
| 10626 | |
| 10627 | VkPipeline pipe; |
| 10628 | VkResult err = vkCreateComputePipelines( |
| 10629 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10630 | |
| 10631 | m_errorMonitor->VerifyNotFound(); |
| 10632 | |
| 10633 | if (err == VK_SUCCESS) { |
| 10634 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10635 | } |
| 10636 | } |
| 10637 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10638 | #endif // SHADER_CHECKER_TESTS |
| 10639 | |
| 10640 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10641 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10642 | m_errorMonitor->SetDesiredFailureMsg( |
| 10643 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10644 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10645 | |
| 10646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10647 | |
| 10648 | // Create an image |
| 10649 | VkImage image; |
| 10650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10651 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10652 | const int32_t tex_width = 32; |
| 10653 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10654 | |
| 10655 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10656 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10657 | image_create_info.pNext = NULL; |
| 10658 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10659 | image_create_info.format = tex_format; |
| 10660 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10661 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10662 | image_create_info.extent.depth = 1; |
| 10663 | image_create_info.mipLevels = 1; |
| 10664 | image_create_info.arrayLayers = 1; |
| 10665 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10666 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10667 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10668 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10669 | |
| 10670 | // Introduce error by sending down a bogus width extent |
| 10671 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10672 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10673 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10674 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10675 | } |
| 10676 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10677 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10678 | m_errorMonitor->SetDesiredFailureMsg( |
| 10679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10680 | "CreateImage extents is 0 for at least one required dimension"); |
| 10681 | |
| 10682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10683 | |
| 10684 | // Create an image |
| 10685 | VkImage image; |
| 10686 | |
| 10687 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10688 | const int32_t tex_width = 32; |
| 10689 | const int32_t tex_height = 32; |
| 10690 | |
| 10691 | VkImageCreateInfo image_create_info = {}; |
| 10692 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10693 | image_create_info.pNext = NULL; |
| 10694 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10695 | image_create_info.format = tex_format; |
| 10696 | image_create_info.extent.width = tex_width; |
| 10697 | image_create_info.extent.height = tex_height; |
| 10698 | image_create_info.extent.depth = 1; |
| 10699 | image_create_info.mipLevels = 1; |
| 10700 | image_create_info.arrayLayers = 1; |
| 10701 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10702 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10703 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10704 | image_create_info.flags = 0; |
| 10705 | |
| 10706 | // Introduce error by sending down a bogus width extent |
| 10707 | image_create_info.extent.width = 0; |
| 10708 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10709 | |
| 10710 | m_errorMonitor->VerifyFound(); |
| 10711 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10712 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10713 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10714 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10715 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10716 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10717 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10718 | m_errorMonitor->SetDesiredFailureMsg( |
| 10719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10720 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10721 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10723 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10724 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10725 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10727 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10728 | const int32_t tex_width = 32; |
| 10729 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10730 | |
| 10731 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10732 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10733 | image_create_info.pNext = NULL; |
| 10734 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10735 | image_create_info.format = tex_format; |
| 10736 | image_create_info.extent.width = tex_width; |
| 10737 | image_create_info.extent.height = tex_height; |
| 10738 | image_create_info.extent.depth = 1; |
| 10739 | image_create_info.mipLevels = 1; |
| 10740 | image_create_info.arrayLayers = 1; |
| 10741 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10742 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10743 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10744 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10745 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10746 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10747 | ASSERT_VK_SUCCESS(err); |
| 10748 | |
| 10749 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10750 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10751 | image_view_create_info.image = image; |
| 10752 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10753 | image_view_create_info.format = tex_format; |
| 10754 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10755 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10756 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10757 | image_view_create_info.subresourceRange.aspectMask = |
| 10758 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10759 | |
| 10760 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10761 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10762 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10763 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10764 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10765 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10766 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10767 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10768 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10769 | TEST_DESCRIPTION( |
| 10770 | "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] | 10771 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10772 | "vkCreateImageView: Color image " |
| 10773 | "formats must have ONLY the " |
| 10774 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10775 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10776 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10778 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10779 | VkImageObj image(m_device); |
| 10780 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10781 | VK_IMAGE_TILING_LINEAR, 0); |
| 10782 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10783 | |
| 10784 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10785 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10786 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10787 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10788 | image_view_create_info.format = tex_format; |
| 10789 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10790 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10791 | // Cause an error by setting an invalid image aspect |
| 10792 | image_view_create_info.subresourceRange.aspectMask = |
| 10793 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10794 | |
| 10795 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10796 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10797 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10798 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10799 | } |
| 10800 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10801 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10802 | VkResult err; |
| 10803 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10804 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10805 | m_errorMonitor->SetDesiredFailureMsg( |
| 10806 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10807 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10808 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10810 | |
| 10811 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10812 | VkImage srcImage; |
| 10813 | VkImage dstImage; |
| 10814 | VkDeviceMemory srcMem; |
| 10815 | VkDeviceMemory destMem; |
| 10816 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10817 | |
| 10818 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10819 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10820 | image_create_info.pNext = NULL; |
| 10821 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10822 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10823 | image_create_info.extent.width = 32; |
| 10824 | image_create_info.extent.height = 32; |
| 10825 | image_create_info.extent.depth = 1; |
| 10826 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10827 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10828 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10829 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10830 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10831 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10833 | err = |
| 10834 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10835 | ASSERT_VK_SUCCESS(err); |
| 10836 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10837 | err = |
| 10838 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10839 | ASSERT_VK_SUCCESS(err); |
| 10840 | |
| 10841 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10842 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10843 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10844 | memAlloc.pNext = NULL; |
| 10845 | memAlloc.allocationSize = 0; |
| 10846 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10847 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10848 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10849 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10850 | pass = |
| 10851 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10852 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10853 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10854 | ASSERT_VK_SUCCESS(err); |
| 10855 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10856 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10857 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10858 | pass = |
| 10859 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10860 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10861 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10862 | ASSERT_VK_SUCCESS(err); |
| 10863 | |
| 10864 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10865 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10866 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10867 | ASSERT_VK_SUCCESS(err); |
| 10868 | |
| 10869 | BeginCommandBuffer(); |
| 10870 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10871 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10872 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10873 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10874 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10875 | copyRegion.srcOffset.x = 0; |
| 10876 | copyRegion.srcOffset.y = 0; |
| 10877 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10878 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10879 | copyRegion.dstSubresource.mipLevel = 0; |
| 10880 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10881 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10882 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10883 | copyRegion.dstOffset.x = 0; |
| 10884 | copyRegion.dstOffset.y = 0; |
| 10885 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10886 | copyRegion.extent.width = 1; |
| 10887 | copyRegion.extent.height = 1; |
| 10888 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10889 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10890 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10891 | EndCommandBuffer(); |
| 10892 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10893 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10894 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10895 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10896 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10897 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10898 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10899 | } |
| 10900 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10901 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10902 | |
| 10903 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10904 | |
| 10905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10906 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10907 | VkImageObj image(m_device); |
| 10908 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10909 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10910 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10911 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10912 | ASSERT_TRUE(image.initialized()); |
| 10913 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10914 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10915 | VkImageCreateInfo image_create_info; |
| 10916 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10917 | image_create_info.pNext = NULL; |
| 10918 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10919 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10920 | image_create_info.extent.width = 32; |
| 10921 | image_create_info.extent.height = 32; |
| 10922 | image_create_info.extent.depth = 1; |
| 10923 | image_create_info.mipLevels = 1; |
| 10924 | image_create_info.arrayLayers = 1; |
| 10925 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10926 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10927 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10928 | image_create_info.flags = 0; |
| 10929 | |
| 10930 | m_errorMonitor->SetDesiredFailureMsg( |
| 10931 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10932 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10933 | |
| 10934 | VkImage localImage; |
| 10935 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10936 | m_errorMonitor->VerifyFound(); |
| 10937 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10938 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10939 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10940 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10941 | VkFormat format = static_cast<VkFormat>(f); |
| 10942 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10943 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10944 | fProps.optimalTilingFeatures == 0) { |
| 10945 | unsupported = format; |
| 10946 | break; |
| 10947 | } |
| 10948 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10949 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10950 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10951 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10952 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10953 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10954 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10955 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10956 | m_errorMonitor->VerifyFound(); |
| 10957 | } |
| 10958 | } |
| 10959 | |
| 10960 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10961 | VkResult ret; |
| 10962 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10963 | |
| 10964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10965 | |
| 10966 | VkImageObj image(m_device); |
| 10967 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10968 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10969 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10970 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10971 | ASSERT_TRUE(image.initialized()); |
| 10972 | |
| 10973 | VkImageView imgView; |
| 10974 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10975 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10976 | imgViewInfo.image = image.handle(); |
| 10977 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10978 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10979 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10980 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10981 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10982 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10983 | |
| 10984 | m_errorMonitor->SetDesiredFailureMsg( |
| 10985 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10986 | "vkCreateImageView called with baseMipLevel"); |
| 10987 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10988 | // VIEW_CREATE_ERROR |
| 10989 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10990 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10991 | m_errorMonitor->VerifyFound(); |
| 10992 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10993 | |
| 10994 | m_errorMonitor->SetDesiredFailureMsg( |
| 10995 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10996 | "vkCreateImageView called with baseArrayLayer"); |
| 10997 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10998 | // VIEW_CREATE_ERROR |
| 10999 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 11000 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11001 | m_errorMonitor->VerifyFound(); |
| 11002 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 11003 | |
| 11004 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11005 | "vkCreateImageView called with 0 in " |
| 11006 | "pCreateInfo->subresourceRange." |
| 11007 | "levelCount"); |
| 11008 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11009 | imgViewInfo.subresourceRange.levelCount = 0; |
| 11010 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11011 | m_errorMonitor->VerifyFound(); |
| 11012 | imgViewInfo.subresourceRange.levelCount = 1; |
| 11013 | |
| 11014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11015 | "vkCreateImageView called with 0 in " |
| 11016 | "pCreateInfo->subresourceRange." |
| 11017 | "layerCount"); |
| 11018 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11019 | imgViewInfo.subresourceRange.layerCount = 0; |
| 11020 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11021 | m_errorMonitor->VerifyFound(); |
| 11022 | imgViewInfo.subresourceRange.layerCount = 1; |
| 11023 | |
| 11024 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11025 | "but both must be color formats"); |
| 11026 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 11027 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11028 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11029 | m_errorMonitor->VerifyFound(); |
| 11030 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11031 | |
| 11032 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11033 | "Formats MUST be IDENTICAL unless " |
| 11034 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 11035 | "was set on image creation."); |
| 11036 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 11037 | // VIEW_CREATE_ERROR |
| 11038 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 11039 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11040 | m_errorMonitor->VerifyFound(); |
| 11041 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11042 | |
| 11043 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11044 | "can support ImageViews with " |
| 11045 | "differing formats but they must be " |
| 11046 | "in the same compatibility class."); |
| 11047 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 11048 | // VIEW_CREATE_ERROR |
| 11049 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 11050 | VkImage mutImage; |
| 11051 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 11052 | assert( |
| 11053 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 11054 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 11055 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 11056 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11057 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 11058 | ASSERT_VK_SUCCESS(ret); |
| 11059 | imgViewInfo.image = mutImage; |
| 11060 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11061 | m_errorMonitor->VerifyFound(); |
| 11062 | imgViewInfo.image = image.handle(); |
| 11063 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 11064 | } |
| 11065 | |
| 11066 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 11067 | |
| 11068 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 11069 | |
| 11070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11071 | |
| 11072 | VkImageObj image(m_device); |
| 11073 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 11074 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 11075 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 11076 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 11077 | ASSERT_TRUE(image.initialized()); |
| 11078 | |
| 11079 | m_errorMonitor->SetDesiredFailureMsg( |
| 11080 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11081 | "number of layers in image subresource is zero"); |
| 11082 | vk_testing::Buffer buffer; |
| 11083 | VkMemoryPropertyFlags reqs = 0; |
| 11084 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 11085 | VkBufferImageCopy region = {}; |
| 11086 | region.bufferRowLength = 128; |
| 11087 | region.bufferImageHeight = 128; |
| 11088 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11089 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 11090 | region.imageSubresource.layerCount = 0; |
| 11091 | region.imageExtent.height = 4; |
| 11092 | region.imageExtent.width = 4; |
| 11093 | region.imageExtent.depth = 1; |
| 11094 | m_commandBuffer->BeginCommandBuffer(); |
| 11095 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11096 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11097 | 1, ®ion); |
| 11098 | m_errorMonitor->VerifyFound(); |
| 11099 | region.imageSubresource.layerCount = 1; |
| 11100 | |
| 11101 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11102 | "aspectMasks for each region must " |
| 11103 | "specify only COLOR or DEPTH or " |
| 11104 | "STENCIL"); |
| 11105 | // Expect MISMATCHED_IMAGE_ASPECT |
| 11106 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 11107 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11108 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11109 | 1, ®ion); |
| 11110 | m_errorMonitor->VerifyFound(); |
| 11111 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11112 | |
| 11113 | m_errorMonitor->SetDesiredFailureMsg( |
| 11114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11115 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 11116 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 11117 | // Expect INVALID_FILTER |
| 11118 | VkImageObj intImage1(m_device); |
| 11119 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 11120 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11121 | 0); |
| 11122 | VkImageObj intImage2(m_device); |
| 11123 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 11124 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11125 | 0); |
| 11126 | VkImageBlit blitRegion = {}; |
| 11127 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11128 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 11129 | blitRegion.srcSubresource.layerCount = 1; |
| 11130 | blitRegion.srcSubresource.mipLevel = 0; |
| 11131 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11132 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 11133 | blitRegion.dstSubresource.layerCount = 1; |
| 11134 | blitRegion.dstSubresource.mipLevel = 0; |
| 11135 | |
| 11136 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 11137 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 11138 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 11139 | m_errorMonitor->VerifyFound(); |
| 11140 | |
| 11141 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11142 | "called with 0 in ppMemoryBarriers"); |
| 11143 | VkImageMemoryBarrier img_barrier; |
| 11144 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 11145 | img_barrier.pNext = NULL; |
| 11146 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 11147 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 11148 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11149 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11150 | img_barrier.image = image.handle(); |
| 11151 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11152 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11153 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11154 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 11155 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 11156 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 11157 | img_barrier.subresourceRange.layerCount = 0; |
| 11158 | img_barrier.subresourceRange.levelCount = 1; |
| 11159 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 11160 | VK_PIPELINE_STAGE_HOST_BIT, |
| 11161 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 11162 | nullptr, 1, &img_barrier); |
| 11163 | m_errorMonitor->VerifyFound(); |
| 11164 | img_barrier.subresourceRange.layerCount = 1; |
| 11165 | } |
| 11166 | |
| 11167 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 11168 | |
| 11169 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 11170 | |
| 11171 | m_errorMonitor->SetDesiredFailureMsg( |
| 11172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11173 | "CreateImage extents exceed allowable limits for format"); |
| 11174 | VkImageCreateInfo image_create_info = {}; |
| 11175 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11176 | image_create_info.pNext = NULL; |
| 11177 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11178 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11179 | image_create_info.extent.width = 32; |
| 11180 | image_create_info.extent.height = 32; |
| 11181 | image_create_info.extent.depth = 1; |
| 11182 | image_create_info.mipLevels = 1; |
| 11183 | image_create_info.arrayLayers = 1; |
| 11184 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11185 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11186 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11187 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11188 | image_create_info.flags = 0; |
| 11189 | |
| 11190 | VkImage nullImg; |
| 11191 | VkImageFormatProperties imgFmtProps; |
| 11192 | vkGetPhysicalDeviceImageFormatProperties( |
| 11193 | gpu(), image_create_info.format, image_create_info.imageType, |
| 11194 | image_create_info.tiling, image_create_info.usage, |
| 11195 | image_create_info.flags, &imgFmtProps); |
| 11196 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 11197 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11198 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11199 | m_errorMonitor->VerifyFound(); |
| 11200 | image_create_info.extent.depth = 1; |
| 11201 | |
| 11202 | m_errorMonitor->SetDesiredFailureMsg( |
| 11203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11204 | "exceeds allowable maximum supported by format of"); |
| 11205 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 11206 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11207 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11208 | m_errorMonitor->VerifyFound(); |
| 11209 | image_create_info.mipLevels = 1; |
| 11210 | |
| 11211 | m_errorMonitor->SetDesiredFailureMsg( |
| 11212 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11213 | "exceeds allowable maximum supported by format of"); |
| 11214 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 11215 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11216 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11217 | m_errorMonitor->VerifyFound(); |
| 11218 | image_create_info.arrayLayers = 1; |
| 11219 | |
| 11220 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11221 | "is not supported by format"); |
| 11222 | int samples = imgFmtProps.sampleCounts >> 1; |
| 11223 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 11224 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11225 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11226 | m_errorMonitor->VerifyFound(); |
| 11227 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11228 | |
| 11229 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11230 | "pCreateInfo->initialLayout, must be " |
| 11231 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 11232 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 11233 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11234 | // Expect INVALID_LAYOUT |
| 11235 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11236 | m_errorMonitor->VerifyFound(); |
| 11237 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11238 | } |
| 11239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11240 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11241 | VkResult err; |
| 11242 | bool pass; |
| 11243 | |
| 11244 | // Create color images with different format sizes and try to copy between them |
| 11245 | m_errorMonitor->SetDesiredFailureMsg( |
| 11246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11247 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 11248 | |
| 11249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11250 | |
| 11251 | // Create two images of different types and try to copy between them |
| 11252 | VkImage srcImage; |
| 11253 | VkImage dstImage; |
| 11254 | VkDeviceMemory srcMem; |
| 11255 | VkDeviceMemory destMem; |
| 11256 | VkMemoryRequirements memReqs; |
| 11257 | |
| 11258 | VkImageCreateInfo image_create_info = {}; |
| 11259 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11260 | image_create_info.pNext = NULL; |
| 11261 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11262 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11263 | image_create_info.extent.width = 32; |
| 11264 | image_create_info.extent.height = 32; |
| 11265 | image_create_info.extent.depth = 1; |
| 11266 | image_create_info.mipLevels = 1; |
| 11267 | image_create_info.arrayLayers = 1; |
| 11268 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11269 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11270 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11271 | image_create_info.flags = 0; |
| 11272 | |
| 11273 | err = |
| 11274 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 11275 | ASSERT_VK_SUCCESS(err); |
| 11276 | |
| 11277 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11278 | // Introduce failure by creating second image with a different-sized format. |
| 11279 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 11280 | |
| 11281 | err = |
| 11282 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 11283 | ASSERT_VK_SUCCESS(err); |
| 11284 | |
| 11285 | // Allocate memory |
| 11286 | VkMemoryAllocateInfo memAlloc = {}; |
| 11287 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11288 | memAlloc.pNext = NULL; |
| 11289 | memAlloc.allocationSize = 0; |
| 11290 | memAlloc.memoryTypeIndex = 0; |
| 11291 | |
| 11292 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 11293 | memAlloc.allocationSize = memReqs.size; |
| 11294 | pass = |
| 11295 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11296 | ASSERT_TRUE(pass); |
| 11297 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 11298 | ASSERT_VK_SUCCESS(err); |
| 11299 | |
| 11300 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 11301 | memAlloc.allocationSize = memReqs.size; |
| 11302 | pass = |
| 11303 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11304 | ASSERT_TRUE(pass); |
| 11305 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 11306 | ASSERT_VK_SUCCESS(err); |
| 11307 | |
| 11308 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11309 | ASSERT_VK_SUCCESS(err); |
| 11310 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 11311 | ASSERT_VK_SUCCESS(err); |
| 11312 | |
| 11313 | BeginCommandBuffer(); |
| 11314 | VkImageCopy copyRegion; |
| 11315 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11316 | copyRegion.srcSubresource.mipLevel = 0; |
| 11317 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 11318 | copyRegion.srcSubresource.layerCount = 0; |
| 11319 | copyRegion.srcOffset.x = 0; |
| 11320 | copyRegion.srcOffset.y = 0; |
| 11321 | copyRegion.srcOffset.z = 0; |
| 11322 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11323 | copyRegion.dstSubresource.mipLevel = 0; |
| 11324 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11325 | copyRegion.dstSubresource.layerCount = 0; |
| 11326 | copyRegion.dstOffset.x = 0; |
| 11327 | copyRegion.dstOffset.y = 0; |
| 11328 | copyRegion.dstOffset.z = 0; |
| 11329 | copyRegion.extent.width = 1; |
| 11330 | copyRegion.extent.height = 1; |
| 11331 | copyRegion.extent.depth = 1; |
| 11332 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11333 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 11334 | EndCommandBuffer(); |
| 11335 | |
| 11336 | m_errorMonitor->VerifyFound(); |
| 11337 | |
| 11338 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 11339 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 11340 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11341 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11342 | } |
| 11343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11344 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 11345 | VkResult err; |
| 11346 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11347 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11348 | // 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] | 11349 | m_errorMonitor->SetDesiredFailureMsg( |
| 11350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11351 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11352 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11354 | |
| 11355 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11356 | VkImage srcImage; |
| 11357 | VkImage dstImage; |
| 11358 | VkDeviceMemory srcMem; |
| 11359 | VkDeviceMemory destMem; |
| 11360 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11361 | |
| 11362 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11363 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11364 | image_create_info.pNext = NULL; |
| 11365 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11366 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11367 | image_create_info.extent.width = 32; |
| 11368 | image_create_info.extent.height = 32; |
| 11369 | image_create_info.extent.depth = 1; |
| 11370 | image_create_info.mipLevels = 1; |
| 11371 | image_create_info.arrayLayers = 1; |
| 11372 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11373 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11374 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11375 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11377 | err = |
| 11378 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11379 | ASSERT_VK_SUCCESS(err); |
| 11380 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11381 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11382 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11383 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11384 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11385 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11386 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11388 | err = |
| 11389 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11390 | ASSERT_VK_SUCCESS(err); |
| 11391 | |
| 11392 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11393 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11394 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11395 | memAlloc.pNext = NULL; |
| 11396 | memAlloc.allocationSize = 0; |
| 11397 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11398 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11399 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11400 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11401 | pass = |
| 11402 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11403 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11404 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11405 | ASSERT_VK_SUCCESS(err); |
| 11406 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11407 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11408 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11409 | pass = |
| 11410 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11411 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11412 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11413 | ASSERT_VK_SUCCESS(err); |
| 11414 | |
| 11415 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11416 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11417 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11418 | ASSERT_VK_SUCCESS(err); |
| 11419 | |
| 11420 | BeginCommandBuffer(); |
| 11421 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11422 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11423 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11424 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11425 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11426 | copyRegion.srcOffset.x = 0; |
| 11427 | copyRegion.srcOffset.y = 0; |
| 11428 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11429 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11430 | copyRegion.dstSubresource.mipLevel = 0; |
| 11431 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11432 | copyRegion.dstSubresource.layerCount = 0; |
| 11433 | copyRegion.dstOffset.x = 0; |
| 11434 | copyRegion.dstOffset.y = 0; |
| 11435 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11436 | copyRegion.extent.width = 1; |
| 11437 | copyRegion.extent.height = 1; |
| 11438 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11439 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11440 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11441 | EndCommandBuffer(); |
| 11442 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11443 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11444 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11445 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11446 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11447 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11448 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11449 | } |
| 11450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11451 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11452 | VkResult err; |
| 11453 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11455 | m_errorMonitor->SetDesiredFailureMsg( |
| 11456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11457 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11458 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11459 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11460 | |
| 11461 | // 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] | 11462 | VkImage srcImage; |
| 11463 | VkImage dstImage; |
| 11464 | VkDeviceMemory srcMem; |
| 11465 | VkDeviceMemory destMem; |
| 11466 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11467 | |
| 11468 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11469 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11470 | image_create_info.pNext = NULL; |
| 11471 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11472 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11473 | image_create_info.extent.width = 32; |
| 11474 | image_create_info.extent.height = 1; |
| 11475 | image_create_info.extent.depth = 1; |
| 11476 | image_create_info.mipLevels = 1; |
| 11477 | image_create_info.arrayLayers = 1; |
| 11478 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11479 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11480 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11481 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11483 | err = |
| 11484 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11485 | ASSERT_VK_SUCCESS(err); |
| 11486 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11487 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11488 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11489 | err = |
| 11490 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11491 | ASSERT_VK_SUCCESS(err); |
| 11492 | |
| 11493 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11494 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11495 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11496 | memAlloc.pNext = NULL; |
| 11497 | memAlloc.allocationSize = 0; |
| 11498 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11499 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11500 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11501 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11502 | pass = |
| 11503 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11504 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11505 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11506 | ASSERT_VK_SUCCESS(err); |
| 11507 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11508 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11509 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11510 | pass = |
| 11511 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11512 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11513 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11514 | ASSERT_VK_SUCCESS(err); |
| 11515 | |
| 11516 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11517 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11518 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11519 | ASSERT_VK_SUCCESS(err); |
| 11520 | |
| 11521 | BeginCommandBuffer(); |
| 11522 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11523 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11524 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11525 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11526 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11527 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11528 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11529 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11530 | resolveRegion.srcOffset.x = 0; |
| 11531 | resolveRegion.srcOffset.y = 0; |
| 11532 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11533 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11534 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11535 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11536 | resolveRegion.dstSubresource.layerCount = 0; |
| 11537 | resolveRegion.dstOffset.x = 0; |
| 11538 | resolveRegion.dstOffset.y = 0; |
| 11539 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11540 | resolveRegion.extent.width = 1; |
| 11541 | resolveRegion.extent.height = 1; |
| 11542 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11543 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11544 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11545 | EndCommandBuffer(); |
| 11546 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11547 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11548 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11549 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11550 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11551 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11552 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11553 | } |
| 11554 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11555 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11556 | VkResult err; |
| 11557 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11558 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11559 | m_errorMonitor->SetDesiredFailureMsg( |
| 11560 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11561 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11562 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11564 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11565 | // 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] | 11566 | VkImage srcImage; |
| 11567 | VkImage dstImage; |
| 11568 | VkDeviceMemory srcMem; |
| 11569 | VkDeviceMemory destMem; |
| 11570 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11571 | |
| 11572 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11573 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11574 | image_create_info.pNext = NULL; |
| 11575 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11576 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11577 | image_create_info.extent.width = 32; |
| 11578 | image_create_info.extent.height = 1; |
| 11579 | image_create_info.extent.depth = 1; |
| 11580 | image_create_info.mipLevels = 1; |
| 11581 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11582 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11583 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11584 | // Note: Some implementations expect color attachment usage for any |
| 11585 | // multisample surface |
| 11586 | image_create_info.usage = |
| 11587 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11588 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11589 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11590 | err = |
| 11591 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11592 | ASSERT_VK_SUCCESS(err); |
| 11593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11594 | // Note: Some implementations expect color attachment usage for any |
| 11595 | // multisample surface |
| 11596 | image_create_info.usage = |
| 11597 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11598 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11599 | err = |
| 11600 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11601 | ASSERT_VK_SUCCESS(err); |
| 11602 | |
| 11603 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11604 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11605 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11606 | memAlloc.pNext = NULL; |
| 11607 | memAlloc.allocationSize = 0; |
| 11608 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11609 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11610 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11611 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11612 | pass = |
| 11613 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11614 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11615 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11616 | ASSERT_VK_SUCCESS(err); |
| 11617 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11618 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11619 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11620 | pass = |
| 11621 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11622 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11623 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11624 | ASSERT_VK_SUCCESS(err); |
| 11625 | |
| 11626 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11627 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11628 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11629 | ASSERT_VK_SUCCESS(err); |
| 11630 | |
| 11631 | BeginCommandBuffer(); |
| 11632 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11633 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11634 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11635 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11636 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11637 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11638 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11639 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11640 | resolveRegion.srcOffset.x = 0; |
| 11641 | resolveRegion.srcOffset.y = 0; |
| 11642 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11643 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11644 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11645 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11646 | resolveRegion.dstSubresource.layerCount = 0; |
| 11647 | resolveRegion.dstOffset.x = 0; |
| 11648 | resolveRegion.dstOffset.y = 0; |
| 11649 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11650 | resolveRegion.extent.width = 1; |
| 11651 | resolveRegion.extent.height = 1; |
| 11652 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11653 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11654 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11655 | EndCommandBuffer(); |
| 11656 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11657 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11658 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11659 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11660 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11661 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11662 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11663 | } |
| 11664 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11665 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11666 | VkResult err; |
| 11667 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11668 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11669 | m_errorMonitor->SetDesiredFailureMsg( |
| 11670 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11671 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11672 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11674 | |
| 11675 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11676 | VkImage srcImage; |
| 11677 | VkImage dstImage; |
| 11678 | VkDeviceMemory srcMem; |
| 11679 | VkDeviceMemory destMem; |
| 11680 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11681 | |
| 11682 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11683 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11684 | image_create_info.pNext = NULL; |
| 11685 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11686 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11687 | image_create_info.extent.width = 32; |
| 11688 | image_create_info.extent.height = 1; |
| 11689 | image_create_info.extent.depth = 1; |
| 11690 | image_create_info.mipLevels = 1; |
| 11691 | image_create_info.arrayLayers = 1; |
| 11692 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11693 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11694 | // Note: Some implementations expect color attachment usage for any |
| 11695 | // multisample surface |
| 11696 | image_create_info.usage = |
| 11697 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11698 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11700 | err = |
| 11701 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11702 | ASSERT_VK_SUCCESS(err); |
| 11703 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11704 | // Set format to something other than source image |
| 11705 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11706 | // Note: Some implementations expect color attachment usage for any |
| 11707 | // multisample surface |
| 11708 | image_create_info.usage = |
| 11709 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11710 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11712 | err = |
| 11713 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11714 | ASSERT_VK_SUCCESS(err); |
| 11715 | |
| 11716 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11717 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11718 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11719 | memAlloc.pNext = NULL; |
| 11720 | memAlloc.allocationSize = 0; |
| 11721 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11722 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11723 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11724 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11725 | pass = |
| 11726 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11727 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11728 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11729 | ASSERT_VK_SUCCESS(err); |
| 11730 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11731 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11732 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11733 | pass = |
| 11734 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11735 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11736 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11737 | ASSERT_VK_SUCCESS(err); |
| 11738 | |
| 11739 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11740 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11741 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11742 | ASSERT_VK_SUCCESS(err); |
| 11743 | |
| 11744 | BeginCommandBuffer(); |
| 11745 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11746 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11747 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11748 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11749 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11750 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11751 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11752 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11753 | resolveRegion.srcOffset.x = 0; |
| 11754 | resolveRegion.srcOffset.y = 0; |
| 11755 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11756 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11757 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11758 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11759 | resolveRegion.dstSubresource.layerCount = 0; |
| 11760 | resolveRegion.dstOffset.x = 0; |
| 11761 | resolveRegion.dstOffset.y = 0; |
| 11762 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11763 | resolveRegion.extent.width = 1; |
| 11764 | resolveRegion.extent.height = 1; |
| 11765 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11766 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11767 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11768 | EndCommandBuffer(); |
| 11769 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11770 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11771 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11772 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11773 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11774 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11775 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11776 | } |
| 11777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11778 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11779 | VkResult err; |
| 11780 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11782 | m_errorMonitor->SetDesiredFailureMsg( |
| 11783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11784 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11785 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11786 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11787 | |
| 11788 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11789 | VkImage srcImage; |
| 11790 | VkImage dstImage; |
| 11791 | VkDeviceMemory srcMem; |
| 11792 | VkDeviceMemory destMem; |
| 11793 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11794 | |
| 11795 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11796 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11797 | image_create_info.pNext = NULL; |
| 11798 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11799 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11800 | image_create_info.extent.width = 32; |
| 11801 | image_create_info.extent.height = 1; |
| 11802 | image_create_info.extent.depth = 1; |
| 11803 | image_create_info.mipLevels = 1; |
| 11804 | image_create_info.arrayLayers = 1; |
| 11805 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11806 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11807 | // Note: Some implementations expect color attachment usage for any |
| 11808 | // multisample surface |
| 11809 | image_create_info.usage = |
| 11810 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11811 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11812 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11813 | err = |
| 11814 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11815 | ASSERT_VK_SUCCESS(err); |
| 11816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11817 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11818 | // Note: Some implementations expect color attachment usage for any |
| 11819 | // multisample surface |
| 11820 | image_create_info.usage = |
| 11821 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11822 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11824 | err = |
| 11825 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11826 | ASSERT_VK_SUCCESS(err); |
| 11827 | |
| 11828 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11829 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11830 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11831 | memAlloc.pNext = NULL; |
| 11832 | memAlloc.allocationSize = 0; |
| 11833 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11834 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11835 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11836 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11837 | pass = |
| 11838 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11839 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11840 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11841 | ASSERT_VK_SUCCESS(err); |
| 11842 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11843 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11844 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11845 | pass = |
| 11846 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11847 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11848 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11849 | ASSERT_VK_SUCCESS(err); |
| 11850 | |
| 11851 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11852 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11853 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11854 | ASSERT_VK_SUCCESS(err); |
| 11855 | |
| 11856 | BeginCommandBuffer(); |
| 11857 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11858 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11859 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11860 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11861 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11862 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11863 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11864 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11865 | resolveRegion.srcOffset.x = 0; |
| 11866 | resolveRegion.srcOffset.y = 0; |
| 11867 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11868 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11869 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11870 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11871 | resolveRegion.dstSubresource.layerCount = 0; |
| 11872 | resolveRegion.dstOffset.x = 0; |
| 11873 | resolveRegion.dstOffset.y = 0; |
| 11874 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11875 | resolveRegion.extent.width = 1; |
| 11876 | resolveRegion.extent.height = 1; |
| 11877 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11878 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11879 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11880 | EndCommandBuffer(); |
| 11881 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11882 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11883 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11884 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11885 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11886 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11887 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11888 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11890 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11891 | // 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] | 11892 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11893 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11894 | // The image format check comes 2nd in validation so we trigger it first, |
| 11895 | // 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] | 11896 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11897 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11898 | m_errorMonitor->SetDesiredFailureMsg( |
| 11899 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11900 | "Combination depth/stencil image formats can have only the "); |
| 11901 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11902 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11903 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11904 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11905 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11906 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11907 | |
| 11908 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11909 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11910 | ds_pool_ci.pNext = NULL; |
| 11911 | ds_pool_ci.maxSets = 1; |
| 11912 | ds_pool_ci.poolSizeCount = 1; |
| 11913 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11914 | |
| 11915 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11916 | err = |
| 11917 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11918 | ASSERT_VK_SUCCESS(err); |
| 11919 | |
| 11920 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11921 | dsl_binding.binding = 0; |
| 11922 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11923 | dsl_binding.descriptorCount = 1; |
| 11924 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11925 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11926 | |
| 11927 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11928 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11929 | ds_layout_ci.pNext = NULL; |
| 11930 | ds_layout_ci.bindingCount = 1; |
| 11931 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11932 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11933 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11934 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11935 | ASSERT_VK_SUCCESS(err); |
| 11936 | |
| 11937 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11938 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11939 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11940 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11941 | alloc_info.descriptorPool = ds_pool; |
| 11942 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11943 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11944 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11945 | ASSERT_VK_SUCCESS(err); |
| 11946 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11947 | VkImage image_bad; |
| 11948 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11949 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11950 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11951 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11952 | const int32_t tex_width = 32; |
| 11953 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11954 | |
| 11955 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11956 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11957 | image_create_info.pNext = NULL; |
| 11958 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11959 | image_create_info.format = tex_format_bad; |
| 11960 | image_create_info.extent.width = tex_width; |
| 11961 | image_create_info.extent.height = tex_height; |
| 11962 | image_create_info.extent.depth = 1; |
| 11963 | image_create_info.mipLevels = 1; |
| 11964 | image_create_info.arrayLayers = 1; |
| 11965 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11966 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11967 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11968 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11969 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11971 | err = |
| 11972 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11973 | ASSERT_VK_SUCCESS(err); |
| 11974 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11975 | image_create_info.usage = |
| 11976 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11977 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11978 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11979 | ASSERT_VK_SUCCESS(err); |
| 11980 | |
| 11981 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11982 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11983 | image_view_create_info.image = image_bad; |
| 11984 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11985 | image_view_create_info.format = tex_format_bad; |
| 11986 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11987 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11988 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11989 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11990 | image_view_create_info.subresourceRange.aspectMask = |
| 11991 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11992 | |
| 11993 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11994 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11995 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11996 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11997 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11998 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11999 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 12000 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12001 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 12002 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12003 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12004 | |
| 12005 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 12006 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 12007 | "ClearDepthStencilImage with a color image."); |
| 12008 | |
| 12009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 12011 | |
| 12012 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 12013 | BeginCommandBuffer(); |
| 12014 | m_commandBuffer->EndRenderPass(); |
| 12015 | |
| 12016 | // Color image |
| 12017 | VkClearColorValue clear_color; |
| 12018 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 12019 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 12020 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12021 | const int32_t img_width = 32; |
| 12022 | const int32_t img_height = 32; |
| 12023 | VkImageCreateInfo image_create_info = {}; |
| 12024 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12025 | image_create_info.pNext = NULL; |
| 12026 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12027 | image_create_info.format = color_format; |
| 12028 | image_create_info.extent.width = img_width; |
| 12029 | image_create_info.extent.height = img_height; |
| 12030 | image_create_info.extent.depth = 1; |
| 12031 | image_create_info.mipLevels = 1; |
| 12032 | image_create_info.arrayLayers = 1; |
| 12033 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12034 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12035 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 12036 | |
| 12037 | vk_testing::Image color_image; |
| 12038 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 12039 | reqs); |
| 12040 | |
| 12041 | const VkImageSubresourceRange color_range = |
| 12042 | vk_testing::Image::subresource_range(image_create_info, |
| 12043 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 12044 | |
| 12045 | // Depth/Stencil image |
| 12046 | VkClearDepthStencilValue clear_value = {0}; |
| 12047 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 12048 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 12049 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12050 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12051 | ds_image_create_info.extent.width = 64; |
| 12052 | ds_image_create_info.extent.height = 64; |
| 12053 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12054 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 12055 | |
| 12056 | vk_testing::Image ds_image; |
| 12057 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 12058 | reqs); |
| 12059 | |
| 12060 | const VkImageSubresourceRange ds_range = |
| 12061 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 12062 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 12063 | |
| 12064 | m_errorMonitor->SetDesiredFailureMsg( |
| 12065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12066 | "vkCmdClearColorImage called with depth/stencil image."); |
| 12067 | |
| 12068 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12069 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12070 | &color_range); |
| 12071 | |
| 12072 | m_errorMonitor->VerifyFound(); |
| 12073 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 12074 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12075 | "vkCmdClearColorImage called with " |
| 12076 | "image created without " |
| 12077 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 12078 | |
| 12079 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12080 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12081 | &color_range); |
| 12082 | |
| 12083 | m_errorMonitor->VerifyFound(); |
| 12084 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12085 | // Call CmdClearDepthStencilImage with color image |
| 12086 | m_errorMonitor->SetDesiredFailureMsg( |
| 12087 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12088 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 12089 | |
| 12090 | vkCmdClearDepthStencilImage( |
| 12091 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 12092 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 12093 | &ds_range); |
| 12094 | |
| 12095 | m_errorMonitor->VerifyFound(); |
| 12096 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12097 | #endif // IMAGE_TESTS |
| 12098 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12099 | int main(int argc, char **argv) { |
| 12100 | int result; |
| 12101 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 12102 | #ifdef ANDROID |
| 12103 | int vulkanSupport = InitVulkan(); |
| 12104 | if (vulkanSupport == 0) |
| 12105 | return 1; |
| 12106 | #endif |
| 12107 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12108 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12109 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12110 | |
| 12111 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 12112 | |
| 12113 | result = RUN_ALL_TESTS(); |
| 12114 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12115 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12116 | return result; |
| 12117 | } |