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; |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 2954 | VkResult result = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 2955 | |
| 2956 | m_errorMonitor->VerifyFound(); |
| 2957 | |
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 2958 | if (result == VK_SUCCESS) { |
| 2959 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 2960 | } |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 2961 | } |
| 2962 | |
| 2963 | TEST_F(VkLayerTest, AttachmentUsageMismatch) { |
| 2964 | TEST_DESCRIPTION("Create a framebuffer where a subpass uses a color image " |
| 2965 | "in the depthStencil attachment point"); |
| 2966 | |
| 2967 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2968 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2969 | |
| 2970 | m_errorMonitor->SetDesiredFailureMsg( |
| 2971 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2972 | "conflicts with the image's IMAGE_USAGE flags"); |
| 2973 | |
| 2974 | // Create a renderPass with a depth-stencil attachment created with |
| 2975 | // IMAGE_USAGE_COLOR_ATTACHMENT |
| 2976 | VkAttachmentReference attach = {}; |
| 2977 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 2978 | VkSubpassDescription subpass = {}; |
| 2979 | // Add our color attachment to pDepthStencilAttachment |
| 2980 | subpass.pDepthStencilAttachment = &attach; |
| 2981 | VkRenderPassCreateInfo rpci = {}; |
| 2982 | rpci.subpassCount = 1; |
| 2983 | rpci.pSubpasses = &subpass; |
| 2984 | rpci.attachmentCount = 1; |
| 2985 | VkAttachmentDescription attach_desc = {}; |
| 2986 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 2987 | rpci.pAttachments = &attach_desc; |
| 2988 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 2989 | VkRenderPass rp; |
| 2990 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 2991 | ASSERT_VK_SUCCESS(err); |
| 2992 | |
| 2993 | VkImageView imageView = |
| 2994 | m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); |
| 2995 | VkFramebufferCreateInfo fb_info = {}; |
| 2996 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; |
| 2997 | fb_info.pNext = NULL; |
| 2998 | fb_info.renderPass = rp; |
| 2999 | fb_info.attachmentCount = 1; |
| 3000 | fb_info.pAttachments = &imageView; |
| 3001 | fb_info.width = 100; |
| 3002 | fb_info.height = 100; |
| 3003 | fb_info.layers = 1; |
| 3004 | |
| 3005 | VkFramebuffer fb; |
| 3006 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); |
| 3007 | |
| 3008 | m_errorMonitor->VerifyFound(); |
| 3009 | |
| 3010 | if (err == VK_SUCCESS) { |
| 3011 | vkDestroyFramebuffer(m_device->device(), fb, NULL); |
| 3012 | } |
| 3013 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
| 3014 | } |
| 3015 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3016 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3017 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 3018 | TEST_DESCRIPTION( |
| 3019 | "Wait on a event then set it after the wait has been submitted."); |
| 3020 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3021 | m_errorMonitor->ExpectSuccess(); |
| 3022 | |
| 3023 | VkEvent event; |
| 3024 | VkEventCreateInfo event_create_info{}; |
| 3025 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3026 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3027 | |
| 3028 | VkCommandPool command_pool; |
| 3029 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3030 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3031 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3032 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3033 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3034 | &command_pool); |
| 3035 | |
| 3036 | VkCommandBuffer command_buffer; |
| 3037 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3038 | command_buffer_allocate_info.sType = |
| 3039 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3040 | command_buffer_allocate_info.commandPool = command_pool; |
| 3041 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3042 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3043 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3044 | &command_buffer); |
| 3045 | |
| 3046 | VkQueue queue = VK_NULL_HANDLE; |
| 3047 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3048 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3049 | |
| 3050 | { |
| 3051 | VkCommandBufferBeginInfo begin_info{}; |
| 3052 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3053 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3054 | |
| 3055 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 3056 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3057 | nullptr, 0, nullptr); |
| 3058 | vkCmdResetEvent(command_buffer, event, |
| 3059 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3060 | vkEndCommandBuffer(command_buffer); |
| 3061 | } |
| 3062 | { |
| 3063 | VkSubmitInfo submit_info{}; |
| 3064 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3065 | submit_info.commandBufferCount = 1; |
| 3066 | submit_info.pCommandBuffers = &command_buffer; |
| 3067 | submit_info.signalSemaphoreCount = 0; |
| 3068 | submit_info.pSignalSemaphores = nullptr; |
| 3069 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3070 | } |
| 3071 | { vkSetEvent(m_device->device(), event); } |
| 3072 | |
| 3073 | vkQueueWaitIdle(queue); |
| 3074 | |
| 3075 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3076 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3077 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3078 | |
| 3079 | m_errorMonitor->VerifyNotFound(); |
| 3080 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3081 | // This is a positive test. No errors should be generated. |
| 3082 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 3083 | TEST_DESCRIPTION( |
| 3084 | "Issue a query and copy from it on a second command buffer."); |
| 3085 | |
| 3086 | if ((m_device->queue_props.empty()) || |
| 3087 | (m_device->queue_props[0].queueCount < 2)) |
| 3088 | return; |
| 3089 | |
| 3090 | m_errorMonitor->ExpectSuccess(); |
| 3091 | |
| 3092 | VkQueryPool query_pool; |
| 3093 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 3094 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 3095 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 3096 | query_pool_create_info.queryCount = 1; |
| 3097 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 3098 | &query_pool); |
| 3099 | |
| 3100 | VkCommandPool command_pool; |
| 3101 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3102 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3103 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3104 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3105 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3106 | &command_pool); |
| 3107 | |
| 3108 | VkCommandBuffer command_buffer[2]; |
| 3109 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3110 | command_buffer_allocate_info.sType = |
| 3111 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3112 | command_buffer_allocate_info.commandPool = command_pool; |
| 3113 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3114 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3115 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3116 | command_buffer); |
| 3117 | |
| 3118 | VkQueue queue = VK_NULL_HANDLE; |
| 3119 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3120 | 1, &queue); |
| 3121 | |
| 3122 | uint32_t qfi = 0; |
| 3123 | VkBufferCreateInfo buff_create_info = {}; |
| 3124 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3125 | buff_create_info.size = 1024; |
| 3126 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 3127 | buff_create_info.queueFamilyIndexCount = 1; |
| 3128 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 3129 | |
| 3130 | VkResult err; |
| 3131 | VkBuffer buffer; |
| 3132 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 3133 | ASSERT_VK_SUCCESS(err); |
| 3134 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3135 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3136 | mem_alloc.pNext = NULL; |
| 3137 | mem_alloc.allocationSize = 1024; |
| 3138 | mem_alloc.memoryTypeIndex = 0; |
| 3139 | |
| 3140 | VkMemoryRequirements memReqs; |
| 3141 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 3142 | bool pass = |
| 3143 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 3144 | if (!pass) { |
| 3145 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3146 | return; |
| 3147 | } |
| 3148 | |
| 3149 | VkDeviceMemory mem; |
| 3150 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3151 | ASSERT_VK_SUCCESS(err); |
| 3152 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 3153 | ASSERT_VK_SUCCESS(err); |
| 3154 | |
| 3155 | { |
| 3156 | VkCommandBufferBeginInfo begin_info{}; |
| 3157 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3158 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3159 | |
| 3160 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 3161 | vkCmdWriteTimestamp(command_buffer[0], |
| 3162 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 3163 | |
| 3164 | vkEndCommandBuffer(command_buffer[0]); |
| 3165 | |
| 3166 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3167 | |
| 3168 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 3169 | 0, 0, 0); |
| 3170 | |
| 3171 | vkEndCommandBuffer(command_buffer[1]); |
| 3172 | } |
| 3173 | { |
| 3174 | VkSubmitInfo submit_info{}; |
| 3175 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3176 | submit_info.commandBufferCount = 2; |
| 3177 | submit_info.pCommandBuffers = command_buffer; |
| 3178 | submit_info.signalSemaphoreCount = 0; |
| 3179 | submit_info.pSignalSemaphores = nullptr; |
| 3180 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3181 | } |
| 3182 | |
| 3183 | vkQueueWaitIdle(queue); |
| 3184 | |
| 3185 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 3186 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 3187 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3188 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 3189 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3190 | |
| 3191 | m_errorMonitor->VerifyNotFound(); |
| 3192 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3193 | |
| 3194 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 3195 | TEST_DESCRIPTION( |
| 3196 | "Reset an event then set it after the reset has been submitted."); |
| 3197 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3198 | m_errorMonitor->ExpectSuccess(); |
| 3199 | |
| 3200 | VkEvent event; |
| 3201 | VkEventCreateInfo event_create_info{}; |
| 3202 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3203 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 3204 | |
| 3205 | VkCommandPool command_pool; |
| 3206 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3207 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3208 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3209 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3210 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3211 | &command_pool); |
| 3212 | |
| 3213 | VkCommandBuffer command_buffer; |
| 3214 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3215 | command_buffer_allocate_info.sType = |
| 3216 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3217 | command_buffer_allocate_info.commandPool = command_pool; |
| 3218 | command_buffer_allocate_info.commandBufferCount = 1; |
| 3219 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3220 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3221 | &command_buffer); |
| 3222 | |
| 3223 | VkQueue queue = VK_NULL_HANDLE; |
| 3224 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3225 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3226 | |
| 3227 | { |
| 3228 | VkCommandBufferBeginInfo begin_info{}; |
| 3229 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3230 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 3231 | |
| 3232 | vkCmdResetEvent(command_buffer, event, |
| 3233 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 3234 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 3235 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3236 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 3237 | nullptr, 0, nullptr); |
| 3238 | vkEndCommandBuffer(command_buffer); |
| 3239 | } |
| 3240 | { |
| 3241 | VkSubmitInfo submit_info{}; |
| 3242 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3243 | submit_info.commandBufferCount = 1; |
| 3244 | submit_info.pCommandBuffers = &command_buffer; |
| 3245 | submit_info.signalSemaphoreCount = 0; |
| 3246 | submit_info.pSignalSemaphores = nullptr; |
| 3247 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3248 | } |
| 3249 | { |
| 3250 | m_errorMonitor->SetDesiredFailureMsg( |
| 3251 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 3252 | "0x1 that is already in use by a " |
| 3253 | "command buffer."); |
| 3254 | vkSetEvent(m_device->device(), event); |
| 3255 | m_errorMonitor->VerifyFound(); |
| 3256 | } |
| 3257 | |
| 3258 | vkQueueWaitIdle(queue); |
| 3259 | |
| 3260 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 3261 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 3262 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3263 | } |
| 3264 | |
| 3265 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3266 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 3267 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 3268 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 3269 | "previously revealed a bug so running this positive test " |
| 3270 | "to prevent a regression."); |
| 3271 | m_errorMonitor->ExpectSuccess(); |
| 3272 | |
| 3273 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3274 | VkQueue queue = VK_NULL_HANDLE; |
| 3275 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3276 | 0, &queue); |
| 3277 | |
| 3278 | static const uint32_t NUM_OBJECTS = 2; |
| 3279 | static const uint32_t NUM_FRAMES = 3; |
| 3280 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 3281 | VkFence fences[NUM_OBJECTS] = {}; |
| 3282 | |
| 3283 | VkCommandPool cmd_pool; |
| 3284 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 3285 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3286 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3287 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3288 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3289 | nullptr, &cmd_pool); |
| 3290 | ASSERT_VK_SUCCESS(err); |
| 3291 | |
| 3292 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3293 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3294 | cmd_buf_info.commandPool = cmd_pool; |
| 3295 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3296 | cmd_buf_info.commandBufferCount = 1; |
| 3297 | |
| 3298 | VkFenceCreateInfo fence_ci = {}; |
| 3299 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3300 | fence_ci.pNext = nullptr; |
| 3301 | fence_ci.flags = 0; |
| 3302 | |
| 3303 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3304 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3305 | &cmd_buffers[i]); |
| 3306 | ASSERT_VK_SUCCESS(err); |
| 3307 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3308 | ASSERT_VK_SUCCESS(err); |
| 3309 | } |
| 3310 | |
| 3311 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3312 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3313 | // Create empty cmd buffer |
| 3314 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3315 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3316 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3317 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3318 | ASSERT_VK_SUCCESS(err); |
| 3319 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3320 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3321 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3322 | VkSubmitInfo submit_info = {}; |
| 3323 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3324 | submit_info.commandBufferCount = 1; |
| 3325 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3326 | // Submit cmd buffer and wait for fence |
| 3327 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3328 | ASSERT_VK_SUCCESS(err); |
| 3329 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3330 | UINT64_MAX); |
| 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3333 | ASSERT_VK_SUCCESS(err); |
| 3334 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3335 | } |
| 3336 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3337 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3338 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3339 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3340 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3341 | } |
| 3342 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3343 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3344 | |
| 3345 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3346 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3347 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3348 | if ((m_device->queue_props.empty()) || |
| 3349 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3350 | return; |
| 3351 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3352 | m_errorMonitor->ExpectSuccess(); |
| 3353 | |
| 3354 | VkSemaphore semaphore; |
| 3355 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3356 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3357 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3358 | &semaphore); |
| 3359 | |
| 3360 | VkCommandPool command_pool; |
| 3361 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3362 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3363 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3364 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3365 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3366 | &command_pool); |
| 3367 | |
| 3368 | VkCommandBuffer command_buffer[2]; |
| 3369 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3370 | command_buffer_allocate_info.sType = |
| 3371 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3372 | command_buffer_allocate_info.commandPool = command_pool; |
| 3373 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3374 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3375 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3376 | command_buffer); |
| 3377 | |
| 3378 | VkQueue queue = VK_NULL_HANDLE; |
| 3379 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3380 | 1, &queue); |
| 3381 | |
| 3382 | { |
| 3383 | VkCommandBufferBeginInfo begin_info{}; |
| 3384 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3385 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3386 | |
| 3387 | vkCmdPipelineBarrier(command_buffer[0], |
| 3388 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3389 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3390 | 0, nullptr, 0, nullptr); |
| 3391 | |
| 3392 | VkViewport viewport{}; |
| 3393 | viewport.maxDepth = 1.0f; |
| 3394 | viewport.minDepth = 0.0f; |
| 3395 | viewport.width = 512; |
| 3396 | viewport.height = 512; |
| 3397 | viewport.x = 0; |
| 3398 | viewport.y = 0; |
| 3399 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3400 | vkEndCommandBuffer(command_buffer[0]); |
| 3401 | } |
| 3402 | { |
| 3403 | VkCommandBufferBeginInfo begin_info{}; |
| 3404 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3405 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3406 | |
| 3407 | VkViewport viewport{}; |
| 3408 | viewport.maxDepth = 1.0f; |
| 3409 | viewport.minDepth = 0.0f; |
| 3410 | viewport.width = 512; |
| 3411 | viewport.height = 512; |
| 3412 | viewport.x = 0; |
| 3413 | viewport.y = 0; |
| 3414 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3415 | vkEndCommandBuffer(command_buffer[1]); |
| 3416 | } |
| 3417 | { |
| 3418 | VkSubmitInfo submit_info{}; |
| 3419 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3420 | submit_info.commandBufferCount = 1; |
| 3421 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3422 | submit_info.signalSemaphoreCount = 1; |
| 3423 | submit_info.pSignalSemaphores = &semaphore; |
| 3424 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3425 | } |
| 3426 | { |
| 3427 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3428 | VkSubmitInfo submit_info{}; |
| 3429 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3430 | submit_info.commandBufferCount = 1; |
| 3431 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3432 | submit_info.waitSemaphoreCount = 1; |
| 3433 | submit_info.pWaitSemaphores = &semaphore; |
| 3434 | submit_info.pWaitDstStageMask = flags; |
| 3435 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3436 | } |
| 3437 | |
| 3438 | vkQueueWaitIdle(m_device->m_queue); |
| 3439 | |
| 3440 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3441 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3442 | &command_buffer[0]); |
| 3443 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3444 | |
| 3445 | m_errorMonitor->VerifyNotFound(); |
| 3446 | } |
| 3447 | |
| 3448 | // This is a positive test. No errors should be generated. |
| 3449 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3450 | |
| 3451 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3452 | "submitted on separate queues, the second having a fence" |
| 3453 | "followed by a QueueWaitIdle."); |
| 3454 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3455 | if ((m_device->queue_props.empty()) || |
| 3456 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3457 | return; |
| 3458 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3459 | m_errorMonitor->ExpectSuccess(); |
| 3460 | |
| 3461 | VkFence fence; |
| 3462 | VkFenceCreateInfo fence_create_info{}; |
| 3463 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3464 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3465 | |
| 3466 | VkSemaphore semaphore; |
| 3467 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3468 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3469 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3470 | &semaphore); |
| 3471 | |
| 3472 | VkCommandPool command_pool; |
| 3473 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3474 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3475 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3476 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3477 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3478 | &command_pool); |
| 3479 | |
| 3480 | VkCommandBuffer command_buffer[2]; |
| 3481 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3482 | command_buffer_allocate_info.sType = |
| 3483 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3484 | command_buffer_allocate_info.commandPool = command_pool; |
| 3485 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3486 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3487 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3488 | command_buffer); |
| 3489 | |
| 3490 | VkQueue queue = VK_NULL_HANDLE; |
| 3491 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3492 | 1, &queue); |
| 3493 | |
| 3494 | { |
| 3495 | VkCommandBufferBeginInfo begin_info{}; |
| 3496 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3497 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3498 | |
| 3499 | vkCmdPipelineBarrier(command_buffer[0], |
| 3500 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3501 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3502 | 0, nullptr, 0, nullptr); |
| 3503 | |
| 3504 | VkViewport viewport{}; |
| 3505 | viewport.maxDepth = 1.0f; |
| 3506 | viewport.minDepth = 0.0f; |
| 3507 | viewport.width = 512; |
| 3508 | viewport.height = 512; |
| 3509 | viewport.x = 0; |
| 3510 | viewport.y = 0; |
| 3511 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3512 | vkEndCommandBuffer(command_buffer[0]); |
| 3513 | } |
| 3514 | { |
| 3515 | VkCommandBufferBeginInfo begin_info{}; |
| 3516 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3517 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3518 | |
| 3519 | VkViewport viewport{}; |
| 3520 | viewport.maxDepth = 1.0f; |
| 3521 | viewport.minDepth = 0.0f; |
| 3522 | viewport.width = 512; |
| 3523 | viewport.height = 512; |
| 3524 | viewport.x = 0; |
| 3525 | viewport.y = 0; |
| 3526 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3527 | vkEndCommandBuffer(command_buffer[1]); |
| 3528 | } |
| 3529 | { |
| 3530 | VkSubmitInfo submit_info{}; |
| 3531 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3532 | submit_info.commandBufferCount = 1; |
| 3533 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3534 | submit_info.signalSemaphoreCount = 1; |
| 3535 | submit_info.pSignalSemaphores = &semaphore; |
| 3536 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3537 | } |
| 3538 | { |
| 3539 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3540 | VkSubmitInfo submit_info{}; |
| 3541 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3542 | submit_info.commandBufferCount = 1; |
| 3543 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3544 | submit_info.waitSemaphoreCount = 1; |
| 3545 | submit_info.pWaitSemaphores = &semaphore; |
| 3546 | submit_info.pWaitDstStageMask = flags; |
| 3547 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3548 | } |
| 3549 | |
| 3550 | vkQueueWaitIdle(m_device->m_queue); |
| 3551 | |
| 3552 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3553 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3554 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3555 | &command_buffer[0]); |
| 3556 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3557 | |
| 3558 | m_errorMonitor->VerifyNotFound(); |
| 3559 | } |
| 3560 | |
| 3561 | // This is a positive test. No errors should be generated. |
| 3562 | TEST_F(VkLayerTest, |
| 3563 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3564 | |
| 3565 | TEST_DESCRIPTION( |
| 3566 | "Two command buffers, each in a separate QueueSubmit call " |
| 3567 | "submitted on separate queues, the second having a fence" |
| 3568 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3569 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3570 | if ((m_device->queue_props.empty()) || |
| 3571 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3572 | return; |
| 3573 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3574 | m_errorMonitor->ExpectSuccess(); |
| 3575 | |
| 3576 | VkFence fence; |
| 3577 | VkFenceCreateInfo fence_create_info{}; |
| 3578 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3579 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3580 | |
| 3581 | VkSemaphore semaphore; |
| 3582 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3583 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3584 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3585 | &semaphore); |
| 3586 | |
| 3587 | VkCommandPool command_pool; |
| 3588 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3589 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3590 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3591 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3592 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3593 | &command_pool); |
| 3594 | |
| 3595 | VkCommandBuffer command_buffer[2]; |
| 3596 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3597 | command_buffer_allocate_info.sType = |
| 3598 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3599 | command_buffer_allocate_info.commandPool = command_pool; |
| 3600 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3601 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3602 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3603 | command_buffer); |
| 3604 | |
| 3605 | VkQueue queue = VK_NULL_HANDLE; |
| 3606 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3607 | 1, &queue); |
| 3608 | |
| 3609 | { |
| 3610 | VkCommandBufferBeginInfo begin_info{}; |
| 3611 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3612 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3613 | |
| 3614 | vkCmdPipelineBarrier(command_buffer[0], |
| 3615 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3616 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3617 | 0, nullptr, 0, nullptr); |
| 3618 | |
| 3619 | VkViewport viewport{}; |
| 3620 | viewport.maxDepth = 1.0f; |
| 3621 | viewport.minDepth = 0.0f; |
| 3622 | viewport.width = 512; |
| 3623 | viewport.height = 512; |
| 3624 | viewport.x = 0; |
| 3625 | viewport.y = 0; |
| 3626 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3627 | vkEndCommandBuffer(command_buffer[0]); |
| 3628 | } |
| 3629 | { |
| 3630 | VkCommandBufferBeginInfo begin_info{}; |
| 3631 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3632 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3633 | |
| 3634 | VkViewport viewport{}; |
| 3635 | viewport.maxDepth = 1.0f; |
| 3636 | viewport.minDepth = 0.0f; |
| 3637 | viewport.width = 512; |
| 3638 | viewport.height = 512; |
| 3639 | viewport.x = 0; |
| 3640 | viewport.y = 0; |
| 3641 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3642 | vkEndCommandBuffer(command_buffer[1]); |
| 3643 | } |
| 3644 | { |
| 3645 | VkSubmitInfo submit_info{}; |
| 3646 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3647 | submit_info.commandBufferCount = 1; |
| 3648 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3649 | submit_info.signalSemaphoreCount = 1; |
| 3650 | submit_info.pSignalSemaphores = &semaphore; |
| 3651 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3652 | } |
| 3653 | { |
| 3654 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3655 | VkSubmitInfo submit_info{}; |
| 3656 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3657 | submit_info.commandBufferCount = 1; |
| 3658 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3659 | submit_info.waitSemaphoreCount = 1; |
| 3660 | submit_info.pWaitSemaphores = &semaphore; |
| 3661 | submit_info.pWaitDstStageMask = flags; |
| 3662 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3663 | } |
| 3664 | |
| 3665 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3666 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3667 | |
| 3668 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3669 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3670 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3671 | &command_buffer[0]); |
| 3672 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3673 | |
| 3674 | m_errorMonitor->VerifyNotFound(); |
| 3675 | } |
| 3676 | |
| 3677 | // This is a positive test. No errors should be generated. |
| 3678 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3679 | |
| 3680 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3681 | "submitted on separate queues, the second having a fence, " |
| 3682 | "followed by a WaitForFences call."); |
| 3683 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3684 | if ((m_device->queue_props.empty()) || |
| 3685 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3686 | return; |
| 3687 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3688 | m_errorMonitor->ExpectSuccess(); |
| 3689 | |
| 3690 | VkFence fence; |
| 3691 | VkFenceCreateInfo fence_create_info{}; |
| 3692 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3693 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3694 | |
| 3695 | VkSemaphore semaphore; |
| 3696 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3697 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3698 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3699 | &semaphore); |
| 3700 | |
| 3701 | VkCommandPool command_pool; |
| 3702 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3703 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3704 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3705 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3706 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3707 | &command_pool); |
| 3708 | |
| 3709 | VkCommandBuffer command_buffer[2]; |
| 3710 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3711 | command_buffer_allocate_info.sType = |
| 3712 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3713 | command_buffer_allocate_info.commandPool = command_pool; |
| 3714 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3715 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3716 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3717 | command_buffer); |
| 3718 | |
| 3719 | VkQueue queue = VK_NULL_HANDLE; |
| 3720 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3721 | 1, &queue); |
| 3722 | |
| 3723 | |
| 3724 | { |
| 3725 | VkCommandBufferBeginInfo begin_info{}; |
| 3726 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3727 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3728 | |
| 3729 | vkCmdPipelineBarrier(command_buffer[0], |
| 3730 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3731 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3732 | 0, nullptr, 0, nullptr); |
| 3733 | |
| 3734 | VkViewport viewport{}; |
| 3735 | viewport.maxDepth = 1.0f; |
| 3736 | viewport.minDepth = 0.0f; |
| 3737 | viewport.width = 512; |
| 3738 | viewport.height = 512; |
| 3739 | viewport.x = 0; |
| 3740 | viewport.y = 0; |
| 3741 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3742 | vkEndCommandBuffer(command_buffer[0]); |
| 3743 | } |
| 3744 | { |
| 3745 | VkCommandBufferBeginInfo begin_info{}; |
| 3746 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3747 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3748 | |
| 3749 | VkViewport viewport{}; |
| 3750 | viewport.maxDepth = 1.0f; |
| 3751 | viewport.minDepth = 0.0f; |
| 3752 | viewport.width = 512; |
| 3753 | viewport.height = 512; |
| 3754 | viewport.x = 0; |
| 3755 | viewport.y = 0; |
| 3756 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3757 | vkEndCommandBuffer(command_buffer[1]); |
| 3758 | } |
| 3759 | { |
| 3760 | VkSubmitInfo submit_info{}; |
| 3761 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3762 | submit_info.commandBufferCount = 1; |
| 3763 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3764 | submit_info.signalSemaphoreCount = 1; |
| 3765 | submit_info.pSignalSemaphores = &semaphore; |
| 3766 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3767 | } |
| 3768 | { |
| 3769 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3770 | VkSubmitInfo submit_info{}; |
| 3771 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3772 | submit_info.commandBufferCount = 1; |
| 3773 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3774 | submit_info.waitSemaphoreCount = 1; |
| 3775 | submit_info.pWaitSemaphores = &semaphore; |
| 3776 | submit_info.pWaitDstStageMask = flags; |
| 3777 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3778 | } |
| 3779 | |
| 3780 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3781 | |
| 3782 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3783 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3784 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3785 | &command_buffer[0]); |
| 3786 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3787 | |
| 3788 | m_errorMonitor->VerifyNotFound(); |
| 3789 | } |
| 3790 | |
| 3791 | // This is a positive test. No errors should be generated. |
| 3792 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3793 | |
| 3794 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3795 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3796 | "second having a fence, " |
| 3797 | "followed by a WaitForFences call."); |
| 3798 | |
| 3799 | m_errorMonitor->ExpectSuccess(); |
| 3800 | |
| 3801 | VkFence fence; |
| 3802 | VkFenceCreateInfo fence_create_info{}; |
| 3803 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3804 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3805 | |
| 3806 | VkSemaphore semaphore; |
| 3807 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3808 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3809 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3810 | &semaphore); |
| 3811 | |
| 3812 | VkCommandPool command_pool; |
| 3813 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3814 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3815 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3816 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3817 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3818 | &command_pool); |
| 3819 | |
| 3820 | VkCommandBuffer command_buffer[2]; |
| 3821 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3822 | command_buffer_allocate_info.sType = |
| 3823 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3824 | command_buffer_allocate_info.commandPool = command_pool; |
| 3825 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3826 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3827 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3828 | command_buffer); |
| 3829 | |
| 3830 | { |
| 3831 | VkCommandBufferBeginInfo begin_info{}; |
| 3832 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3833 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3834 | |
| 3835 | vkCmdPipelineBarrier(command_buffer[0], |
| 3836 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3837 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3838 | 0, nullptr, 0, nullptr); |
| 3839 | |
| 3840 | VkViewport viewport{}; |
| 3841 | viewport.maxDepth = 1.0f; |
| 3842 | viewport.minDepth = 0.0f; |
| 3843 | viewport.width = 512; |
| 3844 | viewport.height = 512; |
| 3845 | viewport.x = 0; |
| 3846 | viewport.y = 0; |
| 3847 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3848 | vkEndCommandBuffer(command_buffer[0]); |
| 3849 | } |
| 3850 | { |
| 3851 | VkCommandBufferBeginInfo begin_info{}; |
| 3852 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3853 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3854 | |
| 3855 | VkViewport viewport{}; |
| 3856 | viewport.maxDepth = 1.0f; |
| 3857 | viewport.minDepth = 0.0f; |
| 3858 | viewport.width = 512; |
| 3859 | viewport.height = 512; |
| 3860 | viewport.x = 0; |
| 3861 | viewport.y = 0; |
| 3862 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3863 | vkEndCommandBuffer(command_buffer[1]); |
| 3864 | } |
| 3865 | { |
| 3866 | VkSubmitInfo submit_info{}; |
| 3867 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3868 | submit_info.commandBufferCount = 1; |
| 3869 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3870 | submit_info.signalSemaphoreCount = 1; |
| 3871 | submit_info.pSignalSemaphores = &semaphore; |
| 3872 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3873 | } |
| 3874 | { |
| 3875 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3876 | VkSubmitInfo submit_info{}; |
| 3877 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3878 | submit_info.commandBufferCount = 1; |
| 3879 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3880 | submit_info.waitSemaphoreCount = 1; |
| 3881 | submit_info.pWaitSemaphores = &semaphore; |
| 3882 | submit_info.pWaitDstStageMask = flags; |
| 3883 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3884 | } |
| 3885 | |
| 3886 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3887 | |
| 3888 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3889 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3890 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3891 | &command_buffer[0]); |
| 3892 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3893 | |
| 3894 | m_errorMonitor->VerifyNotFound(); |
| 3895 | } |
| 3896 | |
| 3897 | // This is a positive test. No errors should be generated. |
| 3898 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3899 | |
| 3900 | TEST_DESCRIPTION( |
| 3901 | "Two command buffers, each in a separate QueueSubmit call " |
| 3902 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3903 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3904 | |
| 3905 | m_errorMonitor->ExpectSuccess(); |
| 3906 | |
| 3907 | VkFence fence; |
| 3908 | VkFenceCreateInfo fence_create_info{}; |
| 3909 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3910 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3911 | |
| 3912 | VkCommandPool command_pool; |
| 3913 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3914 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3915 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3916 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3917 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3918 | &command_pool); |
| 3919 | |
| 3920 | VkCommandBuffer command_buffer[2]; |
| 3921 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3922 | command_buffer_allocate_info.sType = |
| 3923 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3924 | command_buffer_allocate_info.commandPool = command_pool; |
| 3925 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3926 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3927 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3928 | command_buffer); |
| 3929 | |
| 3930 | { |
| 3931 | VkCommandBufferBeginInfo begin_info{}; |
| 3932 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3933 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3934 | |
| 3935 | vkCmdPipelineBarrier(command_buffer[0], |
| 3936 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3937 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3938 | 0, nullptr, 0, nullptr); |
| 3939 | |
| 3940 | VkViewport viewport{}; |
| 3941 | viewport.maxDepth = 1.0f; |
| 3942 | viewport.minDepth = 0.0f; |
| 3943 | viewport.width = 512; |
| 3944 | viewport.height = 512; |
| 3945 | viewport.x = 0; |
| 3946 | viewport.y = 0; |
| 3947 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3948 | vkEndCommandBuffer(command_buffer[0]); |
| 3949 | } |
| 3950 | { |
| 3951 | VkCommandBufferBeginInfo begin_info{}; |
| 3952 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3953 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3954 | |
| 3955 | VkViewport viewport{}; |
| 3956 | viewport.maxDepth = 1.0f; |
| 3957 | viewport.minDepth = 0.0f; |
| 3958 | viewport.width = 512; |
| 3959 | viewport.height = 512; |
| 3960 | viewport.x = 0; |
| 3961 | viewport.y = 0; |
| 3962 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3963 | vkEndCommandBuffer(command_buffer[1]); |
| 3964 | } |
| 3965 | { |
| 3966 | VkSubmitInfo submit_info{}; |
| 3967 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3968 | submit_info.commandBufferCount = 1; |
| 3969 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3970 | submit_info.signalSemaphoreCount = 0; |
| 3971 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3972 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3973 | } |
| 3974 | { |
| 3975 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3976 | VkSubmitInfo submit_info{}; |
| 3977 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3978 | submit_info.commandBufferCount = 1; |
| 3979 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3980 | submit_info.waitSemaphoreCount = 0; |
| 3981 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3982 | submit_info.pWaitDstStageMask = flags; |
| 3983 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3984 | } |
| 3985 | |
| 3986 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3987 | |
| 3988 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3989 | |
| 3990 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3991 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3992 | &command_buffer[0]); |
| 3993 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3994 | |
| 3995 | m_errorMonitor->VerifyNotFound(); |
| 3996 | } |
| 3997 | |
| 3998 | // This is a positive test. No errors should be generated. |
| 3999 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 4000 | |
| 4001 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 4002 | "on the same queue, the second having a fence, followed " |
| 4003 | "by a WaitForFences call."); |
| 4004 | |
| 4005 | m_errorMonitor->ExpectSuccess(); |
| 4006 | |
| 4007 | VkFence fence; |
| 4008 | VkFenceCreateInfo fence_create_info{}; |
| 4009 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4010 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4011 | |
| 4012 | VkCommandPool command_pool; |
| 4013 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4014 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4015 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4016 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4017 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4018 | &command_pool); |
| 4019 | |
| 4020 | VkCommandBuffer command_buffer[2]; |
| 4021 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4022 | command_buffer_allocate_info.sType = |
| 4023 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4024 | command_buffer_allocate_info.commandPool = command_pool; |
| 4025 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4026 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4027 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4028 | command_buffer); |
| 4029 | |
| 4030 | { |
| 4031 | VkCommandBufferBeginInfo begin_info{}; |
| 4032 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4033 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4034 | |
| 4035 | vkCmdPipelineBarrier(command_buffer[0], |
| 4036 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4037 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4038 | 0, nullptr, 0, nullptr); |
| 4039 | |
| 4040 | VkViewport viewport{}; |
| 4041 | viewport.maxDepth = 1.0f; |
| 4042 | viewport.minDepth = 0.0f; |
| 4043 | viewport.width = 512; |
| 4044 | viewport.height = 512; |
| 4045 | viewport.x = 0; |
| 4046 | viewport.y = 0; |
| 4047 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4048 | vkEndCommandBuffer(command_buffer[0]); |
| 4049 | } |
| 4050 | { |
| 4051 | VkCommandBufferBeginInfo begin_info{}; |
| 4052 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4053 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4054 | |
| 4055 | VkViewport viewport{}; |
| 4056 | viewport.maxDepth = 1.0f; |
| 4057 | viewport.minDepth = 0.0f; |
| 4058 | viewport.width = 512; |
| 4059 | viewport.height = 512; |
| 4060 | viewport.x = 0; |
| 4061 | viewport.y = 0; |
| 4062 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4063 | vkEndCommandBuffer(command_buffer[1]); |
| 4064 | } |
| 4065 | { |
| 4066 | VkSubmitInfo submit_info{}; |
| 4067 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4068 | submit_info.commandBufferCount = 1; |
| 4069 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 4070 | submit_info.signalSemaphoreCount = 0; |
| 4071 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 4072 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 4073 | } |
| 4074 | { |
| 4075 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4076 | VkSubmitInfo submit_info{}; |
| 4077 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4078 | submit_info.commandBufferCount = 1; |
| 4079 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 4080 | submit_info.waitSemaphoreCount = 0; |
| 4081 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 4082 | submit_info.pWaitDstStageMask = flags; |
| 4083 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 4084 | } |
| 4085 | |
| 4086 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4087 | |
| 4088 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4089 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4090 | &command_buffer[0]); |
| 4091 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 4092 | |
| 4093 | m_errorMonitor->VerifyNotFound(); |
| 4094 | } |
| 4095 | |
| 4096 | // This is a positive test. No errors should be generated. |
| 4097 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 4098 | |
| 4099 | TEST_DESCRIPTION( |
| 4100 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 4101 | "QueueSubmit call followed by a WaitForFences call."); |
| 4102 | |
| 4103 | m_errorMonitor->ExpectSuccess(); |
| 4104 | |
| 4105 | VkFence fence; |
| 4106 | VkFenceCreateInfo fence_create_info{}; |
| 4107 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4108 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 4109 | |
| 4110 | VkSemaphore semaphore; |
| 4111 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 4112 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 4113 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 4114 | &semaphore); |
| 4115 | |
| 4116 | VkCommandPool command_pool; |
| 4117 | VkCommandPoolCreateInfo pool_create_info{}; |
| 4118 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 4119 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 4120 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 4121 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 4122 | &command_pool); |
| 4123 | |
| 4124 | VkCommandBuffer command_buffer[2]; |
| 4125 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 4126 | command_buffer_allocate_info.sType = |
| 4127 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 4128 | command_buffer_allocate_info.commandPool = command_pool; |
| 4129 | command_buffer_allocate_info.commandBufferCount = 2; |
| 4130 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 4131 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 4132 | command_buffer); |
| 4133 | |
| 4134 | { |
| 4135 | VkCommandBufferBeginInfo begin_info{}; |
| 4136 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4137 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 4138 | |
| 4139 | vkCmdPipelineBarrier(command_buffer[0], |
| 4140 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 4141 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 4142 | 0, nullptr, 0, nullptr); |
| 4143 | |
| 4144 | VkViewport viewport{}; |
| 4145 | viewport.maxDepth = 1.0f; |
| 4146 | viewport.minDepth = 0.0f; |
| 4147 | viewport.width = 512; |
| 4148 | viewport.height = 512; |
| 4149 | viewport.x = 0; |
| 4150 | viewport.y = 0; |
| 4151 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 4152 | vkEndCommandBuffer(command_buffer[0]); |
| 4153 | } |
| 4154 | { |
| 4155 | VkCommandBufferBeginInfo begin_info{}; |
| 4156 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4157 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 4158 | |
| 4159 | VkViewport viewport{}; |
| 4160 | viewport.maxDepth = 1.0f; |
| 4161 | viewport.minDepth = 0.0f; |
| 4162 | viewport.width = 512; |
| 4163 | viewport.height = 512; |
| 4164 | viewport.x = 0; |
| 4165 | viewport.y = 0; |
| 4166 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 4167 | vkEndCommandBuffer(command_buffer[1]); |
| 4168 | } |
| 4169 | { |
| 4170 | VkSubmitInfo submit_info[2]; |
| 4171 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 4172 | |
| 4173 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4174 | submit_info[0].pNext = NULL; |
| 4175 | submit_info[0].commandBufferCount = 1; |
| 4176 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 4177 | submit_info[0].signalSemaphoreCount = 1; |
| 4178 | submit_info[0].pSignalSemaphores = &semaphore; |
| 4179 | submit_info[0].waitSemaphoreCount = 0; |
| 4180 | submit_info[0].pWaitSemaphores = NULL; |
| 4181 | submit_info[0].pWaitDstStageMask = 0; |
| 4182 | |
| 4183 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4184 | submit_info[1].pNext = NULL; |
| 4185 | submit_info[1].commandBufferCount = 1; |
| 4186 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 4187 | submit_info[1].waitSemaphoreCount = 1; |
| 4188 | submit_info[1].pWaitSemaphores = &semaphore; |
| 4189 | submit_info[1].pWaitDstStageMask = flags; |
| 4190 | submit_info[1].signalSemaphoreCount = 0; |
| 4191 | submit_info[1].pSignalSemaphores = NULL; |
| 4192 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 4193 | } |
| 4194 | |
| 4195 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 4196 | |
| 4197 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 4198 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 4199 | &command_buffer[0]); |
| 4200 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4201 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4202 | |
| 4203 | m_errorMonitor->VerifyNotFound(); |
| 4204 | } |
| 4205 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4206 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4207 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4208 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 4209 | "state is required but not correctly bound."); |
| 4210 | |
| 4211 | // Dynamic depth bias |
| 4212 | m_errorMonitor->SetDesiredFailureMsg( |
| 4213 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4214 | "Dynamic depth bias state not set for this command buffer"); |
| 4215 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4216 | BsoFailDepthBias); |
| 4217 | m_errorMonitor->VerifyFound(); |
| 4218 | } |
| 4219 | |
| 4220 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 4221 | TEST_DESCRIPTION( |
| 4222 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 4223 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4224 | |
| 4225 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4226 | m_errorMonitor->SetDesiredFailureMsg( |
| 4227 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4228 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4229 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4230 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4231 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4232 | } |
| 4233 | |
| 4234 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 4235 | TEST_DESCRIPTION( |
| 4236 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 4237 | "state is required but not correctly bound."); |
| 4238 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4239 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4240 | m_errorMonitor->SetDesiredFailureMsg( |
| 4241 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4242 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4243 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4244 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4245 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4246 | } |
| 4247 | |
| 4248 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 4249 | TEST_DESCRIPTION( |
| 4250 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 4251 | "state is required but not correctly bound."); |
| 4252 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4253 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4254 | m_errorMonitor->SetDesiredFailureMsg( |
| 4255 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4256 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4257 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4258 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4259 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4260 | } |
| 4261 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4262 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4263 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4264 | "Run a simple draw calls to validate failure when Blend Constants " |
| 4265 | "dynamic state is required but not correctly bound."); |
| 4266 | // Dynamic blend constant state |
| 4267 | m_errorMonitor->SetDesiredFailureMsg( |
| 4268 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4269 | "Dynamic blend constants state not set for this command buffer"); |
| 4270 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4271 | BsoFailBlend); |
| 4272 | m_errorMonitor->VerifyFound(); |
| 4273 | } |
| 4274 | |
| 4275 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 4276 | TEST_DESCRIPTION( |
| 4277 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4278 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4279 | if (!m_device->phy().features().depthBounds) { |
| 4280 | printf("Device does not support depthBounds test; skipped.\n"); |
| 4281 | return; |
| 4282 | } |
| 4283 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4284 | m_errorMonitor->SetDesiredFailureMsg( |
| 4285 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4286 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4287 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4288 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4289 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4290 | } |
| 4291 | |
| 4292 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4293 | TEST_DESCRIPTION( |
| 4294 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4295 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4296 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4297 | m_errorMonitor->SetDesiredFailureMsg( |
| 4298 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4299 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4300 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4301 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4302 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4303 | } |
| 4304 | |
| 4305 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4306 | TEST_DESCRIPTION( |
| 4307 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4308 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4309 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4310 | m_errorMonitor->SetDesiredFailureMsg( |
| 4311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4312 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4313 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4314 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4315 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4316 | } |
| 4317 | |
| 4318 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4319 | TEST_DESCRIPTION( |
| 4320 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4321 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4322 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4323 | m_errorMonitor->SetDesiredFailureMsg( |
| 4324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4325 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4326 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4327 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4328 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4329 | } |
| 4330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4331 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4332 | m_errorMonitor->SetDesiredFailureMsg( |
| 4333 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4334 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4335 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4336 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4337 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4338 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4341 | // We luck out b/c by default the framework creates CB w/ the |
| 4342 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4343 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4344 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4345 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4346 | EndCommandBuffer(); |
| 4347 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4348 | // Bypass framework since it does the waits automatically |
| 4349 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4350 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4351 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4352 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4353 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4354 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4355 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4356 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4357 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4358 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4359 | submit_info.pSignalSemaphores = NULL; |
| 4360 | |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4361 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4362 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4363 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4364 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4365 | // submitted once |
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4366 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4367 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4368 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4369 | } |
| 4370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4371 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4372 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4373 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4374 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4375 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4376 | "Unable to allocate 1 descriptors of " |
| 4377 | "type " |
| 4378 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4379 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4380 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4381 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4383 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4384 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4385 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4387 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4388 | |
| 4389 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4391 | ds_pool_ci.pNext = NULL; |
| 4392 | ds_pool_ci.flags = 0; |
| 4393 | ds_pool_ci.maxSets = 1; |
| 4394 | ds_pool_ci.poolSizeCount = 1; |
| 4395 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4396 | |
| 4397 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | err = |
| 4399 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4400 | ASSERT_VK_SUCCESS(err); |
| 4401 | |
| 4402 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4403 | dsl_binding.binding = 0; |
| 4404 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4405 | dsl_binding.descriptorCount = 1; |
| 4406 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4407 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4408 | |
| 4409 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4410 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4411 | ds_layout_ci.pNext = NULL; |
| 4412 | ds_layout_ci.bindingCount = 1; |
| 4413 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4414 | |
| 4415 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4416 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4417 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4418 | ASSERT_VK_SUCCESS(err); |
| 4419 | |
| 4420 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4421 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4422 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4423 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4424 | alloc_info.descriptorPool = ds_pool; |
| 4425 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4426 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4427 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4428 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4429 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4430 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4431 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4432 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4433 | } |
| 4434 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4436 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4438 | m_errorMonitor->SetDesiredFailureMsg( |
| 4439 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4440 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4441 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4442 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4443 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4444 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4445 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4446 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4447 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4448 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4449 | |
| 4450 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4451 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4452 | ds_pool_ci.pNext = NULL; |
| 4453 | ds_pool_ci.maxSets = 1; |
| 4454 | ds_pool_ci.poolSizeCount = 1; |
| 4455 | ds_pool_ci.flags = 0; |
| 4456 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4457 | // app can only call vkResetDescriptorPool on this pool.; |
| 4458 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4459 | |
| 4460 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4461 | err = |
| 4462 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4463 | ASSERT_VK_SUCCESS(err); |
| 4464 | |
| 4465 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4466 | dsl_binding.binding = 0; |
| 4467 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4468 | dsl_binding.descriptorCount = 1; |
| 4469 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4470 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4471 | |
| 4472 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4473 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4474 | ds_layout_ci.pNext = NULL; |
| 4475 | ds_layout_ci.bindingCount = 1; |
| 4476 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4477 | |
| 4478 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4479 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4480 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4481 | ASSERT_VK_SUCCESS(err); |
| 4482 | |
| 4483 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4484 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4485 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4486 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4487 | alloc_info.descriptorPool = ds_pool; |
| 4488 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4489 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4490 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4491 | ASSERT_VK_SUCCESS(err); |
| 4492 | |
| 4493 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4494 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4495 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4496 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4497 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4498 | } |
| 4499 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4500 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4501 | // Attempt to clear Descriptor Pool with bad object. |
| 4502 | // ObjectTracker should catch this. |
| 4503 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4504 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4505 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4506 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4507 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4508 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4509 | } |
| 4510 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4511 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4512 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4513 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4514 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4515 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4516 | |
| 4517 | uint64_t fake_set_handle = 0xbaad6001; |
| 4518 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4519 | VkResult err; |
| 4520 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4521 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4522 | |
| 4523 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4524 | |
| 4525 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4526 | layout_bindings[0].binding = 0; |
| 4527 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4528 | layout_bindings[0].descriptorCount = 1; |
| 4529 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4530 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4531 | |
| 4532 | VkDescriptorSetLayout descriptor_set_layout; |
| 4533 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4534 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4535 | dslci.pNext = NULL; |
| 4536 | dslci.bindingCount = 1; |
| 4537 | dslci.pBindings = layout_bindings; |
| 4538 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4539 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4540 | |
| 4541 | VkPipelineLayout pipeline_layout; |
| 4542 | VkPipelineLayoutCreateInfo plci = {}; |
| 4543 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4544 | plci.pNext = NULL; |
| 4545 | plci.setLayoutCount = 1; |
| 4546 | plci.pSetLayouts = &descriptor_set_layout; |
| 4547 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4548 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4549 | |
| 4550 | BeginCommandBuffer(); |
| 4551 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4552 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4553 | m_errorMonitor->VerifyFound(); |
| 4554 | EndCommandBuffer(); |
| 4555 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4556 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4557 | } |
| 4558 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4559 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4560 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4561 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4562 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4563 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4564 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4565 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4566 | |
| 4567 | VkPipelineLayout pipeline_layout; |
| 4568 | VkPipelineLayoutCreateInfo plci = {}; |
| 4569 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4570 | plci.pNext = NULL; |
| 4571 | plci.setLayoutCount = 1; |
| 4572 | plci.pSetLayouts = &bad_layout; |
| 4573 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4574 | |
| 4575 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4576 | } |
| 4577 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4578 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
| 4579 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " |
| 4580 | "1) A uniform buffer update must have a valid buffer index." |
| 4581 | "2) When using an array of descriptors in a single WriteDescriptor," |
| 4582 | " the descriptor types and stageflags must all be the same." |
| 4583 | "3) Immutable Sampler state must match across descriptors"); |
| 4584 | |
| 4585 | const char *invalid_BufferInfo_ErrorMessage = |
| 4586 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " |
| 4587 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " |
| 4588 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; |
| 4589 | const char *stateFlag_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 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4592 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4593 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4594 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
| 4595 | |
| 4596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4597 | VkDescriptorPoolSize ds_type_count[4] = {}; |
| 4598 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4599 | ds_type_count[0].descriptorCount = 1; |
| 4600 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4601 | ds_type_count[1].descriptorCount = 1; |
| 4602 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4603 | ds_type_count[2].descriptorCount = 1; |
| 4604 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4605 | ds_type_count[3].descriptorCount = 1; |
| 4606 | |
| 4607 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4608 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4609 | ds_pool_ci.maxSets = 1; |
| 4610 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); |
| 4611 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 4612 | |
| 4613 | VkDescriptorPool ds_pool; |
| 4614 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4615 | ASSERT_VK_SUCCESS(err); |
| 4616 | |
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4617 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4618 | layout_binding[0].binding = 0; |
| 4619 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4620 | layout_binding[0].descriptorCount = 1; |
| 4621 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4622 | layout_binding[0].pImmutableSamplers = NULL; |
| 4623 | |
| 4624 | layout_binding[1].binding = 1; |
| 4625 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4626 | layout_binding[1].descriptorCount = 1; |
| 4627 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 4628 | layout_binding[1].pImmutableSamplers = NULL; |
| 4629 | |
| 4630 | VkSamplerCreateInfo sampler_ci = {}; |
| 4631 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4632 | sampler_ci.pNext = NULL; |
| 4633 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4634 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4635 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4636 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4637 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4638 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4639 | sampler_ci.mipLodBias = 1.0; |
| 4640 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4641 | sampler_ci.maxAnisotropy = 1; |
| 4642 | sampler_ci.compareEnable = VK_FALSE; |
| 4643 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4644 | sampler_ci.minLod = 1.0; |
| 4645 | sampler_ci.maxLod = 1.0; |
| 4646 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4647 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 4648 | VkSampler sampler; |
| 4649 | |
| 4650 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 4651 | ASSERT_VK_SUCCESS(err); |
| 4652 | |
| 4653 | layout_binding[2].binding = 2; |
| 4654 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4655 | layout_binding[2].descriptorCount = 1; |
| 4656 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 4657 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); |
| 4658 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4659 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4660 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4661 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); |
| 4662 | ds_layout_ci.pBindings = layout_binding; |
| 4663 | VkDescriptorSetLayout ds_layout; |
| 4664 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 4665 | ASSERT_VK_SUCCESS(err); |
| 4666 | |
| 4667 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4668 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4669 | alloc_info.descriptorSetCount = 1; |
| 4670 | alloc_info.descriptorPool = ds_pool; |
| 4671 | alloc_info.pSetLayouts = &ds_layout; |
| 4672 | VkDescriptorSet descriptorSet; |
| 4673 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 4674 | ASSERT_VK_SUCCESS(err); |
| 4675 | |
| 4676 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4677 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4678 | pipeline_layout_ci.pNext = NULL; |
| 4679 | pipeline_layout_ci.setLayoutCount = 1; |
| 4680 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4681 | |
| 4682 | VkPipelineLayout pipeline_layout; |
| 4683 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 4684 | ASSERT_VK_SUCCESS(err); |
| 4685 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4686 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4687 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4688 | descriptor_write.dstSet = descriptorSet; |
| 4689 | descriptor_write.dstBinding = 0; |
| 4690 | descriptor_write.descriptorCount = 1; |
| 4691 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4692 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4693 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4694 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4695 | m_errorMonitor->VerifyFound(); |
| 4696 | |
| 4697 | // Create a buffer to update the descriptor with |
| 4698 | uint32_t qfi = 0; |
| 4699 | VkBufferCreateInfo buffCI = {}; |
| 4700 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4701 | buffCI.size = 1024; |
| 4702 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4703 | buffCI.queueFamilyIndexCount = 1; |
| 4704 | buffCI.pQueueFamilyIndices = &qfi; |
| 4705 | |
| 4706 | VkBuffer dyub; |
| 4707 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4708 | ASSERT_VK_SUCCESS(err); |
| 4709 | VkDescriptorBufferInfo buffInfo = {}; |
| 4710 | buffInfo.buffer = dyub; |
| 4711 | buffInfo.offset = 0; |
| 4712 | buffInfo.range = 1024; |
| 4713 | |
| 4714 | descriptor_write.pBufferInfo = &buffInfo; |
| 4715 | descriptor_write.descriptorCount = 2; |
| 4716 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4717 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4718 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
| 4719 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4720 | m_errorMonitor->VerifyFound(); |
| 4721 | |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4722 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
| 4723 | // the third descriptor contains an immutable sampler |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4724 | descriptor_write.dstBinding = 1; |
| 4725 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4726 | |
| 4727 | |
| 4728 | // Make pImageInfo index non-null to avoid complaints of it missing |
| 4729 | VkDescriptorImageInfo imageInfo = {}; |
| 4730 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4731 | descriptor_write.pImageInfo = &imageInfo; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4732 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
| 4733 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4734 | m_errorMonitor->VerifyFound(); |
| 4735 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4736 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4737 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4738 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4739 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4740 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4741 | } |
| 4742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4743 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4744 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4745 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4746 | // Create a valid cmd buffer |
| 4747 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4748 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4749 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4750 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4751 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4752 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4753 | BeginCommandBuffer(); |
| 4754 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4755 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4756 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4757 | // Now issue a draw call with no pipeline bound |
| 4758 | m_errorMonitor->SetDesiredFailureMsg( |
| 4759 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4760 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4761 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4762 | BeginCommandBuffer(); |
| 4763 | Draw(1, 0, 0, 0); |
| 4764 | m_errorMonitor->VerifyFound(); |
| 4765 | // Finally same check once more but with Dispatch/Compute |
| 4766 | m_errorMonitor->SetDesiredFailureMsg( |
| 4767 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4768 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4769 | BeginCommandBuffer(); |
| 4770 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4771 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4772 | } |
| 4773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4774 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4775 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4776 | // CommandBuffer |
| 4777 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4778 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4779 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4780 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4781 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4783 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4784 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4785 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4786 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4787 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4788 | |
| 4789 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4790 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4791 | ds_pool_ci.pNext = NULL; |
| 4792 | ds_pool_ci.maxSets = 1; |
| 4793 | ds_pool_ci.poolSizeCount = 1; |
| 4794 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4795 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4796 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4797 | err = |
| 4798 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4799 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4800 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4801 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4802 | dsl_binding.binding = 0; |
| 4803 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4804 | dsl_binding.descriptorCount = 1; |
| 4805 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4806 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4807 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4808 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4809 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4810 | ds_layout_ci.pNext = NULL; |
| 4811 | ds_layout_ci.bindingCount = 1; |
| 4812 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4813 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4814 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4815 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4816 | ASSERT_VK_SUCCESS(err); |
| 4817 | |
| 4818 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4819 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4820 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4821 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4822 | alloc_info.descriptorPool = ds_pool; |
| 4823 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4824 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4825 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4826 | ASSERT_VK_SUCCESS(err); |
| 4827 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4828 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4829 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4830 | pipeline_layout_ci.pNext = NULL; |
| 4831 | pipeline_layout_ci.setLayoutCount = 1; |
| 4832 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4833 | |
| 4834 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4835 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4836 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4837 | ASSERT_VK_SUCCESS(err); |
| 4838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4839 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4840 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4841 | // 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] | 4842 | // on more devices |
| 4843 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4844 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4845 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4846 | VkPipelineObj pipe(m_device); |
| 4847 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4848 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4849 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4850 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4851 | |
| 4852 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4853 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4854 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4855 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4856 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4857 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4858 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4859 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4860 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4861 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4862 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4863 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4864 | } |
| 4865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4866 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4867 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4868 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4869 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4870 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4871 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4872 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4873 | |
| 4874 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4875 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4876 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4877 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4878 | |
| 4879 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4880 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4881 | ds_pool_ci.pNext = NULL; |
| 4882 | ds_pool_ci.maxSets = 1; |
| 4883 | ds_pool_ci.poolSizeCount = 1; |
| 4884 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4885 | |
| 4886 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4887 | err = |
| 4888 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4889 | ASSERT_VK_SUCCESS(err); |
| 4890 | |
| 4891 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4892 | dsl_binding.binding = 0; |
| 4893 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4894 | dsl_binding.descriptorCount = 1; |
| 4895 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4896 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4897 | |
| 4898 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4899 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4900 | ds_layout_ci.pNext = NULL; |
| 4901 | ds_layout_ci.bindingCount = 1; |
| 4902 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4903 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4904 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4905 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4906 | ASSERT_VK_SUCCESS(err); |
| 4907 | |
| 4908 | VkDescriptorSet descriptorSet; |
| 4909 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4910 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4911 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4912 | alloc_info.descriptorPool = ds_pool; |
| 4913 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4914 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4915 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4916 | ASSERT_VK_SUCCESS(err); |
| 4917 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4918 | VkBufferView view = |
| 4919 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4920 | VkWriteDescriptorSet descriptor_write; |
| 4921 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4922 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4923 | descriptor_write.dstSet = descriptorSet; |
| 4924 | descriptor_write.dstBinding = 0; |
| 4925 | descriptor_write.descriptorCount = 1; |
| 4926 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4927 | descriptor_write.pTexelBufferView = &view; |
| 4928 | |
| 4929 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4930 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4931 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4932 | |
| 4933 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4934 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4935 | } |
| 4936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4937 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4938 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4939 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4940 | // 1. No dynamicOffset supplied |
| 4941 | // 2. Too many dynamicOffsets supplied |
| 4942 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4943 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4944 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4945 | " requires 1 dynamicOffsets, but only " |
| 4946 | "0 dynamicOffsets are left in " |
| 4947 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4948 | |
| 4949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4950 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4951 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4952 | |
| 4953 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4954 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4955 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4956 | |
| 4957 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4958 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4959 | ds_pool_ci.pNext = NULL; |
| 4960 | ds_pool_ci.maxSets = 1; |
| 4961 | ds_pool_ci.poolSizeCount = 1; |
| 4962 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4963 | |
| 4964 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4965 | err = |
| 4966 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4967 | ASSERT_VK_SUCCESS(err); |
| 4968 | |
| 4969 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4970 | dsl_binding.binding = 0; |
| 4971 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4972 | dsl_binding.descriptorCount = 1; |
| 4973 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4974 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4975 | |
| 4976 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4977 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4978 | ds_layout_ci.pNext = NULL; |
| 4979 | ds_layout_ci.bindingCount = 1; |
| 4980 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4981 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4982 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4983 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4984 | ASSERT_VK_SUCCESS(err); |
| 4985 | |
| 4986 | VkDescriptorSet descriptorSet; |
| 4987 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4988 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4989 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4990 | alloc_info.descriptorPool = ds_pool; |
| 4991 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4992 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4993 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4994 | ASSERT_VK_SUCCESS(err); |
| 4995 | |
| 4996 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4997 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4998 | pipeline_layout_ci.pNext = NULL; |
| 4999 | pipeline_layout_ci.setLayoutCount = 1; |
| 5000 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5001 | |
| 5002 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5003 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5004 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5005 | ASSERT_VK_SUCCESS(err); |
| 5006 | |
| 5007 | // Create a buffer to update the descriptor with |
| 5008 | uint32_t qfi = 0; |
| 5009 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5010 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5011 | buffCI.size = 1024; |
| 5012 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5013 | buffCI.queueFamilyIndexCount = 1; |
| 5014 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5015 | |
| 5016 | VkBuffer dyub; |
| 5017 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5018 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5019 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 5020 | // error |
| 5021 | VkMemoryAllocateInfo mem_alloc = {}; |
| 5022 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5023 | mem_alloc.pNext = NULL; |
| 5024 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 5025 | mem_alloc.memoryTypeIndex = 0; |
| 5026 | |
| 5027 | VkMemoryRequirements memReqs; |
| 5028 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 5029 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 5030 | 0); |
| 5031 | if (!pass) { |
| 5032 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 5033 | return; |
| 5034 | } |
| 5035 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5036 | VkDeviceMemory mem; |
| 5037 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 5038 | ASSERT_VK_SUCCESS(err); |
| 5039 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 5040 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5041 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5042 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5043 | buffInfo.buffer = dyub; |
| 5044 | buffInfo.offset = 0; |
| 5045 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5046 | |
| 5047 | VkWriteDescriptorSet descriptor_write; |
| 5048 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5049 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5050 | descriptor_write.dstSet = descriptorSet; |
| 5051 | descriptor_write.dstBinding = 0; |
| 5052 | descriptor_write.descriptorCount = 1; |
| 5053 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 5054 | descriptor_write.pBufferInfo = &buffInfo; |
| 5055 | |
| 5056 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5057 | |
| 5058 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5059 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5060 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5061 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5062 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5063 | uint32_t pDynOff[2] = {512, 756}; |
| 5064 | // 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] | 5065 | m_errorMonitor->SetDesiredFailureMsg( |
| 5066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5067 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5068 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5069 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5070 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5071 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5072 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5073 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5074 | " dynamic offset 512 combined with " |
| 5075 | "offset 0 and range 1024 that " |
| 5076 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5077 | // Create PSO to be used for draw-time errors below |
| 5078 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5079 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5080 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5081 | "out gl_PerVertex { \n" |
| 5082 | " vec4 gl_Position;\n" |
| 5083 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5084 | "void main(){\n" |
| 5085 | " gl_Position = vec4(1);\n" |
| 5086 | "}\n"; |
| 5087 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5088 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5089 | "\n" |
| 5090 | "layout(location=0) out vec4 x;\n" |
| 5091 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5092 | "void main(){\n" |
| 5093 | " x = vec4(bar.y);\n" |
| 5094 | "}\n"; |
| 5095 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5096 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5097 | VkPipelineObj pipe(m_device); |
| 5098 | pipe.AddShader(&vs); |
| 5099 | pipe.AddShader(&fs); |
| 5100 | pipe.AddColorAttachment(); |
| 5101 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 5102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5103 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5104 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5105 | // This update should succeed, but offset size of 512 will overstep buffer |
| 5106 | // /w range 1024 & size 1024 |
| 5107 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5108 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5109 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5110 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5111 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5112 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5113 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 5114 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5115 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5116 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5117 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5118 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5119 | } |
| 5120 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5121 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5122 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5124 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5125 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5126 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5127 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5128 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5129 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5130 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5131 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 5132 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 5133 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5134 | // |
| 5135 | // Check for invalid push constant ranges in pipeline layouts. |
| 5136 | // |
| 5137 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5138 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5139 | char const *msg; |
| 5140 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5141 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5142 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 5143 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 5144 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5145 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5146 | "size 0."}, |
| 5147 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5148 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5149 | "size 1."}, |
| 5150 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5151 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5152 | "size 1."}, |
| 5153 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5154 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5155 | "size 0."}, |
| 5156 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5157 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 5158 | "offset 1. Offset must"}, |
| 5159 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 5160 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5161 | "with offset "}, |
| 5162 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 5163 | "vkCreatePipelineLayout() call has push constants " |
| 5164 | "index 0 with offset "}, |
| 5165 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 5166 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 5167 | "with offset "}, |
| 5168 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 5169 | "vkCreatePipelineLayout() call has push " |
| 5170 | "constants index 0 with offset "}, |
| 5171 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 5172 | "vkCreatePipelineLayout() call has push " |
| 5173 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5174 | }}; |
| 5175 | |
| 5176 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5177 | for (const auto &iter : range_tests) { |
| 5178 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5179 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5180 | iter.msg); |
| 5181 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5182 | NULL, &pipeline_layout); |
| 5183 | m_errorMonitor->VerifyFound(); |
| 5184 | if (VK_SUCCESS == err) { |
| 5185 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5186 | } |
| 5187 | } |
| 5188 | |
| 5189 | // Check for invalid stage flag |
| 5190 | pc_range.offset = 0; |
| 5191 | pc_range.size = 16; |
| 5192 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5193 | m_errorMonitor->SetDesiredFailureMsg( |
| 5194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5195 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5196 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5197 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5198 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5199 | if (VK_SUCCESS == err) { |
| 5200 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5201 | } |
| 5202 | |
| 5203 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5204 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5205 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5206 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5207 | char const *msg; |
| 5208 | }; |
| 5209 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5210 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 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 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5215 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5216 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 5217 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 5218 | { |
| 5219 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5220 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5221 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5222 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5223 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5224 | "vkCreatePipelineLayout() call has push constants with " |
| 5225 | "overlapping " |
| 5226 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 5227 | }, |
| 5228 | { |
| 5229 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5230 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5231 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5232 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5233 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5234 | "vkCreatePipelineLayout() call has push constants with " |
| 5235 | "overlapping " |
| 5236 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 5237 | }, |
| 5238 | { |
| 5239 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5240 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5241 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5242 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 5243 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5244 | "vkCreatePipelineLayout() call has push constants with " |
| 5245 | "overlapping " |
| 5246 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 5247 | }, |
| 5248 | { |
| 5249 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5250 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 5251 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 5252 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 5253 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 5254 | "vkCreatePipelineLayout() call has push constants with " |
| 5255 | "overlapping " |
| 5256 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 5257 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5258 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5259 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5260 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5261 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 5262 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5263 | iter.msg); |
| 5264 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5265 | NULL, &pipeline_layout); |
| 5266 | m_errorMonitor->VerifyFound(); |
| 5267 | if (VK_SUCCESS == err) { |
| 5268 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5269 | } |
| 5270 | } |
| 5271 | |
| 5272 | // 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] | 5273 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 5274 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5275 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 5276 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 5277 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 5278 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 5279 | ""}, |
| 5280 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 5281 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 5282 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 5283 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 5284 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 5285 | ""}}}; |
| 5286 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5287 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 5288 | m_errorMonitor->ExpectSuccess(); |
| 5289 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 5290 | NULL, &pipeline_layout); |
| 5291 | m_errorMonitor->VerifyNotFound(); |
| 5292 | if (VK_SUCCESS == err) { |
| 5293 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5294 | } |
| 5295 | } |
| 5296 | |
| 5297 | // |
| 5298 | // CmdPushConstants tests |
| 5299 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5300 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5301 | |
| 5302 | // 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] | 5303 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 5304 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 5305 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 5306 | "must be greater than zero and a multiple of 4."}, |
| 5307 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 5308 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5309 | "must be greater than zero and a multiple of 4."}, |
| 5310 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 5311 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 5312 | "must be greater than zero and a multiple of 4."}, |
| 5313 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 5314 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5315 | "Offset must be a multiple of 4."}, |
| 5316 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 5317 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 5318 | "Offset must be a multiple of 4."}, |
| 5319 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5320 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5321 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5322 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 5323 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 5324 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5325 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 5326 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 5327 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5328 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 5329 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 5330 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5331 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 5332 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 5333 | "any of the ranges in pipeline layout"}, |
| 5334 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5335 | 0, 16}, |
| 5336 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 5337 | "any of the ranges in pipeline layout"}, |
| 5338 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 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, too_big}, |
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, too_big, 0}, |
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, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5345 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5346 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5347 | "vkCmdPushConstants() call has push constants with offset "}, |
| 5348 | }}; |
| 5349 | |
| 5350 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5351 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5352 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5353 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5354 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5355 | pipeline_layout_ci.pushConstantRangeCount = |
| 5356 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5357 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5358 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5359 | &pipeline_layout); |
| 5360 | ASSERT_VK_SUCCESS(err); |
| 5361 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5362 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5363 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5364 | iter.msg); |
| 5365 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5366 | iter.range.stageFlags, iter.range.offset, |
| 5367 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5368 | m_errorMonitor->VerifyFound(); |
| 5369 | } |
| 5370 | |
| 5371 | // Check for invalid stage flag |
| 5372 | m_errorMonitor->SetDesiredFailureMsg( |
| 5373 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5374 | "vkCmdPushConstants() call has no stageFlags set."); |
| 5375 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5376 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5377 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5378 | EndCommandBuffer(); |
| 5379 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5380 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5381 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5382 | // overlapping range tests with cmd |
| 5383 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 5384 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 5385 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 5386 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5387 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 5388 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 5389 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5390 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 5391 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 5392 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 5393 | }}; |
| 5394 | const VkPushConstantRange pc_range3[] = { |
| 5395 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5396 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5397 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5398 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5399 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5400 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5401 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5402 | }; |
| 5403 | pipeline_layout_ci.pushConstantRangeCount = |
| 5404 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 5405 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 5406 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5407 | &pipeline_layout); |
| 5408 | ASSERT_VK_SUCCESS(err); |
| 5409 | BeginCommandBuffer(); |
| 5410 | for (const auto &iter : cmd_overlap_tests) { |
| 5411 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5412 | iter.msg); |
| 5413 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5414 | iter.range.stageFlags, iter.range.offset, |
| 5415 | iter.range.size, dummy_values); |
| 5416 | m_errorMonitor->VerifyFound(); |
| 5417 | } |
| 5418 | EndCommandBuffer(); |
| 5419 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 5420 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5421 | |
| 5422 | // positive overlapping range tests with cmd |
| 5423 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 5424 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 5425 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 5426 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 5427 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 5428 | }}; |
| 5429 | const VkPushConstantRange pc_range4[] = { |
| 5430 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 5431 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 5432 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 5433 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 5434 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 5435 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 5436 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5437 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5438 | }; |
| 5439 | pipeline_layout_ci.pushConstantRangeCount = |
| 5440 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 5441 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 5442 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5443 | &pipeline_layout); |
| 5444 | ASSERT_VK_SUCCESS(err); |
| 5445 | BeginCommandBuffer(); |
| 5446 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5447 | m_errorMonitor->ExpectSuccess(); |
| 5448 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5449 | iter.range.stageFlags, iter.range.offset, |
| 5450 | iter.range.size, dummy_values); |
| 5451 | m_errorMonitor->VerifyNotFound(); |
| 5452 | } |
| 5453 | EndCommandBuffer(); |
| 5454 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5455 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5456 | } |
| 5457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5459 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5460 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5461 | |
| 5462 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5463 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5464 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5465 | |
| 5466 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5467 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5468 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5469 | ds_type_count[0].descriptorCount = 10; |
| 5470 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5471 | ds_type_count[1].descriptorCount = 2; |
| 5472 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5473 | ds_type_count[2].descriptorCount = 2; |
| 5474 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5475 | ds_type_count[3].descriptorCount = 5; |
| 5476 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5477 | // type |
| 5478 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5479 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5480 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5481 | |
| 5482 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5483 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5484 | ds_pool_ci.pNext = NULL; |
| 5485 | ds_pool_ci.maxSets = 5; |
| 5486 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5487 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5488 | |
| 5489 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5490 | err = |
| 5491 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5492 | ASSERT_VK_SUCCESS(err); |
| 5493 | |
| 5494 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5495 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5496 | dsl_binding[0].binding = 0; |
| 5497 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5498 | dsl_binding[0].descriptorCount = 5; |
| 5499 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5500 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5501 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5502 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5503 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5504 | dsl_fs_stage_only.binding = 0; |
| 5505 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5506 | dsl_fs_stage_only.descriptorCount = 5; |
| 5507 | dsl_fs_stage_only.stageFlags = |
| 5508 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5509 | // bind time |
| 5510 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5511 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5512 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5513 | ds_layout_ci.pNext = NULL; |
| 5514 | ds_layout_ci.bindingCount = 1; |
| 5515 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5516 | static const uint32_t NUM_LAYOUTS = 4; |
| 5517 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5518 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5519 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5520 | // layout for error case |
| 5521 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5522 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5523 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5524 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5526 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5527 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5528 | dsl_binding[0].binding = 0; |
| 5529 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5530 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5531 | dsl_binding[1].binding = 1; |
| 5532 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5533 | dsl_binding[1].descriptorCount = 2; |
| 5534 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5535 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5536 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5537 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5538 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5539 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5540 | ASSERT_VK_SUCCESS(err); |
| 5541 | dsl_binding[0].binding = 0; |
| 5542 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5543 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5544 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5545 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5546 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5547 | ASSERT_VK_SUCCESS(err); |
| 5548 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5549 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5551 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5552 | ASSERT_VK_SUCCESS(err); |
| 5553 | |
| 5554 | static const uint32_t NUM_SETS = 4; |
| 5555 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5556 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5557 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5558 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5559 | alloc_info.descriptorPool = ds_pool; |
| 5560 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5561 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5562 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5563 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5564 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5565 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5566 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5567 | err = |
| 5568 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5569 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5570 | |
| 5571 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5572 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5573 | pipeline_layout_ci.pNext = NULL; |
| 5574 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5575 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5576 | |
| 5577 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5578 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5579 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5580 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5581 | // Create pipelineLayout with only one setLayout |
| 5582 | pipeline_layout_ci.setLayoutCount = 1; |
| 5583 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5585 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5586 | ASSERT_VK_SUCCESS(err); |
| 5587 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5588 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5589 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5590 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5591 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5592 | ASSERT_VK_SUCCESS(err); |
| 5593 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5594 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5595 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5597 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5598 | ASSERT_VK_SUCCESS(err); |
| 5599 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5600 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5601 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5602 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5603 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5604 | ASSERT_VK_SUCCESS(err); |
| 5605 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5606 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5607 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5608 | pl_bad_s0[1] = ds_layout[1]; |
| 5609 | pipeline_layout_ci.setLayoutCount = 2; |
| 5610 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5611 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5612 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5613 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5614 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5615 | |
| 5616 | // Create a buffer to update the descriptor with |
| 5617 | uint32_t qfi = 0; |
| 5618 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5619 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5620 | buffCI.size = 1024; |
| 5621 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5622 | buffCI.queueFamilyIndexCount = 1; |
| 5623 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5624 | |
| 5625 | VkBuffer dyub; |
| 5626 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5627 | ASSERT_VK_SUCCESS(err); |
| 5628 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5629 | static const uint32_t NUM_BUFFS = 5; |
| 5630 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5631 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5632 | buffInfo[i].buffer = dyub; |
| 5633 | buffInfo[i].offset = 0; |
| 5634 | buffInfo[i].range = 1024; |
| 5635 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5636 | VkImage image; |
| 5637 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5638 | const int32_t tex_width = 32; |
| 5639 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5640 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5641 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5642 | image_create_info.pNext = NULL; |
| 5643 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5644 | image_create_info.format = tex_format; |
| 5645 | image_create_info.extent.width = tex_width; |
| 5646 | image_create_info.extent.height = tex_height; |
| 5647 | image_create_info.extent.depth = 1; |
| 5648 | image_create_info.mipLevels = 1; |
| 5649 | image_create_info.arrayLayers = 1; |
| 5650 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5651 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5652 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5653 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5654 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5655 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5657 | VkMemoryRequirements memReqs; |
| 5658 | VkDeviceMemory imageMem; |
| 5659 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5660 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5661 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5662 | memAlloc.pNext = NULL; |
| 5663 | memAlloc.allocationSize = 0; |
| 5664 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5665 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5666 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5667 | pass = |
| 5668 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5669 | ASSERT_TRUE(pass); |
| 5670 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5671 | ASSERT_VK_SUCCESS(err); |
| 5672 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5673 | ASSERT_VK_SUCCESS(err); |
| 5674 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5675 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5676 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5677 | image_view_create_info.image = image; |
| 5678 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5679 | image_view_create_info.format = tex_format; |
| 5680 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5681 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5682 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5683 | image_view_create_info.subresourceRange.aspectMask = |
| 5684 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5685 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5686 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5687 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5688 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5689 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5690 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5691 | imageInfo[0].imageView = view; |
| 5692 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5693 | imageInfo[1].imageView = view; |
| 5694 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5695 | imageInfo[2].imageView = view; |
| 5696 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5697 | imageInfo[3].imageView = view; |
| 5698 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5699 | |
| 5700 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5701 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5702 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5703 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5704 | descriptor_write[0].dstBinding = 0; |
| 5705 | descriptor_write[0].descriptorCount = 5; |
| 5706 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5707 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5708 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5709 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5710 | descriptor_write[1].dstBinding = 0; |
| 5711 | descriptor_write[1].descriptorCount = 2; |
| 5712 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5713 | descriptor_write[1].pImageInfo = imageInfo; |
| 5714 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5715 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5716 | descriptor_write[2].dstBinding = 1; |
| 5717 | descriptor_write[2].descriptorCount = 2; |
| 5718 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5719 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5720 | |
| 5721 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5722 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5723 | // Create PSO to be used for draw-time errors below |
| 5724 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5725 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5726 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5727 | "out gl_PerVertex {\n" |
| 5728 | " vec4 gl_Position;\n" |
| 5729 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5730 | "void main(){\n" |
| 5731 | " gl_Position = vec4(1);\n" |
| 5732 | "}\n"; |
| 5733 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5734 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5735 | "\n" |
| 5736 | "layout(location=0) out vec4 x;\n" |
| 5737 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5738 | "void main(){\n" |
| 5739 | " x = vec4(bar.y);\n" |
| 5740 | "}\n"; |
| 5741 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5742 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5743 | VkPipelineObj pipe(m_device); |
| 5744 | pipe.AddShader(&vs); |
| 5745 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5746 | pipe.AddColorAttachment(); |
| 5747 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5748 | |
| 5749 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5750 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5751 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5752 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5753 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5754 | // of PSO |
| 5755 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5756 | // cmd_pipeline.c |
| 5757 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5758 | // cmd_bind_graphics_pipeline() |
| 5759 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5760 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5761 | // First cause various verify_layout_compatibility() fails |
| 5762 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5763 | // verify_set_layout_compatibility fail cases: |
| 5764 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5765 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5766 | " due to: invalid VkPipelineLayout "); |
| 5767 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5768 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5769 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5770 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5771 | m_errorMonitor->VerifyFound(); |
| 5772 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5773 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5774 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5775 | " attempting to bind set to index 1"); |
| 5776 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5777 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5778 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5779 | m_errorMonitor->VerifyFound(); |
| 5780 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5781 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5782 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5783 | // descriptors |
| 5784 | m_errorMonitor->SetDesiredFailureMsg( |
| 5785 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5786 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5787 | vkCmdBindDescriptorSets( |
| 5788 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5789 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5790 | m_errorMonitor->VerifyFound(); |
| 5791 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5792 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5793 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5794 | m_errorMonitor->SetDesiredFailureMsg( |
| 5795 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5796 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5797 | vkCmdBindDescriptorSets( |
| 5798 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5799 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5800 | m_errorMonitor->VerifyFound(); |
| 5801 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5802 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5803 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5804 | m_errorMonitor->SetDesiredFailureMsg( |
| 5805 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5806 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5807 | vkCmdBindDescriptorSets( |
| 5808 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5809 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5810 | m_errorMonitor->VerifyFound(); |
| 5811 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5812 | // Cause INFO messages due to disturbing previously bound Sets |
| 5813 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5814 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5815 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5816 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5817 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5818 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5819 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | " previously bound as set #0 was disturbed "); |
| 5821 | vkCmdBindDescriptorSets( |
| 5822 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5823 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5824 | m_errorMonitor->VerifyFound(); |
| 5825 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5826 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5827 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5828 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5829 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5831 | " newly bound as set #0 so set #1 and " |
| 5832 | "any subsequent sets were disturbed "); |
| 5833 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5834 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5835 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5836 | m_errorMonitor->VerifyFound(); |
| 5837 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5838 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5839 | // 1. Error due to not binding required set (we actually use same code as |
| 5840 | // above to disturb set0) |
| 5841 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5842 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5843 | 2, &descriptorSet[0], 0, NULL); |
| 5844 | vkCmdBindDescriptorSets( |
| 5845 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5846 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5847 | m_errorMonitor->SetDesiredFailureMsg( |
| 5848 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5849 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5850 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5851 | m_errorMonitor->VerifyFound(); |
| 5852 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5853 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | // 2. Error due to bound set not being compatible with PSO's |
| 5855 | // VkPipelineLayout (diff stageFlags in this case) |
| 5856 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5857 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5858 | 2, &descriptorSet[0], 0, NULL); |
| 5859 | m_errorMonitor->SetDesiredFailureMsg( |
| 5860 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5861 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5862 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5863 | m_errorMonitor->VerifyFound(); |
| 5864 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5865 | // Remaining clean-up |
| 5866 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5867 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5868 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5869 | } |
| 5870 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5871 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5872 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5873 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5874 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5875 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5876 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 5877 | vkDestroyImage(m_device->device(), image, NULL); |
| 5878 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5879 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5882 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5883 | m_errorMonitor->SetDesiredFailureMsg( |
| 5884 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5885 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5886 | |
| 5887 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5888 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5889 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5890 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5891 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5892 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5893 | } |
| 5894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5895 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5896 | VkResult err; |
| 5897 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | m_errorMonitor->SetDesiredFailureMsg( |
| 5900 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5901 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5902 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5903 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5904 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5905 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5906 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5907 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5908 | cmd.commandPool = m_commandPool; |
| 5909 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5910 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5911 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5912 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5913 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5914 | |
| 5915 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5916 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5917 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5918 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5919 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5920 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5921 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5922 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5923 | |
| 5924 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5925 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5926 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5927 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5928 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5929 | } |
| 5930 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5931 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5932 | // Cause error due to Begin while recording CB |
| 5933 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5934 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5935 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5936 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5938 | |
| 5939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5940 | |
| 5941 | // Calls AllocateCommandBuffers |
| 5942 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5943 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5944 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5945 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5946 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5947 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5948 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5949 | cmd_buf_info.pNext = NULL; |
| 5950 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5951 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5952 | |
| 5953 | // Begin CB to transition to recording state |
| 5954 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5955 | // Can't re-begin. This should trigger error |
| 5956 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5957 | m_errorMonitor->VerifyFound(); |
| 5958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5959 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5960 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5961 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5962 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5963 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5964 | m_errorMonitor->VerifyFound(); |
| 5965 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5966 | m_errorMonitor->SetDesiredFailureMsg( |
| 5967 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5968 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5969 | // Transition CB to RECORDED state |
| 5970 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5971 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5972 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5973 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5974 | } |
| 5975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5977 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5979 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5980 | m_errorMonitor->SetDesiredFailureMsg( |
| 5981 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5982 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5983 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5985 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5986 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5987 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5988 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5989 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5990 | |
| 5991 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5992 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5993 | ds_pool_ci.pNext = NULL; |
| 5994 | ds_pool_ci.maxSets = 1; |
| 5995 | ds_pool_ci.poolSizeCount = 1; |
| 5996 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5997 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5998 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5999 | err = |
| 6000 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6001 | ASSERT_VK_SUCCESS(err); |
| 6002 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6003 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6004 | dsl_binding.binding = 0; |
| 6005 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6006 | dsl_binding.descriptorCount = 1; |
| 6007 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6008 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6009 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6010 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6012 | ds_layout_ci.pNext = NULL; |
| 6013 | ds_layout_ci.bindingCount = 1; |
| 6014 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6015 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6016 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6017 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6018 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6019 | ASSERT_VK_SUCCESS(err); |
| 6020 | |
| 6021 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6022 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6023 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6024 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6025 | alloc_info.descriptorPool = ds_pool; |
| 6026 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6028 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6029 | ASSERT_VK_SUCCESS(err); |
| 6030 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6031 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6032 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6033 | pipeline_layout_ci.setLayoutCount = 1; |
| 6034 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6035 | |
| 6036 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6037 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6038 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6039 | ASSERT_VK_SUCCESS(err); |
| 6040 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6041 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6042 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6043 | |
| 6044 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6045 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6046 | vp_state_ci.scissorCount = 1; |
| 6047 | vp_state_ci.pScissors = ≻ |
| 6048 | vp_state_ci.viewportCount = 1; |
| 6049 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6050 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6051 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6052 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6053 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6054 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6055 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6056 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6057 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6058 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6059 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6060 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6062 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6063 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6064 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6065 | gp_ci.layout = pipeline_layout; |
| 6066 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6067 | |
| 6068 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6069 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6070 | pc_ci.initialDataSize = 0; |
| 6071 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6072 | |
| 6073 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6074 | VkPipelineCache pipelineCache; |
| 6075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6076 | err = |
| 6077 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 6078 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6080 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6082 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6083 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6084 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6085 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6086 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6087 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6088 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6089 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 6090 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 6091 | { |
| 6092 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6093 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6094 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6096 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 6097 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6098 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6100 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6101 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6102 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6103 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6104 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6105 | |
| 6106 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6107 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6108 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6109 | ds_pool_ci.poolSizeCount = 1; |
| 6110 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6111 | |
| 6112 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6113 | err = vkCreateDescriptorPool(m_device->device(), |
| 6114 | 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] | 6115 | ASSERT_VK_SUCCESS(err); |
| 6116 | |
| 6117 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6118 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6119 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6120 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6121 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6122 | dsl_binding.pImmutableSamplers = NULL; |
| 6123 | |
| 6124 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6125 | ds_layout_ci.sType = |
| 6126 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6127 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6128 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6129 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6130 | |
| 6131 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6132 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6133 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6134 | ASSERT_VK_SUCCESS(err); |
| 6135 | |
| 6136 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6137 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 6138 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6139 | ASSERT_VK_SUCCESS(err); |
| 6140 | |
| 6141 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6142 | pipeline_layout_ci.sType = |
| 6143 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6144 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6145 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6146 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6147 | |
| 6148 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6149 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6150 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6151 | ASSERT_VK_SUCCESS(err); |
| 6152 | |
| 6153 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 6154 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 6157 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6158 | // 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] | 6159 | VkShaderObj |
| 6160 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 6161 | this); |
| 6162 | VkShaderObj |
| 6163 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 6164 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6166 | shaderStages[0].sType = |
| 6167 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6168 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6169 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6170 | shaderStages[1].sType = |
| 6171 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6172 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6173 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6174 | shaderStages[2].sType = |
| 6175 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6176 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6177 | shaderStages[2].shader = te.handle(); |
| 6178 | |
| 6179 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6180 | iaCI.sType = |
| 6181 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6182 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6183 | |
| 6184 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 6185 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 6186 | tsCI.patchControlPoints = 0; // This will cause an error |
| 6187 | |
| 6188 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6189 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6190 | gp_ci.pNext = NULL; |
| 6191 | gp_ci.stageCount = 3; |
| 6192 | gp_ci.pStages = shaderStages; |
| 6193 | gp_ci.pVertexInputState = NULL; |
| 6194 | gp_ci.pInputAssemblyState = &iaCI; |
| 6195 | gp_ci.pTessellationState = &tsCI; |
| 6196 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6197 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6198 | gp_ci.pMultisampleState = NULL; |
| 6199 | gp_ci.pDepthStencilState = NULL; |
| 6200 | gp_ci.pColorBlendState = NULL; |
| 6201 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6202 | gp_ci.layout = pipeline_layout; |
| 6203 | gp_ci.renderPass = renderPass(); |
| 6204 | |
| 6205 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6206 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6207 | pc_ci.pNext = NULL; |
| 6208 | pc_ci.initialSize = 0; |
| 6209 | pc_ci.initialData = 0; |
| 6210 | pc_ci.maxSize = 0; |
| 6211 | |
| 6212 | VkPipeline pipeline; |
| 6213 | VkPipelineCache pipelineCache; |
| 6214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6215 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 6216 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6217 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6218 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6219 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6220 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6221 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6222 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6223 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6224 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6225 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6226 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6227 | } |
| 6228 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6229 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6230 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6231 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6232 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6233 | m_errorMonitor->SetDesiredFailureMsg( |
| 6234 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6235 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 6236 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6238 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6239 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6240 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6241 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6242 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6243 | |
| 6244 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6245 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6246 | ds_pool_ci.maxSets = 1; |
| 6247 | ds_pool_ci.poolSizeCount = 1; |
| 6248 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6249 | |
| 6250 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6251 | err = |
| 6252 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6253 | ASSERT_VK_SUCCESS(err); |
| 6254 | |
| 6255 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6256 | dsl_binding.binding = 0; |
| 6257 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6258 | dsl_binding.descriptorCount = 1; |
| 6259 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6260 | |
| 6261 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6262 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6263 | ds_layout_ci.bindingCount = 1; |
| 6264 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6265 | |
| 6266 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6267 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6268 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6269 | ASSERT_VK_SUCCESS(err); |
| 6270 | |
| 6271 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6272 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6273 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6274 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6275 | alloc_info.descriptorPool = ds_pool; |
| 6276 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6277 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6278 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6279 | ASSERT_VK_SUCCESS(err); |
| 6280 | |
| 6281 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6282 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6283 | pipeline_layout_ci.setLayoutCount = 1; |
| 6284 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6285 | |
| 6286 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6287 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6288 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6289 | ASSERT_VK_SUCCESS(err); |
| 6290 | |
| 6291 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6292 | |
| 6293 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6294 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6295 | vp_state_ci.scissorCount = 0; |
| 6296 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 6297 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6298 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6299 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6300 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6301 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6302 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6303 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6304 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6305 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6306 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6307 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6308 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6309 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6310 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6311 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6312 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6313 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6314 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6315 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6316 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6317 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6318 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6319 | |
| 6320 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6321 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6322 | gp_ci.stageCount = 2; |
| 6323 | gp_ci.pStages = shaderStages; |
| 6324 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6325 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6326 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6327 | gp_ci.layout = pipeline_layout; |
| 6328 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6329 | |
| 6330 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6331 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6332 | |
| 6333 | VkPipeline pipeline; |
| 6334 | VkPipelineCache pipelineCache; |
| 6335 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6336 | err = |
| 6337 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6338 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6339 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6340 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6341 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6342 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6343 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6344 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6345 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6346 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6347 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6348 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6349 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 6350 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6351 | // 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] | 6352 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6353 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6355 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6356 | m_errorMonitor->SetDesiredFailureMsg( |
| 6357 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6358 | "Gfx Pipeline pViewportState is null. Even if "); |
| 6359 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6360 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6361 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6362 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6363 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6364 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6365 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6366 | |
| 6367 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6368 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6369 | ds_pool_ci.maxSets = 1; |
| 6370 | ds_pool_ci.poolSizeCount = 1; |
| 6371 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6372 | |
| 6373 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6374 | err = |
| 6375 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6376 | ASSERT_VK_SUCCESS(err); |
| 6377 | |
| 6378 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6379 | dsl_binding.binding = 0; |
| 6380 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6381 | dsl_binding.descriptorCount = 1; |
| 6382 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6383 | |
| 6384 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6385 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6386 | ds_layout_ci.bindingCount = 1; |
| 6387 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6388 | |
| 6389 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6391 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6392 | ASSERT_VK_SUCCESS(err); |
| 6393 | |
| 6394 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6395 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6396 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6397 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6398 | alloc_info.descriptorPool = ds_pool; |
| 6399 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6400 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6401 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6402 | ASSERT_VK_SUCCESS(err); |
| 6403 | |
| 6404 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6405 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6406 | pipeline_layout_ci.setLayoutCount = 1; |
| 6407 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6408 | |
| 6409 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6410 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6411 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6412 | ASSERT_VK_SUCCESS(err); |
| 6413 | |
| 6414 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6415 | // Set scissor as dynamic to avoid second error |
| 6416 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6417 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6418 | dyn_state_ci.dynamicStateCount = 1; |
| 6419 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6420 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6421 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6422 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6425 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6426 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6427 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6428 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6429 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6430 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6431 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6432 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6433 | |
| 6434 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 6435 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6436 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6437 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6438 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6439 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6440 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6441 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6442 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6443 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6444 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6445 | gp_ci.stageCount = 2; |
| 6446 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6447 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6448 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6449 | // should cause validation error |
| 6450 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6451 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6452 | gp_ci.layout = pipeline_layout; |
| 6453 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6454 | |
| 6455 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6456 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6457 | |
| 6458 | VkPipeline pipeline; |
| 6459 | VkPipelineCache pipelineCache; |
| 6460 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6461 | err = |
| 6462 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6463 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6464 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6465 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6466 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6467 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6468 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6469 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6470 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6471 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6472 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6473 | } |
| 6474 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6475 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6476 | // count |
| 6477 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6478 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6479 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6480 | m_errorMonitor->SetDesiredFailureMsg( |
| 6481 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6482 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6483 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6485 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6486 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6487 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6488 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6489 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6490 | |
| 6491 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6492 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6493 | ds_pool_ci.maxSets = 1; |
| 6494 | ds_pool_ci.poolSizeCount = 1; |
| 6495 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6496 | |
| 6497 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6498 | err = |
| 6499 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6500 | ASSERT_VK_SUCCESS(err); |
| 6501 | |
| 6502 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6503 | dsl_binding.binding = 0; |
| 6504 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6505 | dsl_binding.descriptorCount = 1; |
| 6506 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6507 | |
| 6508 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6509 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6510 | ds_layout_ci.bindingCount = 1; |
| 6511 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6512 | |
| 6513 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6514 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6515 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6516 | ASSERT_VK_SUCCESS(err); |
| 6517 | |
| 6518 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6519 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6520 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6521 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6522 | alloc_info.descriptorPool = ds_pool; |
| 6523 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6524 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6525 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6526 | ASSERT_VK_SUCCESS(err); |
| 6527 | |
| 6528 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6529 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6530 | pipeline_layout_ci.setLayoutCount = 1; |
| 6531 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6532 | |
| 6533 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6534 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6535 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6536 | ASSERT_VK_SUCCESS(err); |
| 6537 | |
| 6538 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6539 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6540 | vp_state_ci.viewportCount = 1; |
| 6541 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6542 | vp_state_ci.scissorCount = 1; |
| 6543 | vp_state_ci.pScissors = |
| 6544 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6545 | |
| 6546 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6547 | // Set scissor as dynamic to avoid that error |
| 6548 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6549 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6550 | dyn_state_ci.dynamicStateCount = 1; |
| 6551 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6552 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6553 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6554 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6555 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6556 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6557 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6558 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6559 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6560 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6561 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6562 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6563 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6564 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6565 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6566 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6567 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6568 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6569 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6570 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6571 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6572 | |
| 6573 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6574 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6575 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6576 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6577 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6578 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6579 | rs_ci.pNext = nullptr; |
| 6580 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6581 | VkPipelineColorBlendAttachmentState att = {}; |
| 6582 | att.blendEnable = VK_FALSE; |
| 6583 | att.colorWriteMask = 0xf; |
| 6584 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6585 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6586 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6587 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6588 | cb_ci.attachmentCount = 1; |
| 6589 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6590 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6591 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6592 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6593 | gp_ci.stageCount = 2; |
| 6594 | gp_ci.pStages = shaderStages; |
| 6595 | gp_ci.pVertexInputState = &vi_ci; |
| 6596 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6597 | gp_ci.pViewportState = &vp_state_ci; |
| 6598 | gp_ci.pRasterizationState = &rs_ci; |
| 6599 | gp_ci.pColorBlendState = &cb_ci; |
| 6600 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6601 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6602 | gp_ci.layout = pipeline_layout; |
| 6603 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6604 | |
| 6605 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6606 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6607 | |
| 6608 | VkPipeline pipeline; |
| 6609 | VkPipelineCache pipelineCache; |
| 6610 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6611 | err = |
| 6612 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6613 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6615 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6616 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6617 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6618 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6619 | // 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] | 6620 | // First need to successfully create the PSO from above by setting |
| 6621 | // pViewports |
| 6622 | m_errorMonitor->SetDesiredFailureMsg( |
| 6623 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6624 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6625 | "scissorCount is 1. These counts must match."); |
| 6626 | |
| 6627 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6628 | vp_state_ci.pViewports = &vp; |
| 6629 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6630 | &gp_ci, NULL, &pipeline); |
| 6631 | ASSERT_VK_SUCCESS(err); |
| 6632 | BeginCommandBuffer(); |
| 6633 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6634 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6635 | VkRect2D scissors[2] = {}; // don't care about data |
| 6636 | // Count of 2 doesn't match PSO count of 1 |
| 6637 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6638 | Draw(1, 0, 0, 0); |
| 6639 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6640 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6641 | |
| 6642 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6643 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6644 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6645 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6646 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6647 | } |
| 6648 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6649 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6650 | // viewportCount |
| 6651 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6652 | VkResult err; |
| 6653 | |
| 6654 | m_errorMonitor->SetDesiredFailureMsg( |
| 6655 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6656 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6657 | |
| 6658 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6659 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6660 | |
| 6661 | VkDescriptorPoolSize ds_type_count = {}; |
| 6662 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6663 | ds_type_count.descriptorCount = 1; |
| 6664 | |
| 6665 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6666 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6667 | ds_pool_ci.maxSets = 1; |
| 6668 | ds_pool_ci.poolSizeCount = 1; |
| 6669 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6670 | |
| 6671 | VkDescriptorPool ds_pool; |
| 6672 | err = |
| 6673 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6674 | ASSERT_VK_SUCCESS(err); |
| 6675 | |
| 6676 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6677 | dsl_binding.binding = 0; |
| 6678 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6679 | dsl_binding.descriptorCount = 1; |
| 6680 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6681 | |
| 6682 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6683 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6684 | ds_layout_ci.bindingCount = 1; |
| 6685 | ds_layout_ci.pBindings = &dsl_binding; |
| 6686 | |
| 6687 | VkDescriptorSetLayout ds_layout; |
| 6688 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6689 | &ds_layout); |
| 6690 | ASSERT_VK_SUCCESS(err); |
| 6691 | |
| 6692 | VkDescriptorSet descriptorSet; |
| 6693 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6694 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6695 | alloc_info.descriptorSetCount = 1; |
| 6696 | alloc_info.descriptorPool = ds_pool; |
| 6697 | alloc_info.pSetLayouts = &ds_layout; |
| 6698 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6699 | &descriptorSet); |
| 6700 | ASSERT_VK_SUCCESS(err); |
| 6701 | |
| 6702 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6703 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6704 | pipeline_layout_ci.setLayoutCount = 1; |
| 6705 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6706 | |
| 6707 | VkPipelineLayout pipeline_layout; |
| 6708 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6709 | &pipeline_layout); |
| 6710 | ASSERT_VK_SUCCESS(err); |
| 6711 | |
| 6712 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6713 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6714 | vp_state_ci.scissorCount = 1; |
| 6715 | vp_state_ci.pScissors = |
| 6716 | NULL; // Null scissor w/ count of 1 should cause error |
| 6717 | vp_state_ci.viewportCount = 1; |
| 6718 | vp_state_ci.pViewports = |
| 6719 | NULL; // vp is dynamic (below) so this won't cause error |
| 6720 | |
| 6721 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6722 | // Set scissor as dynamic to avoid that error |
| 6723 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6724 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6725 | dyn_state_ci.dynamicStateCount = 1; |
| 6726 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6727 | |
| 6728 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6729 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6730 | |
| 6731 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6732 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6733 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6734 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6735 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6736 | // but add it to be able to run on more devices |
| 6737 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6738 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6739 | |
| 6740 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6741 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6742 | vi_ci.pNext = nullptr; |
| 6743 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6744 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6745 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6746 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6747 | |
| 6748 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6749 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6750 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6751 | |
| 6752 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6753 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6754 | rs_ci.pNext = nullptr; |
| 6755 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6756 | VkPipelineColorBlendAttachmentState att = {}; |
| 6757 | att.blendEnable = VK_FALSE; |
| 6758 | att.colorWriteMask = 0xf; |
| 6759 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6760 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6761 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6762 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6763 | cb_ci.attachmentCount = 1; |
| 6764 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6765 | |
| 6766 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6767 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6768 | gp_ci.stageCount = 2; |
| 6769 | gp_ci.pStages = shaderStages; |
| 6770 | gp_ci.pVertexInputState = &vi_ci; |
| 6771 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6772 | gp_ci.pViewportState = &vp_state_ci; |
| 6773 | gp_ci.pRasterizationState = &rs_ci; |
| 6774 | gp_ci.pColorBlendState = &cb_ci; |
| 6775 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6776 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6777 | gp_ci.layout = pipeline_layout; |
| 6778 | gp_ci.renderPass = renderPass(); |
| 6779 | |
| 6780 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6781 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6782 | |
| 6783 | VkPipeline pipeline; |
| 6784 | VkPipelineCache pipelineCache; |
| 6785 | |
| 6786 | err = |
| 6787 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6788 | ASSERT_VK_SUCCESS(err); |
| 6789 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6790 | &gp_ci, NULL, &pipeline); |
| 6791 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6792 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6793 | |
| 6794 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6795 | // First need to successfully create the PSO from above by setting |
| 6796 | // pViewports |
| 6797 | m_errorMonitor->SetDesiredFailureMsg( |
| 6798 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6799 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6800 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6801 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6802 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6803 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6804 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6805 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6806 | ASSERT_VK_SUCCESS(err); |
| 6807 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6808 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6809 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6810 | VkViewport viewports[2] = {}; // don't care about data |
| 6811 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6812 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6813 | Draw(1, 0, 0, 0); |
| 6814 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6815 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6816 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6817 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6818 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6819 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6820 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6821 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6822 | } |
| 6823 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6824 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6825 | VkResult err; |
| 6826 | |
| 6827 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6828 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6829 | |
| 6830 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6831 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6832 | |
| 6833 | VkDescriptorPoolSize ds_type_count = {}; |
| 6834 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6835 | ds_type_count.descriptorCount = 1; |
| 6836 | |
| 6837 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6838 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6839 | ds_pool_ci.maxSets = 1; |
| 6840 | ds_pool_ci.poolSizeCount = 1; |
| 6841 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6842 | |
| 6843 | VkDescriptorPool ds_pool; |
| 6844 | err = |
| 6845 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6846 | ASSERT_VK_SUCCESS(err); |
| 6847 | |
| 6848 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6849 | dsl_binding.binding = 0; |
| 6850 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6851 | dsl_binding.descriptorCount = 1; |
| 6852 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6853 | |
| 6854 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6855 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6856 | ds_layout_ci.bindingCount = 1; |
| 6857 | ds_layout_ci.pBindings = &dsl_binding; |
| 6858 | |
| 6859 | VkDescriptorSetLayout ds_layout; |
| 6860 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6861 | &ds_layout); |
| 6862 | ASSERT_VK_SUCCESS(err); |
| 6863 | |
| 6864 | VkDescriptorSet descriptorSet; |
| 6865 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6866 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6867 | alloc_info.descriptorSetCount = 1; |
| 6868 | alloc_info.descriptorPool = ds_pool; |
| 6869 | alloc_info.pSetLayouts = &ds_layout; |
| 6870 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6871 | &descriptorSet); |
| 6872 | ASSERT_VK_SUCCESS(err); |
| 6873 | |
| 6874 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6875 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6876 | pipeline_layout_ci.setLayoutCount = 1; |
| 6877 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6878 | |
| 6879 | VkPipelineLayout pipeline_layout; |
| 6880 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6881 | &pipeline_layout); |
| 6882 | ASSERT_VK_SUCCESS(err); |
| 6883 | |
| 6884 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6885 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6886 | vp_state_ci.scissorCount = 1; |
| 6887 | vp_state_ci.pScissors = NULL; |
| 6888 | vp_state_ci.viewportCount = 1; |
| 6889 | vp_state_ci.pViewports = NULL; |
| 6890 | |
| 6891 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6892 | VK_DYNAMIC_STATE_SCISSOR, |
| 6893 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6894 | // Set scissor as dynamic to avoid that error |
| 6895 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6896 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6897 | dyn_state_ci.dynamicStateCount = 2; |
| 6898 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6899 | |
| 6900 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6901 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6902 | |
| 6903 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6904 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6905 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6906 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6907 | this); // TODO - We shouldn't need a fragment shader |
| 6908 | // but add it to be able to run on more devices |
| 6909 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6910 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6911 | |
| 6912 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6913 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6914 | vi_ci.pNext = nullptr; |
| 6915 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6916 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6917 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6918 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6919 | |
| 6920 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6921 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6922 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6923 | |
| 6924 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6925 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6926 | rs_ci.pNext = nullptr; |
| 6927 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6928 | // Check too low (line width of -1.0f). |
| 6929 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6930 | |
| 6931 | VkPipelineColorBlendAttachmentState att = {}; |
| 6932 | att.blendEnable = VK_FALSE; |
| 6933 | att.colorWriteMask = 0xf; |
| 6934 | |
| 6935 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6936 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6937 | cb_ci.pNext = nullptr; |
| 6938 | cb_ci.attachmentCount = 1; |
| 6939 | cb_ci.pAttachments = &att; |
| 6940 | |
| 6941 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6942 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6943 | gp_ci.stageCount = 2; |
| 6944 | gp_ci.pStages = shaderStages; |
| 6945 | gp_ci.pVertexInputState = &vi_ci; |
| 6946 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6947 | gp_ci.pViewportState = &vp_state_ci; |
| 6948 | gp_ci.pRasterizationState = &rs_ci; |
| 6949 | gp_ci.pColorBlendState = &cb_ci; |
| 6950 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6951 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6952 | gp_ci.layout = pipeline_layout; |
| 6953 | gp_ci.renderPass = renderPass(); |
| 6954 | |
| 6955 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6956 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6957 | |
| 6958 | VkPipeline pipeline; |
| 6959 | VkPipelineCache pipelineCache; |
| 6960 | |
| 6961 | err = |
| 6962 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6963 | ASSERT_VK_SUCCESS(err); |
| 6964 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6965 | &gp_ci, NULL, &pipeline); |
| 6966 | |
| 6967 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6968 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6969 | |
| 6970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6971 | "Attempt to set lineWidth to 65536"); |
| 6972 | |
| 6973 | // Check too high (line width of 65536.0f). |
| 6974 | rs_ci.lineWidth = 65536.0f; |
| 6975 | |
| 6976 | err = |
| 6977 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6978 | ASSERT_VK_SUCCESS(err); |
| 6979 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6980 | &gp_ci, NULL, &pipeline); |
| 6981 | |
| 6982 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6983 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6984 | |
| 6985 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6986 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6987 | |
| 6988 | dyn_state_ci.dynamicStateCount = 3; |
| 6989 | |
| 6990 | rs_ci.lineWidth = 1.0f; |
| 6991 | |
| 6992 | err = |
| 6993 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6994 | ASSERT_VK_SUCCESS(err); |
| 6995 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6996 | &gp_ci, NULL, &pipeline); |
| 6997 | BeginCommandBuffer(); |
| 6998 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6999 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 7000 | |
| 7001 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 7002 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7003 | m_errorMonitor->VerifyFound(); |
| 7004 | |
| 7005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7006 | "Attempt to set lineWidth to 65536"); |
| 7007 | |
| 7008 | // Check too high with dynamic setting. |
| 7009 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 7010 | m_errorMonitor->VerifyFound(); |
| 7011 | EndCommandBuffer(); |
| 7012 | |
| 7013 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 7014 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7015 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7016 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7017 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 7018 | } |
| 7019 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7020 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7021 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7022 | m_errorMonitor->SetDesiredFailureMsg( |
| 7023 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7024 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7025 | |
| 7026 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7027 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7028 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7029 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7030 | // Don't care about RenderPass handle b/c error should be flagged before |
| 7031 | // that |
| 7032 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 7033 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7034 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7035 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 7036 | } |
| 7037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7038 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7039 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7040 | m_errorMonitor->SetDesiredFailureMsg( |
| 7041 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7042 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7043 | |
| 7044 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7045 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7046 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7047 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7048 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 7049 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7050 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7051 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 7052 | rp_begin.pNext = NULL; |
| 7053 | rp_begin.renderPass = renderPass(); |
| 7054 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7055 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7056 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 7057 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7058 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7059 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7060 | } |
| 7061 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7062 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 7063 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 7064 | "the number of renderPass attachments that use loadOp" |
| 7065 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 7066 | |
| 7067 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7068 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7069 | |
| 7070 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 7071 | VkAttachmentReference attach = {}; |
| 7072 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7073 | VkSubpassDescription subpass = {}; |
| 7074 | subpass.inputAttachmentCount = 1; |
| 7075 | subpass.pInputAttachments = &attach; |
| 7076 | VkRenderPassCreateInfo rpci = {}; |
| 7077 | rpci.subpassCount = 1; |
| 7078 | rpci.pSubpasses = &subpass; |
| 7079 | rpci.attachmentCount = 1; |
| 7080 | VkAttachmentDescription attach_desc = {}; |
| 7081 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7082 | // Set loadOp to CLEAR |
| 7083 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 7084 | rpci.pAttachments = &attach_desc; |
| 7085 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 7086 | VkRenderPass rp; |
| 7087 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7088 | |
| 7089 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 7090 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 7091 | hinfo.renderPass = VK_NULL_HANDLE; |
| 7092 | hinfo.subpass = 0; |
| 7093 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 7094 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 7095 | hinfo.queryFlags = 0; |
| 7096 | hinfo.pipelineStatistics = 0; |
| 7097 | VkCommandBufferBeginInfo info = {}; |
| 7098 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 7099 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 7100 | info.pInheritanceInfo = &hinfo; |
| 7101 | |
| 7102 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 7103 | VkRenderPassBeginInfo rp_begin = {}; |
| 7104 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 7105 | rp_begin.pNext = NULL; |
| 7106 | rp_begin.renderPass = renderPass(); |
| 7107 | rp_begin.framebuffer = framebuffer(); |
| 7108 | rp_begin.clearValueCount = 0; // Should be 1 |
| 7109 | |
| 7110 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7111 | " has a clearValueCount of 0 but the " |
| 7112 | "actual number of attachments in " |
| 7113 | "renderPass "); |
| 7114 | |
| 7115 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 7116 | VK_SUBPASS_CONTENTS_INLINE); |
| 7117 | |
| 7118 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 7119 | |
| 7120 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7121 | } |
| 7122 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 7123 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 7124 | |
| 7125 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 7126 | |
| 7127 | m_errorMonitor->SetDesiredFailureMsg( |
| 7128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7129 | "It is invalid to issue this call inside an active render pass"); |
| 7130 | |
| 7131 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7132 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7133 | |
| 7134 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 7135 | BeginCommandBuffer(); |
| 7136 | |
| 7137 | // Call directly into vkEndCommandBuffer instead of the |
| 7138 | // the framework's EndCommandBuffer, which inserts a |
| 7139 | // vkEndRenderPass |
| 7140 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 7141 | |
| 7142 | m_errorMonitor->VerifyFound(); |
| 7143 | |
| 7144 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 7145 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 7146 | } |
| 7147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7148 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7149 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7150 | m_errorMonitor->SetDesiredFailureMsg( |
| 7151 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7152 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7153 | |
| 7154 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7155 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7156 | |
| 7157 | // Renderpass is started here |
| 7158 | BeginCommandBuffer(); |
| 7159 | |
| 7160 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7161 | vk_testing::Buffer dstBuffer; |
| 7162 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7163 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7164 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7165 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7166 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7167 | } |
| 7168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7169 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7170 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7171 | m_errorMonitor->SetDesiredFailureMsg( |
| 7172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7173 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7174 | |
| 7175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7176 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7177 | |
| 7178 | // Renderpass is started here |
| 7179 | BeginCommandBuffer(); |
| 7180 | |
| 7181 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7182 | vk_testing::Buffer dstBuffer; |
| 7183 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7185 | VkDeviceSize dstOffset = 0; |
| 7186 | VkDeviceSize dataSize = 1024; |
| 7187 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7189 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 7190 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7191 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7192 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7193 | } |
| 7194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7195 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7196 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7197 | m_errorMonitor->SetDesiredFailureMsg( |
| 7198 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7199 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7200 | |
| 7201 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7202 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7203 | |
| 7204 | // Renderpass is started here |
| 7205 | BeginCommandBuffer(); |
| 7206 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 7207 | VkClearColorValue clear_color; |
| 7208 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7209 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7210 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7211 | const int32_t tex_width = 32; |
| 7212 | const int32_t tex_height = 32; |
| 7213 | VkImageCreateInfo image_create_info = {}; |
| 7214 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7215 | image_create_info.pNext = NULL; |
| 7216 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7217 | image_create_info.format = tex_format; |
| 7218 | image_create_info.extent.width = tex_width; |
| 7219 | image_create_info.extent.height = tex_height; |
| 7220 | image_create_info.extent.depth = 1; |
| 7221 | image_create_info.mipLevels = 1; |
| 7222 | image_create_info.arrayLayers = 1; |
| 7223 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7224 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7225 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7226 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7227 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7228 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7229 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7231 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7232 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7233 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7234 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7235 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7236 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7237 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7238 | } |
| 7239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7240 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7241 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7242 | m_errorMonitor->SetDesiredFailureMsg( |
| 7243 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7244 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7245 | |
| 7246 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7247 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7248 | |
| 7249 | // Renderpass is started here |
| 7250 | BeginCommandBuffer(); |
| 7251 | |
| 7252 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 7253 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7254 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 7255 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7256 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 7257 | image_create_info.extent.width = 64; |
| 7258 | image_create_info.extent.height = 64; |
| 7259 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7260 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7261 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7262 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7263 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 7264 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7265 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7266 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 7267 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7268 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7269 | vkCmdClearDepthStencilImage( |
| 7270 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 7271 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 7272 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7273 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7274 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7275 | } |
| 7276 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7277 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7278 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7279 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7280 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7281 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7282 | "vkCmdClearAttachments: This call " |
| 7283 | "must be issued inside an active " |
| 7284 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7285 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7287 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7288 | |
| 7289 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7290 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7291 | ASSERT_VK_SUCCESS(err); |
| 7292 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7293 | VkClearAttachment color_attachment; |
| 7294 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7295 | color_attachment.clearValue.color.float32[0] = 0; |
| 7296 | color_attachment.clearValue.color.float32[1] = 0; |
| 7297 | color_attachment.clearValue.color.float32[2] = 0; |
| 7298 | color_attachment.clearValue.color.float32[3] = 0; |
| 7299 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7300 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 7301 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7302 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7303 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7304 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7305 | } |
| 7306 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 7307 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 7308 | // Try to add a buffer memory barrier with no buffer. |
| 7309 | m_errorMonitor->SetDesiredFailureMsg( |
| 7310 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7311 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 7312 | |
| 7313 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7314 | BeginCommandBuffer(); |
| 7315 | |
| 7316 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7317 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7318 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7319 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7320 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7321 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7322 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 7323 | buf_barrier.offset = 0; |
| 7324 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7325 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7326 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 7327 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 7328 | |
| 7329 | m_errorMonitor->VerifyFound(); |
| 7330 | } |
| 7331 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 7332 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 7333 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 7334 | |
| 7335 | m_errorMonitor->SetDesiredFailureMsg( |
| 7336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 7337 | |
| 7338 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7340 | |
| 7341 | VkMemoryBarrier mem_barrier = {}; |
| 7342 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 7343 | mem_barrier.pNext = NULL; |
| 7344 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7345 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7346 | BeginCommandBuffer(); |
| 7347 | // BeginCommandBuffer() starts a render pass |
| 7348 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7349 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7350 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 7351 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 7352 | m_errorMonitor->VerifyFound(); |
| 7353 | |
| 7354 | m_errorMonitor->SetDesiredFailureMsg( |
| 7355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7356 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 7357 | VkImageObj image(m_device); |
| 7358 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 7359 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 7360 | ASSERT_TRUE(image.initialized()); |
| 7361 | VkImageMemoryBarrier img_barrier = {}; |
| 7362 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 7363 | img_barrier.pNext = NULL; |
| 7364 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7365 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7366 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7367 | // New layout can't be UNDEFINED |
| 7368 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 7369 | img_barrier.image = image.handle(); |
| 7370 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7371 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7372 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7373 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7374 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7375 | img_barrier.subresourceRange.layerCount = 1; |
| 7376 | img_barrier.subresourceRange.levelCount = 1; |
| 7377 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7378 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7379 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7380 | nullptr, 1, &img_barrier); |
| 7381 | m_errorMonitor->VerifyFound(); |
| 7382 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7383 | |
| 7384 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7385 | "Subresource must have the sum of the " |
| 7386 | "baseArrayLayer"); |
| 7387 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 7388 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 7389 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7390 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7391 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7392 | nullptr, 1, &img_barrier); |
| 7393 | m_errorMonitor->VerifyFound(); |
| 7394 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 7395 | |
| 7396 | m_errorMonitor->SetDesiredFailureMsg( |
| 7397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7398 | "Subresource must have the sum of the baseMipLevel"); |
| 7399 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 7400 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 7401 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7402 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7403 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7404 | nullptr, 1, &img_barrier); |
| 7405 | m_errorMonitor->VerifyFound(); |
| 7406 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 7407 | |
| 7408 | m_errorMonitor->SetDesiredFailureMsg( |
| 7409 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7410 | "Buffer Barriers cannot be used during a render pass"); |
| 7411 | vk_testing::Buffer buffer; |
| 7412 | buffer.init(*m_device, 256); |
| 7413 | VkBufferMemoryBarrier buf_barrier = {}; |
| 7414 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 7415 | buf_barrier.pNext = NULL; |
| 7416 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 7417 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 7418 | buf_barrier.buffer = buffer.handle(); |
| 7419 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7420 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 7421 | buf_barrier.offset = 0; |
| 7422 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7423 | // Can't send buffer barrier during a render pass |
| 7424 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7425 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7426 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7427 | &buf_barrier, 0, nullptr); |
| 7428 | m_errorMonitor->VerifyFound(); |
| 7429 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 7430 | |
| 7431 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7432 | "which is not less than total size"); |
| 7433 | buf_barrier.offset = 257; |
| 7434 | // Offset greater than total size |
| 7435 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7436 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7437 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7438 | &buf_barrier, 0, nullptr); |
| 7439 | m_errorMonitor->VerifyFound(); |
| 7440 | buf_barrier.offset = 0; |
| 7441 | |
| 7442 | m_errorMonitor->SetDesiredFailureMsg( |
| 7443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 7444 | buf_barrier.size = 257; |
| 7445 | // Size greater than total size |
| 7446 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7447 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7448 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7449 | &buf_barrier, 0, nullptr); |
| 7450 | m_errorMonitor->VerifyFound(); |
| 7451 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7452 | |
| 7453 | m_errorMonitor->SetDesiredFailureMsg( |
| 7454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7455 | "Image is a depth and stencil format and thus must " |
| 7456 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7457 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7458 | VkDepthStencilObj ds_image(m_device); |
| 7459 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7460 | ASSERT_TRUE(ds_image.initialized()); |
| 7461 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7462 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7463 | img_barrier.image = ds_image.handle(); |
| 7464 | // Leave aspectMask at COLOR on purpose |
| 7465 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7466 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7467 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7468 | nullptr, 1, &img_barrier); |
| 7469 | m_errorMonitor->VerifyFound(); |
| 7470 | } |
| 7471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7472 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7473 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7474 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7476 | m_errorMonitor->SetDesiredFailureMsg( |
| 7477 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7478 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7479 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7482 | uint32_t qfi = 0; |
| 7483 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7485 | buffCI.size = 1024; |
| 7486 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7487 | buffCI.queueFamilyIndexCount = 1; |
| 7488 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7489 | |
| 7490 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7491 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7492 | ASSERT_VK_SUCCESS(err); |
| 7493 | |
| 7494 | BeginCommandBuffer(); |
| 7495 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7496 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7497 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7498 | // 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] | 7499 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7500 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7501 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7502 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7503 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7504 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7505 | } |
| 7506 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7507 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7508 | // Create an out-of-range queueFamilyIndex |
| 7509 | m_errorMonitor->SetDesiredFailureMsg( |
| 7510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7511 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7512 | "of the indices specified when the device was created, via the " |
| 7513 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7514 | |
| 7515 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7516 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7517 | VkBufferCreateInfo buffCI = {}; |
| 7518 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7519 | buffCI.size = 1024; |
| 7520 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7521 | buffCI.queueFamilyIndexCount = 1; |
| 7522 | // Introduce failure by specifying invalid queue_family_index |
| 7523 | uint32_t qfi = 777; |
| 7524 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7525 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7526 | |
| 7527 | VkBuffer ib; |
| 7528 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7529 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7530 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7531 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7532 | } |
| 7533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7534 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7535 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7536 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7537 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7538 | m_errorMonitor->SetDesiredFailureMsg( |
| 7539 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7540 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7541 | |
| 7542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7543 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7544 | |
| 7545 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7546 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7547 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7548 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7549 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7550 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7551 | } |
| 7552 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7553 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7554 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7555 | "that do not have correct usage bits sets."); |
| 7556 | VkResult err; |
| 7557 | |
| 7558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7559 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7560 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7561 | ds_type_count[i].type = VkDescriptorType(i); |
| 7562 | ds_type_count[i].descriptorCount = 1; |
| 7563 | } |
| 7564 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7565 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7566 | ds_pool_ci.pNext = NULL; |
| 7567 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7568 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7569 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7570 | |
| 7571 | VkDescriptorPool ds_pool; |
| 7572 | err = |
| 7573 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7574 | ASSERT_VK_SUCCESS(err); |
| 7575 | |
| 7576 | // Create 10 layouts where each has a single descriptor of different type |
| 7577 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7578 | {}; |
| 7579 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7580 | dsl_binding[i].binding = 0; |
| 7581 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7582 | dsl_binding[i].descriptorCount = 1; |
| 7583 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7584 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7585 | } |
| 7586 | |
| 7587 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7588 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7589 | ds_layout_ci.pNext = NULL; |
| 7590 | ds_layout_ci.bindingCount = 1; |
| 7591 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7592 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7593 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7594 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7595 | NULL, ds_layouts + i); |
| 7596 | ASSERT_VK_SUCCESS(err); |
| 7597 | } |
| 7598 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7599 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7600 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7601 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7602 | alloc_info.descriptorPool = ds_pool; |
| 7603 | alloc_info.pSetLayouts = ds_layouts; |
| 7604 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7605 | descriptor_sets); |
| 7606 | ASSERT_VK_SUCCESS(err); |
| 7607 | |
| 7608 | // Create a buffer & bufferView to be used for invalid updates |
| 7609 | VkBufferCreateInfo buff_ci = {}; |
| 7610 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7611 | // This usage is not valid for any descriptor type |
| 7612 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7613 | buff_ci.size = 256; |
| 7614 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7615 | VkBuffer buffer; |
| 7616 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7617 | ASSERT_VK_SUCCESS(err); |
| 7618 | |
| 7619 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7620 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7621 | buff_view_ci.buffer = buffer; |
| 7622 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7623 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7624 | VkBufferView buff_view; |
| 7625 | err = |
| 7626 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7627 | ASSERT_VK_SUCCESS(err); |
| 7628 | |
| 7629 | // Create an image to be used for invalid updates |
| 7630 | VkImageCreateInfo image_ci = {}; |
| 7631 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7632 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7633 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7634 | image_ci.extent.width = 64; |
| 7635 | image_ci.extent.height = 64; |
| 7636 | image_ci.extent.depth = 1; |
| 7637 | image_ci.mipLevels = 1; |
| 7638 | image_ci.arrayLayers = 1; |
| 7639 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7640 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7641 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7642 | // This usage is not valid for any descriptor type |
| 7643 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7644 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7645 | VkImage image; |
| 7646 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7647 | ASSERT_VK_SUCCESS(err); |
| 7648 | // Bind memory to image |
| 7649 | VkMemoryRequirements mem_reqs; |
| 7650 | VkDeviceMemory image_mem; |
| 7651 | bool pass; |
| 7652 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7653 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7654 | mem_alloc.pNext = NULL; |
| 7655 | mem_alloc.allocationSize = 0; |
| 7656 | mem_alloc.memoryTypeIndex = 0; |
| 7657 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7658 | mem_alloc.allocationSize = mem_reqs.size; |
| 7659 | pass = |
| 7660 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7661 | ASSERT_TRUE(pass); |
| 7662 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7663 | ASSERT_VK_SUCCESS(err); |
| 7664 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7665 | ASSERT_VK_SUCCESS(err); |
| 7666 | // Now create view for image |
| 7667 | VkImageViewCreateInfo image_view_ci = {}; |
| 7668 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7669 | image_view_ci.image = image; |
| 7670 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7671 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7672 | image_view_ci.subresourceRange.layerCount = 1; |
| 7673 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7674 | image_view_ci.subresourceRange.levelCount = 1; |
| 7675 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7676 | VkImageView image_view; |
| 7677 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7678 | &image_view); |
| 7679 | ASSERT_VK_SUCCESS(err); |
| 7680 | |
| 7681 | VkDescriptorBufferInfo buff_info = {}; |
| 7682 | buff_info.buffer = buffer; |
| 7683 | VkDescriptorImageInfo img_info = {}; |
| 7684 | img_info.imageView = image_view; |
| 7685 | VkWriteDescriptorSet descriptor_write = {}; |
| 7686 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7687 | descriptor_write.dstBinding = 0; |
| 7688 | descriptor_write.descriptorCount = 1; |
| 7689 | descriptor_write.pTexelBufferView = &buff_view; |
| 7690 | descriptor_write.pBufferInfo = &buff_info; |
| 7691 | descriptor_write.pImageInfo = &img_info; |
| 7692 | |
| 7693 | // These error messages align with VkDescriptorType struct |
| 7694 | const char *error_msgs[] = { |
| 7695 | "", // placeholder, no error for SAMPLER descriptor |
| 7696 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7697 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7698 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7699 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7700 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_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_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7704 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7705 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7706 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7707 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7708 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7709 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7710 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7711 | error_msgs[i]); |
| 7712 | |
| 7713 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7714 | NULL); |
| 7715 | |
| 7716 | m_errorMonitor->VerifyFound(); |
| 7717 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7718 | } |
| 7719 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7720 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7721 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7722 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7723 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7724 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7725 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7726 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7727 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7728 | } |
| 7729 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7730 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7731 | // 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] | 7732 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7733 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7734 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7735 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7736 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7737 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7738 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7739 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7740 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7741 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7742 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7743 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7744 | |
| 7745 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7746 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7747 | ds_pool_ci.pNext = NULL; |
| 7748 | ds_pool_ci.maxSets = 1; |
| 7749 | ds_pool_ci.poolSizeCount = 1; |
| 7750 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7751 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7752 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7753 | err = |
| 7754 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7755 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7756 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7757 | dsl_binding.binding = 0; |
| 7758 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7759 | dsl_binding.descriptorCount = 1; |
| 7760 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7761 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7762 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7763 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7764 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7765 | ds_layout_ci.pNext = NULL; |
| 7766 | ds_layout_ci.bindingCount = 1; |
| 7767 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7768 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7769 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7770 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7771 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7772 | ASSERT_VK_SUCCESS(err); |
| 7773 | |
| 7774 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7775 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7776 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7777 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7778 | alloc_info.descriptorPool = ds_pool; |
| 7779 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7780 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7781 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7782 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7783 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7784 | VkSamplerCreateInfo sampler_ci = {}; |
| 7785 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7786 | sampler_ci.pNext = NULL; |
| 7787 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7788 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7789 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7790 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7791 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7792 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7793 | sampler_ci.mipLodBias = 1.0; |
| 7794 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7795 | sampler_ci.maxAnisotropy = 1; |
| 7796 | sampler_ci.compareEnable = VK_FALSE; |
| 7797 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7798 | sampler_ci.minLod = 1.0; |
| 7799 | sampler_ci.maxLod = 1.0; |
| 7800 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7801 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7802 | VkSampler sampler; |
| 7803 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7804 | ASSERT_VK_SUCCESS(err); |
| 7805 | |
| 7806 | VkDescriptorImageInfo info = {}; |
| 7807 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7808 | |
| 7809 | VkWriteDescriptorSet descriptor_write; |
| 7810 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7811 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7812 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7813 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7814 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7815 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7816 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7817 | |
| 7818 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7819 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7820 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7821 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7822 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7823 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7824 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7825 | } |
| 7826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7827 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7828 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7829 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7830 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7831 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7832 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7833 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7834 | "starting at binding offset of 0 combined with update array element " |
| 7835 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7836 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7837 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7838 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7839 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7840 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7841 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7842 | |
| 7843 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7844 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7845 | ds_pool_ci.pNext = NULL; |
| 7846 | ds_pool_ci.maxSets = 1; |
| 7847 | ds_pool_ci.poolSizeCount = 1; |
| 7848 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7849 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7850 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7851 | err = |
| 7852 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7853 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7854 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7855 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7856 | dsl_binding.binding = 0; |
| 7857 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7858 | dsl_binding.descriptorCount = 1; |
| 7859 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7860 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7861 | |
| 7862 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7863 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7864 | ds_layout_ci.pNext = NULL; |
| 7865 | ds_layout_ci.bindingCount = 1; |
| 7866 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7867 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7868 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7869 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7870 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7871 | ASSERT_VK_SUCCESS(err); |
| 7872 | |
| 7873 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7874 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7875 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7876 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7877 | alloc_info.descriptorPool = ds_pool; |
| 7878 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7879 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7880 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7881 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7882 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7883 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7884 | VkDescriptorBufferInfo buff_info = {}; |
| 7885 | buff_info.buffer = |
| 7886 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7887 | buff_info.offset = 0; |
| 7888 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7889 | |
| 7890 | VkWriteDescriptorSet descriptor_write; |
| 7891 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7892 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7893 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7894 | descriptor_write.dstArrayElement = |
| 7895 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7896 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7897 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7898 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7899 | |
| 7900 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7901 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7902 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7903 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7904 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7905 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7906 | } |
| 7907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7908 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7909 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7910 | // index 2 |
| 7911 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7912 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7913 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7914 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7915 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7916 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7917 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7918 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7919 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7920 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7921 | |
| 7922 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7923 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7924 | ds_pool_ci.pNext = NULL; |
| 7925 | ds_pool_ci.maxSets = 1; |
| 7926 | ds_pool_ci.poolSizeCount = 1; |
| 7927 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7928 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7929 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7930 | err = |
| 7931 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7932 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7933 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7934 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7935 | dsl_binding.binding = 0; |
| 7936 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7937 | dsl_binding.descriptorCount = 1; |
| 7938 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7939 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7940 | |
| 7941 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7942 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7943 | ds_layout_ci.pNext = NULL; |
| 7944 | ds_layout_ci.bindingCount = 1; |
| 7945 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7946 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7947 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7948 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7949 | ASSERT_VK_SUCCESS(err); |
| 7950 | |
| 7951 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7952 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7953 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7954 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7955 | alloc_info.descriptorPool = ds_pool; |
| 7956 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7957 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7958 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7959 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7960 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7961 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7962 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7963 | sampler_ci.pNext = NULL; |
| 7964 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7965 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7966 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7967 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7968 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7969 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7970 | sampler_ci.mipLodBias = 1.0; |
| 7971 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7972 | sampler_ci.maxAnisotropy = 1; |
| 7973 | sampler_ci.compareEnable = VK_FALSE; |
| 7974 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7975 | sampler_ci.minLod = 1.0; |
| 7976 | sampler_ci.maxLod = 1.0; |
| 7977 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7978 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7979 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7980 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7981 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7982 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7983 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7984 | VkDescriptorImageInfo info = {}; |
| 7985 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7986 | |
| 7987 | VkWriteDescriptorSet descriptor_write; |
| 7988 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7989 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7990 | descriptor_write.dstSet = descriptorSet; |
| 7991 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7992 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7993 | // 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] | 7994 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7995 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7996 | |
| 7997 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7998 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7999 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8000 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8001 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8002 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8003 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8004 | } |
| 8005 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8006 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 8007 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 8008 | // types |
| 8009 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8010 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8011 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 8012 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8013 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8014 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8015 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8016 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8018 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8019 | |
| 8020 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8021 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8022 | ds_pool_ci.pNext = NULL; |
| 8023 | ds_pool_ci.maxSets = 1; |
| 8024 | ds_pool_ci.poolSizeCount = 1; |
| 8025 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8026 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8027 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8028 | err = |
| 8029 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8030 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8031 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8032 | dsl_binding.binding = 0; |
| 8033 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8034 | dsl_binding.descriptorCount = 1; |
| 8035 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8036 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8037 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8038 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8039 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8040 | ds_layout_ci.pNext = NULL; |
| 8041 | ds_layout_ci.bindingCount = 1; |
| 8042 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8043 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8044 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8045 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8046 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8047 | ASSERT_VK_SUCCESS(err); |
| 8048 | |
| 8049 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8050 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8051 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8052 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8053 | alloc_info.descriptorPool = ds_pool; |
| 8054 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8055 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8056 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8057 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8058 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8059 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8060 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8061 | sampler_ci.pNext = NULL; |
| 8062 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8063 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8064 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8065 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8066 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8067 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8068 | sampler_ci.mipLodBias = 1.0; |
| 8069 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8070 | sampler_ci.maxAnisotropy = 1; |
| 8071 | sampler_ci.compareEnable = VK_FALSE; |
| 8072 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8073 | sampler_ci.minLod = 1.0; |
| 8074 | sampler_ci.maxLod = 1.0; |
| 8075 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8076 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8077 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8078 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8079 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8080 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8081 | VkDescriptorImageInfo info = {}; |
| 8082 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8083 | |
| 8084 | VkWriteDescriptorSet descriptor_write; |
| 8085 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8086 | descriptor_write.sType = |
| 8087 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8088 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8089 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8090 | // 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] | 8091 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8092 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8093 | |
| 8094 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8096 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8098 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8099 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8100 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8101 | } |
| 8102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8103 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8104 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8105 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8107 | m_errorMonitor->SetDesiredFailureMsg( |
| 8108 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8109 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8110 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8111 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8112 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 8113 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8114 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8115 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8116 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8117 | |
| 8118 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8119 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8120 | ds_pool_ci.pNext = NULL; |
| 8121 | ds_pool_ci.maxSets = 1; |
| 8122 | ds_pool_ci.poolSizeCount = 1; |
| 8123 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8124 | |
| 8125 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8126 | err = |
| 8127 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8128 | ASSERT_VK_SUCCESS(err); |
| 8129 | |
| 8130 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8131 | dsl_binding.binding = 0; |
| 8132 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8133 | dsl_binding.descriptorCount = 1; |
| 8134 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8135 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8136 | |
| 8137 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8138 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8139 | ds_layout_ci.pNext = NULL; |
| 8140 | ds_layout_ci.bindingCount = 1; |
| 8141 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8142 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8143 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8144 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8145 | ASSERT_VK_SUCCESS(err); |
| 8146 | |
| 8147 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8148 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8149 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8150 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8151 | alloc_info.descriptorPool = ds_pool; |
| 8152 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8153 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8154 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8155 | ASSERT_VK_SUCCESS(err); |
| 8156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8157 | VkSampler sampler = |
| 8158 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8159 | |
| 8160 | VkDescriptorImageInfo descriptor_info; |
| 8161 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8162 | descriptor_info.sampler = sampler; |
| 8163 | |
| 8164 | VkWriteDescriptorSet descriptor_write; |
| 8165 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8166 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8167 | descriptor_write.dstSet = descriptorSet; |
| 8168 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8169 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8170 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8171 | descriptor_write.pImageInfo = &descriptor_info; |
| 8172 | |
| 8173 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8174 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8175 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8176 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8177 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8178 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8179 | } |
| 8180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8181 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 8182 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 8183 | // imageView |
| 8184 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8185 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8186 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8187 | "Attempted write update to combined " |
| 8188 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 8189 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8190 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8191 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8192 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8193 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8194 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8195 | |
| 8196 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8197 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8198 | ds_pool_ci.pNext = NULL; |
| 8199 | ds_pool_ci.maxSets = 1; |
| 8200 | ds_pool_ci.poolSizeCount = 1; |
| 8201 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8202 | |
| 8203 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8204 | err = |
| 8205 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8206 | ASSERT_VK_SUCCESS(err); |
| 8207 | |
| 8208 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8209 | dsl_binding.binding = 0; |
| 8210 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8211 | dsl_binding.descriptorCount = 1; |
| 8212 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8213 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8214 | |
| 8215 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8216 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8217 | ds_layout_ci.pNext = NULL; |
| 8218 | ds_layout_ci.bindingCount = 1; |
| 8219 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8220 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8221 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8222 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8223 | ASSERT_VK_SUCCESS(err); |
| 8224 | |
| 8225 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8226 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8227 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8228 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8229 | alloc_info.descriptorPool = ds_pool; |
| 8230 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8231 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8232 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8233 | ASSERT_VK_SUCCESS(err); |
| 8234 | |
| 8235 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8236 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8237 | sampler_ci.pNext = NULL; |
| 8238 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8239 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8240 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8241 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8242 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8243 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8244 | sampler_ci.mipLodBias = 1.0; |
| 8245 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8246 | sampler_ci.maxAnisotropy = 1; |
| 8247 | sampler_ci.compareEnable = VK_FALSE; |
| 8248 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8249 | sampler_ci.minLod = 1.0; |
| 8250 | sampler_ci.maxLod = 1.0; |
| 8251 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8252 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8253 | |
| 8254 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8255 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8256 | ASSERT_VK_SUCCESS(err); |
| 8257 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8258 | VkImageView view = |
| 8259 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8260 | |
| 8261 | VkDescriptorImageInfo descriptor_info; |
| 8262 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 8263 | descriptor_info.sampler = sampler; |
| 8264 | descriptor_info.imageView = view; |
| 8265 | |
| 8266 | VkWriteDescriptorSet descriptor_write; |
| 8267 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 8268 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8269 | descriptor_write.dstSet = descriptorSet; |
| 8270 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8271 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8272 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 8273 | descriptor_write.pImageInfo = &descriptor_info; |
| 8274 | |
| 8275 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8276 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8277 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8278 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8279 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8280 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8281 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8282 | } |
| 8283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8284 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 8285 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 8286 | // into the other |
| 8287 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8288 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8289 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8290 | " binding #1 with type " |
| 8291 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 8292 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8293 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8294 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8295 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8296 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8297 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8298 | ds_type_count[0].descriptorCount = 1; |
| 8299 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8300 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8301 | |
| 8302 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8303 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8304 | ds_pool_ci.pNext = NULL; |
| 8305 | ds_pool_ci.maxSets = 1; |
| 8306 | ds_pool_ci.poolSizeCount = 2; |
| 8307 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8308 | |
| 8309 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8310 | err = |
| 8311 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8312 | ASSERT_VK_SUCCESS(err); |
| 8313 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8314 | dsl_binding[0].binding = 0; |
| 8315 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8316 | dsl_binding[0].descriptorCount = 1; |
| 8317 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 8318 | dsl_binding[0].pImmutableSamplers = NULL; |
| 8319 | dsl_binding[1].binding = 1; |
| 8320 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8321 | dsl_binding[1].descriptorCount = 1; |
| 8322 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 8323 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8324 | |
| 8325 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8326 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8327 | ds_layout_ci.pNext = NULL; |
| 8328 | ds_layout_ci.bindingCount = 2; |
| 8329 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8330 | |
| 8331 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8332 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8333 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8334 | ASSERT_VK_SUCCESS(err); |
| 8335 | |
| 8336 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8337 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8338 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8339 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8340 | alloc_info.descriptorPool = ds_pool; |
| 8341 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8342 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8343 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8344 | ASSERT_VK_SUCCESS(err); |
| 8345 | |
| 8346 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8347 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 8348 | sampler_ci.pNext = NULL; |
| 8349 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 8350 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 8351 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 8352 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8353 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8354 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 8355 | sampler_ci.mipLodBias = 1.0; |
| 8356 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 8357 | sampler_ci.maxAnisotropy = 1; |
| 8358 | sampler_ci.compareEnable = VK_FALSE; |
| 8359 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 8360 | sampler_ci.minLod = 1.0; |
| 8361 | sampler_ci.maxLod = 1.0; |
| 8362 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 8363 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8364 | |
| 8365 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8366 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8367 | ASSERT_VK_SUCCESS(err); |
| 8368 | |
| 8369 | VkDescriptorImageInfo info = {}; |
| 8370 | info.sampler = sampler; |
| 8371 | |
| 8372 | VkWriteDescriptorSet descriptor_write; |
| 8373 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 8374 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8375 | descriptor_write.dstSet = descriptorSet; |
| 8376 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8377 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8378 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 8379 | descriptor_write.pImageInfo = &info; |
| 8380 | // This write update should succeed |
| 8381 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 8382 | // Now perform a copy update that fails due to type mismatch |
| 8383 | VkCopyDescriptorSet copy_ds_update; |
| 8384 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8385 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8386 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8387 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8388 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8389 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8390 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8391 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8392 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8393 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8394 | // 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] | 8395 | m_errorMonitor->SetDesiredFailureMsg( |
| 8396 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8397 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8398 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8399 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8400 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8401 | copy_ds_update.srcBinding = |
| 8402 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8403 | copy_ds_update.dstSet = descriptorSet; |
| 8404 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8405 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8406 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8407 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8408 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8409 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8410 | // 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] | 8411 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8412 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 8413 | "update array offset of 0 and update of " |
| 8414 | "5 descriptors oversteps total number " |
| 8415 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8416 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8417 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 8418 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 8419 | copy_ds_update.srcSet = descriptorSet; |
| 8420 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8421 | copy_ds_update.dstSet = descriptorSet; |
| 8422 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8423 | copy_ds_update.descriptorCount = |
| 8424 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8425 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 8426 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8427 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8428 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8429 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 8430 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8431 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8432 | } |
| 8433 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8434 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 8435 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 8436 | // sampleCount |
| 8437 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8438 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8439 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8440 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8441 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8442 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8443 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8444 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8445 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8446 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8447 | |
| 8448 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8449 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8450 | ds_pool_ci.pNext = NULL; |
| 8451 | ds_pool_ci.maxSets = 1; |
| 8452 | ds_pool_ci.poolSizeCount = 1; |
| 8453 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8454 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8455 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8456 | err = |
| 8457 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8458 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8459 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8460 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8461 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8462 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8463 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8464 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8465 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8466 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8467 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8468 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8469 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8470 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8471 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8472 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8473 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8474 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8475 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8476 | ASSERT_VK_SUCCESS(err); |
| 8477 | |
| 8478 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8479 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8480 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8481 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8482 | alloc_info.descriptorPool = ds_pool; |
| 8483 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8484 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8485 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8486 | ASSERT_VK_SUCCESS(err); |
| 8487 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8488 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8489 | pipe_ms_state_ci.sType = |
| 8490 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8491 | pipe_ms_state_ci.pNext = NULL; |
| 8492 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8493 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8494 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8495 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8496 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8497 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8498 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8499 | pipeline_layout_ci.pNext = NULL; |
| 8500 | pipeline_layout_ci.setLayoutCount = 1; |
| 8501 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8502 | |
| 8503 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8504 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8505 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8506 | ASSERT_VK_SUCCESS(err); |
| 8507 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8508 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8509 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8510 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8511 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8512 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8513 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8514 | VkPipelineObj pipe(m_device); |
| 8515 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8516 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8517 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8518 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8519 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8520 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8521 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8522 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8523 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8524 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8525 | // Render triangle (the error should trigger on the attempt to draw). |
| 8526 | Draw(3, 1, 0, 0); |
| 8527 | |
| 8528 | // Finalize recording of the command buffer |
| 8529 | EndCommandBuffer(); |
| 8530 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8531 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8532 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8533 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8534 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8535 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8536 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8537 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8538 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8539 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8540 | // number of color attachments. In this case, we don't add any color |
| 8541 | // blend attachments even though we have a color attachment. |
| 8542 | VkResult err; |
| 8543 | |
| 8544 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8545 | "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] | 8546 | |
| 8547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8548 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8549 | VkDescriptorPoolSize ds_type_count = {}; |
| 8550 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8551 | ds_type_count.descriptorCount = 1; |
| 8552 | |
| 8553 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8554 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8555 | ds_pool_ci.pNext = NULL; |
| 8556 | ds_pool_ci.maxSets = 1; |
| 8557 | ds_pool_ci.poolSizeCount = 1; |
| 8558 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8559 | |
| 8560 | VkDescriptorPool ds_pool; |
| 8561 | err = |
| 8562 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8563 | ASSERT_VK_SUCCESS(err); |
| 8564 | |
| 8565 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8566 | dsl_binding.binding = 0; |
| 8567 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8568 | dsl_binding.descriptorCount = 1; |
| 8569 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8570 | dsl_binding.pImmutableSamplers = NULL; |
| 8571 | |
| 8572 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8573 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8574 | ds_layout_ci.pNext = NULL; |
| 8575 | ds_layout_ci.bindingCount = 1; |
| 8576 | ds_layout_ci.pBindings = &dsl_binding; |
| 8577 | |
| 8578 | VkDescriptorSetLayout ds_layout; |
| 8579 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8580 | &ds_layout); |
| 8581 | ASSERT_VK_SUCCESS(err); |
| 8582 | |
| 8583 | VkDescriptorSet descriptorSet; |
| 8584 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8585 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8586 | alloc_info.descriptorSetCount = 1; |
| 8587 | alloc_info.descriptorPool = ds_pool; |
| 8588 | alloc_info.pSetLayouts = &ds_layout; |
| 8589 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8590 | &descriptorSet); |
| 8591 | ASSERT_VK_SUCCESS(err); |
| 8592 | |
| 8593 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8594 | pipe_ms_state_ci.sType = |
| 8595 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8596 | pipe_ms_state_ci.pNext = NULL; |
| 8597 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8598 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8599 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8600 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8601 | |
| 8602 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8603 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8604 | pipeline_layout_ci.pNext = NULL; |
| 8605 | pipeline_layout_ci.setLayoutCount = 1; |
| 8606 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8607 | |
| 8608 | VkPipelineLayout pipeline_layout; |
| 8609 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8610 | &pipeline_layout); |
| 8611 | ASSERT_VK_SUCCESS(err); |
| 8612 | |
| 8613 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8614 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8615 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8616 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8617 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8618 | // but add it to be able to run on more devices |
| 8619 | VkPipelineObj pipe(m_device); |
| 8620 | pipe.AddShader(&vs); |
| 8621 | pipe.AddShader(&fs); |
| 8622 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8623 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8624 | |
| 8625 | BeginCommandBuffer(); |
| 8626 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8627 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8628 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8629 | // Render triangle (the error should trigger on the attempt to draw). |
| 8630 | Draw(3, 1, 0, 0); |
| 8631 | |
| 8632 | // Finalize recording of the command buffer |
| 8633 | EndCommandBuffer(); |
| 8634 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8635 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8636 | |
| 8637 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8638 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8639 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8640 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8641 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 8642 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 8643 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " |
| 8644 | "structure passed to vkCmdClearAttachments"); |
| 8645 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8646 | "vkCmdClearAttachments() attachment index 1 not found in attachment " |
| 8647 | "reference array of active subpass 0"); |
| 8648 | |
| 8649 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); |
| 8650 | m_errorMonitor->VerifyFound(); |
| 8651 | } |
| 8652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8653 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8654 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8655 | // to issuing a Draw |
| 8656 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8657 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8658 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8659 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8660 | "vkCmdClearAttachments() issued on CB object "); |
| 8661 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8662 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8663 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8664 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8665 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8666 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8667 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8668 | |
| 8669 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8670 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8671 | ds_pool_ci.pNext = NULL; |
| 8672 | ds_pool_ci.maxSets = 1; |
| 8673 | ds_pool_ci.poolSizeCount = 1; |
| 8674 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8675 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8676 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8677 | err = |
| 8678 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8679 | ASSERT_VK_SUCCESS(err); |
| 8680 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8681 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8682 | dsl_binding.binding = 0; |
| 8683 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8684 | dsl_binding.descriptorCount = 1; |
| 8685 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8686 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8687 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8688 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8689 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8690 | ds_layout_ci.pNext = NULL; |
| 8691 | ds_layout_ci.bindingCount = 1; |
| 8692 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8693 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8694 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8695 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8696 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8697 | ASSERT_VK_SUCCESS(err); |
| 8698 | |
| 8699 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8700 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8701 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8702 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8703 | alloc_info.descriptorPool = ds_pool; |
| 8704 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8705 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8706 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8707 | ASSERT_VK_SUCCESS(err); |
| 8708 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8709 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8710 | pipe_ms_state_ci.sType = |
| 8711 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8712 | pipe_ms_state_ci.pNext = NULL; |
| 8713 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8714 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8715 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8716 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8717 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8718 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8719 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8720 | pipeline_layout_ci.pNext = NULL; |
| 8721 | pipeline_layout_ci.setLayoutCount = 1; |
| 8722 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8723 | |
| 8724 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8725 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8726 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8727 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8729 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8730 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8731 | // 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] | 8732 | // on more devices |
| 8733 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8734 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8735 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8736 | VkPipelineObj pipe(m_device); |
| 8737 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8738 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8739 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8740 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8741 | |
| 8742 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8744 | // Main thing we care about for this test is that the VkImage obj we're |
| 8745 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8746 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8747 | VkClearAttachment color_attachment; |
| 8748 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8749 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8750 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8751 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8752 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8753 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8754 | VkClearRect clear_rect = { |
| 8755 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8756 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8757 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8758 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8759 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8760 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8761 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8762 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8763 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8764 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8765 | } |
| 8766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8767 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8768 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8769 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8770 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8771 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8772 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8773 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8774 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8775 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8776 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8777 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8778 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8779 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8780 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8781 | |
| 8782 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8783 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8784 | ds_pool_ci.pNext = NULL; |
| 8785 | ds_pool_ci.maxSets = 1; |
| 8786 | ds_pool_ci.poolSizeCount = 1; |
| 8787 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8788 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8789 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8790 | err = |
| 8791 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8792 | ASSERT_VK_SUCCESS(err); |
| 8793 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8794 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8795 | dsl_binding.binding = 0; |
| 8796 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8797 | dsl_binding.descriptorCount = 1; |
| 8798 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8799 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8800 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8801 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8802 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8803 | ds_layout_ci.pNext = NULL; |
| 8804 | ds_layout_ci.bindingCount = 1; |
| 8805 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8806 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8807 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8808 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8809 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8810 | ASSERT_VK_SUCCESS(err); |
| 8811 | |
| 8812 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8813 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8814 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8815 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8816 | alloc_info.descriptorPool = ds_pool; |
| 8817 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8818 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8819 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8820 | ASSERT_VK_SUCCESS(err); |
| 8821 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8822 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8823 | pipe_ms_state_ci.sType = |
| 8824 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8825 | pipe_ms_state_ci.pNext = NULL; |
| 8826 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8827 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8828 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8829 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8830 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8831 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8832 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8833 | pipeline_layout_ci.pNext = NULL; |
| 8834 | pipeline_layout_ci.setLayoutCount = 1; |
| 8835 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8836 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8838 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8839 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8840 | ASSERT_VK_SUCCESS(err); |
| 8841 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8842 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8843 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8844 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8845 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8846 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8847 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8848 | VkPipelineObj pipe(m_device); |
| 8849 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8850 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8851 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8852 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8853 | pipe.SetViewport(m_viewports); |
| 8854 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8855 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8856 | |
| 8857 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8858 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8859 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8860 | // Don't care about actual data, just need to get to draw to flag error |
| 8861 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8862 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8863 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8864 | 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] | 8865 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8866 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8867 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8868 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8869 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8870 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8871 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8872 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8873 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8874 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8875 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8876 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8877 | "images in the wrong layout when they're copied or transitioned."); |
| 8878 | // 3 in ValidateCmdBufImageLayouts |
| 8879 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8880 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8881 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8882 | m_errorMonitor->SetDesiredFailureMsg( |
| 8883 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8884 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8885 | |
| 8886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8887 | // Create src & dst images to use for copy operations |
| 8888 | VkImage src_image; |
| 8889 | VkImage dst_image; |
| 8890 | |
| 8891 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8892 | const int32_t tex_width = 32; |
| 8893 | const int32_t tex_height = 32; |
| 8894 | |
| 8895 | VkImageCreateInfo image_create_info = {}; |
| 8896 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8897 | image_create_info.pNext = NULL; |
| 8898 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8899 | image_create_info.format = tex_format; |
| 8900 | image_create_info.extent.width = tex_width; |
| 8901 | image_create_info.extent.height = tex_height; |
| 8902 | image_create_info.extent.depth = 1; |
| 8903 | image_create_info.mipLevels = 1; |
| 8904 | image_create_info.arrayLayers = 4; |
| 8905 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8906 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8907 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8908 | image_create_info.flags = 0; |
| 8909 | |
| 8910 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8911 | ASSERT_VK_SUCCESS(err); |
| 8912 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8913 | ASSERT_VK_SUCCESS(err); |
| 8914 | |
| 8915 | BeginCommandBuffer(); |
| 8916 | VkImageCopy copyRegion; |
| 8917 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8918 | copyRegion.srcSubresource.mipLevel = 0; |
| 8919 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8920 | copyRegion.srcSubresource.layerCount = 1; |
| 8921 | copyRegion.srcOffset.x = 0; |
| 8922 | copyRegion.srcOffset.y = 0; |
| 8923 | copyRegion.srcOffset.z = 0; |
| 8924 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8925 | copyRegion.dstSubresource.mipLevel = 0; |
| 8926 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8927 | copyRegion.dstSubresource.layerCount = 1; |
| 8928 | copyRegion.dstOffset.x = 0; |
| 8929 | copyRegion.dstOffset.y = 0; |
| 8930 | copyRegion.dstOffset.z = 0; |
| 8931 | copyRegion.extent.width = 1; |
| 8932 | copyRegion.extent.height = 1; |
| 8933 | copyRegion.extent.depth = 1; |
| 8934 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8935 | m_errorMonitor->VerifyFound(); |
| 8936 | // Now cause error due to src image layout changing |
| 8937 | m_errorMonitor->SetDesiredFailureMsg( |
| 8938 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8939 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8940 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8941 | m_errorMonitor->VerifyFound(); |
| 8942 | // Final src error is due to bad layout type |
| 8943 | m_errorMonitor->SetDesiredFailureMsg( |
| 8944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8945 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8946 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8947 | m_errorMonitor->VerifyFound(); |
| 8948 | // Now verify same checks for dst |
| 8949 | m_errorMonitor->SetDesiredFailureMsg( |
| 8950 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8951 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8952 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8953 | m_errorMonitor->VerifyFound(); |
| 8954 | // Now cause error due to src image layout changing |
| 8955 | m_errorMonitor->SetDesiredFailureMsg( |
| 8956 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8957 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8958 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8959 | m_errorMonitor->VerifyFound(); |
| 8960 | m_errorMonitor->SetDesiredFailureMsg( |
| 8961 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8962 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8963 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8964 | m_errorMonitor->VerifyFound(); |
| 8965 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8966 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8967 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8968 | image_barrier[0].image = src_image; |
| 8969 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8970 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8971 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8972 | m_errorMonitor->SetDesiredFailureMsg( |
| 8973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8974 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8975 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8976 | m_errorMonitor->VerifyFound(); |
| 8977 | |
| 8978 | // Finally some layout errors at RenderPass create time |
| 8979 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8980 | VkAttachmentReference attach = {}; |
| 8981 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8982 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8983 | VkSubpassDescription subpass = {}; |
| 8984 | subpass.inputAttachmentCount = 1; |
| 8985 | subpass.pInputAttachments = &attach; |
| 8986 | VkRenderPassCreateInfo rpci = {}; |
| 8987 | rpci.subpassCount = 1; |
| 8988 | rpci.pSubpasses = &subpass; |
| 8989 | rpci.attachmentCount = 1; |
| 8990 | VkAttachmentDescription attach_desc = {}; |
| 8991 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8992 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8993 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8994 | VkRenderPass rp; |
| 8995 | m_errorMonitor->SetDesiredFailureMsg( |
| 8996 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8997 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8998 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8999 | m_errorMonitor->VerifyFound(); |
| 9000 | // error w/ non-general layout |
| 9001 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9002 | |
| 9003 | m_errorMonitor->SetDesiredFailureMsg( |
| 9004 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9005 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 9006 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9007 | m_errorMonitor->VerifyFound(); |
| 9008 | subpass.inputAttachmentCount = 0; |
| 9009 | subpass.colorAttachmentCount = 1; |
| 9010 | subpass.pColorAttachments = &attach; |
| 9011 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9012 | // perf warning for GENERAL layout on color attachment |
| 9013 | m_errorMonitor->SetDesiredFailureMsg( |
| 9014 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9015 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 9016 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9017 | m_errorMonitor->VerifyFound(); |
| 9018 | // error w/ non-color opt or GENERAL layout for color attachment |
| 9019 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9020 | m_errorMonitor->SetDesiredFailureMsg( |
| 9021 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9022 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9023 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9024 | m_errorMonitor->VerifyFound(); |
| 9025 | subpass.colorAttachmentCount = 0; |
| 9026 | subpass.pDepthStencilAttachment = &attach; |
| 9027 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9028 | // perf warning for GENERAL layout on DS attachment |
| 9029 | m_errorMonitor->SetDesiredFailureMsg( |
| 9030 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 9031 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 9032 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9033 | m_errorMonitor->VerifyFound(); |
| 9034 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 9035 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 9036 | m_errorMonitor->SetDesiredFailureMsg( |
| 9037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9038 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 9039 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9040 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 9041 | // For this error we need a valid renderpass so create default one |
| 9042 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9043 | attach.attachment = 0; |
| 9044 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9045 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9046 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 9047 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 9048 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 9049 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 9050 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 9051 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 9052 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9053 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9054 | " with invalid first layout " |
| 9055 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 9056 | "ONLY_OPTIMAL"); |
| 9057 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 9058 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 9059 | |
| 9060 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 9061 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 9062 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9063 | #endif // DRAW_STATE_TESTS |
| 9064 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 9065 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9066 | #if GTEST_IS_THREADSAFE |
| 9067 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9068 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9069 | VkEvent event; |
| 9070 | bool bailout; |
| 9071 | }; |
| 9072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9073 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 9074 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9076 | for (int i = 0; i < 10000; i++) { |
| 9077 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 9078 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9079 | if (data->bailout) { |
| 9080 | break; |
| 9081 | } |
| 9082 | } |
| 9083 | return NULL; |
| 9084 | } |
| 9085 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9086 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9087 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9089 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9090 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9091 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9092 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9093 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 9094 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9095 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9096 | // Calls AllocateCommandBuffers |
| 9097 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9098 | |
| 9099 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9100 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9101 | |
| 9102 | VkEventCreateInfo event_info; |
| 9103 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9104 | VkResult err; |
| 9105 | |
| 9106 | memset(&event_info, 0, sizeof(event_info)); |
| 9107 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 9108 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9109 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9110 | ASSERT_VK_SUCCESS(err); |
| 9111 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9112 | err = vkResetEvent(device(), event); |
| 9113 | ASSERT_VK_SUCCESS(err); |
| 9114 | |
| 9115 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9116 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9117 | data.event = event; |
| 9118 | data.bailout = false; |
| 9119 | m_errorMonitor->SetBailout(&data.bailout); |
| 9120 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9121 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9122 | // Add many entries to command buffer from this thread at the same time. |
| 9123 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9124 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9125 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9126 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9127 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 9128 | m_errorMonitor->SetBailout(NULL); |
| 9129 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9130 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9131 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9132 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9133 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9134 | #endif // GTEST_IS_THREADSAFE |
| 9135 | #endif // THREADING_TESTS |
| 9136 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9137 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9138 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9139 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9140 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9141 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9142 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9143 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9144 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9145 | VkShaderModule module; |
| 9146 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9147 | struct icd_spv_header spv; |
| 9148 | |
| 9149 | spv.magic = ICD_SPV_MAGIC; |
| 9150 | spv.version = ICD_SPV_VERSION; |
| 9151 | spv.gen_magic = 0; |
| 9152 | |
| 9153 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9154 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9155 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9156 | moduleCreateInfo.codeSize = 4; |
| 9157 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9158 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9159 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9160 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9161 | } |
| 9162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9163 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9164 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9165 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9166 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9167 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9168 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9169 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9170 | VkShaderModule module; |
| 9171 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9172 | struct icd_spv_header spv; |
| 9173 | |
| 9174 | spv.magic = ~ICD_SPV_MAGIC; |
| 9175 | spv.version = ICD_SPV_VERSION; |
| 9176 | spv.gen_magic = 0; |
| 9177 | |
| 9178 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9179 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9180 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9181 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9182 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9183 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9184 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9185 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9186 | } |
| 9187 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9188 | #if 0 |
| 9189 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9190 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9191 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9192 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9193 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9194 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9195 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9196 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9197 | VkShaderModule module; |
| 9198 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 9199 | struct icd_spv_header spv; |
| 9200 | |
| 9201 | spv.magic = ICD_SPV_MAGIC; |
| 9202 | spv.version = ~ICD_SPV_VERSION; |
| 9203 | spv.gen_magic = 0; |
| 9204 | |
| 9205 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 9206 | moduleCreateInfo.pNext = NULL; |
| 9207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9208 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9209 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 9210 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9211 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9213 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9214 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9215 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9217 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9218 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9219 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9220 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9222 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9223 | |
| 9224 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9225 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9226 | "\n" |
| 9227 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9228 | "out gl_PerVertex {\n" |
| 9229 | " vec4 gl_Position;\n" |
| 9230 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9231 | "void main(){\n" |
| 9232 | " gl_Position = vec4(1);\n" |
| 9233 | " x = 0;\n" |
| 9234 | "}\n"; |
| 9235 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9236 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9237 | "\n" |
| 9238 | "layout(location=0) out vec4 color;\n" |
| 9239 | "void main(){\n" |
| 9240 | " color = vec4(1);\n" |
| 9241 | "}\n"; |
| 9242 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9243 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9244 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9245 | |
| 9246 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9247 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9248 | pipe.AddShader(&vs); |
| 9249 | pipe.AddShader(&fs); |
| 9250 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9251 | VkDescriptorSetObj descriptorSet(m_device); |
| 9252 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9253 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9254 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9255 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9256 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9257 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9258 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9259 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9260 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9261 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9262 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9263 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9264 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9265 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9266 | |
| 9267 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9268 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9269 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9270 | "out gl_PerVertex {\n" |
| 9271 | " vec4 gl_Position;\n" |
| 9272 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9273 | "void main(){\n" |
| 9274 | " gl_Position = vec4(1);\n" |
| 9275 | "}\n"; |
| 9276 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9277 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9278 | "\n" |
| 9279 | "layout(location=0) in float x;\n" |
| 9280 | "layout(location=0) out vec4 color;\n" |
| 9281 | "void main(){\n" |
| 9282 | " color = vec4(x);\n" |
| 9283 | "}\n"; |
| 9284 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9285 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9286 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9287 | |
| 9288 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9289 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9290 | pipe.AddShader(&vs); |
| 9291 | pipe.AddShader(&fs); |
| 9292 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9293 | VkDescriptorSetObj descriptorSet(m_device); |
| 9294 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9295 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9296 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9297 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9298 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9299 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9300 | } |
| 9301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9302 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9303 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9304 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9305 | |
| 9306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9308 | |
| 9309 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9310 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9311 | "\n" |
| 9312 | "out gl_PerVertex {\n" |
| 9313 | " vec4 gl_Position;\n" |
| 9314 | "};\n" |
| 9315 | "void main(){\n" |
| 9316 | " gl_Position = vec4(1);\n" |
| 9317 | "}\n"; |
| 9318 | char const *fsSource = |
| 9319 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9320 | "\n" |
| 9321 | "in block { layout(location=0) float x; } ins;\n" |
| 9322 | "layout(location=0) out vec4 color;\n" |
| 9323 | "void main(){\n" |
| 9324 | " color = vec4(ins.x);\n" |
| 9325 | "}\n"; |
| 9326 | |
| 9327 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9328 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9329 | |
| 9330 | VkPipelineObj pipe(m_device); |
| 9331 | pipe.AddColorAttachment(); |
| 9332 | pipe.AddShader(&vs); |
| 9333 | pipe.AddShader(&fs); |
| 9334 | |
| 9335 | VkDescriptorSetObj descriptorSet(m_device); |
| 9336 | descriptorSet.AppendDummy(); |
| 9337 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9338 | |
| 9339 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9340 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9341 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9342 | } |
| 9343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9344 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9345 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9346 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9347 | "output arr[2] of float32' vs 'ptr to " |
| 9348 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9349 | |
| 9350 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9352 | |
| 9353 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9354 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9355 | "\n" |
| 9356 | "layout(location=0) out float x[2];\n" |
| 9357 | "out gl_PerVertex {\n" |
| 9358 | " vec4 gl_Position;\n" |
| 9359 | "};\n" |
| 9360 | "void main(){\n" |
| 9361 | " x[0] = 0; x[1] = 0;\n" |
| 9362 | " gl_Position = vec4(1);\n" |
| 9363 | "}\n"; |
| 9364 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9365 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9366 | "\n" |
| 9367 | "layout(location=0) in float x[3];\n" |
| 9368 | "layout(location=0) out vec4 color;\n" |
| 9369 | "void main(){\n" |
| 9370 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 9371 | "}\n"; |
| 9372 | |
| 9373 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9374 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9375 | |
| 9376 | VkPipelineObj pipe(m_device); |
| 9377 | pipe.AddColorAttachment(); |
| 9378 | pipe.AddShader(&vs); |
| 9379 | pipe.AddShader(&fs); |
| 9380 | |
| 9381 | VkDescriptorSetObj descriptorSet(m_device); |
| 9382 | descriptorSet.AppendDummy(); |
| 9383 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9384 | |
| 9385 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9386 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9387 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9388 | } |
| 9389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9390 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9391 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9392 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9393 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9395 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9396 | |
| 9397 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9398 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9399 | "\n" |
| 9400 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9401 | "out gl_PerVertex {\n" |
| 9402 | " vec4 gl_Position;\n" |
| 9403 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9404 | "void main(){\n" |
| 9405 | " x = 0;\n" |
| 9406 | " gl_Position = vec4(1);\n" |
| 9407 | "}\n"; |
| 9408 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9409 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9410 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9411 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9412 | "layout(location=0) out vec4 color;\n" |
| 9413 | "void main(){\n" |
| 9414 | " color = vec4(x);\n" |
| 9415 | "}\n"; |
| 9416 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9417 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9418 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9419 | |
| 9420 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9421 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9422 | pipe.AddShader(&vs); |
| 9423 | pipe.AddShader(&fs); |
| 9424 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9425 | VkDescriptorSetObj descriptorSet(m_device); |
| 9426 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9427 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9428 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9429 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9430 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9431 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9432 | } |
| 9433 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9434 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9435 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9436 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9437 | |
| 9438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9439 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9440 | |
| 9441 | char const *vsSource = |
| 9442 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9443 | "\n" |
| 9444 | "out block { layout(location=0) int x; } outs;\n" |
| 9445 | "out gl_PerVertex {\n" |
| 9446 | " vec4 gl_Position;\n" |
| 9447 | "};\n" |
| 9448 | "void main(){\n" |
| 9449 | " outs.x = 0;\n" |
| 9450 | " gl_Position = vec4(1);\n" |
| 9451 | "}\n"; |
| 9452 | char const *fsSource = |
| 9453 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9454 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9455 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9456 | "layout(location=0) out vec4 color;\n" |
| 9457 | "void main(){\n" |
| 9458 | " color = vec4(ins.x);\n" |
| 9459 | "}\n"; |
| 9460 | |
| 9461 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9462 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9463 | |
| 9464 | VkPipelineObj pipe(m_device); |
| 9465 | pipe.AddColorAttachment(); |
| 9466 | pipe.AddShader(&vs); |
| 9467 | pipe.AddShader(&fs); |
| 9468 | |
| 9469 | VkDescriptorSetObj descriptorSet(m_device); |
| 9470 | descriptorSet.AppendDummy(); |
| 9471 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9472 | |
| 9473 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9474 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9475 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9476 | } |
| 9477 | |
| 9478 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9479 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9480 | "location 0.0 which is not written by vertex shader"); |
| 9481 | |
| 9482 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9483 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9484 | |
| 9485 | char const *vsSource = |
| 9486 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9487 | "\n" |
| 9488 | "out block { layout(location=1) float x; } outs;\n" |
| 9489 | "out gl_PerVertex {\n" |
| 9490 | " vec4 gl_Position;\n" |
| 9491 | "};\n" |
| 9492 | "void main(){\n" |
| 9493 | " outs.x = 0;\n" |
| 9494 | " gl_Position = vec4(1);\n" |
| 9495 | "}\n"; |
| 9496 | char const *fsSource = |
| 9497 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9498 | "\n" |
| 9499 | "in block { layout(location=0) float x; } ins;\n" |
| 9500 | "layout(location=0) out vec4 color;\n" |
| 9501 | "void main(){\n" |
| 9502 | " color = vec4(ins.x);\n" |
| 9503 | "}\n"; |
| 9504 | |
| 9505 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9506 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9507 | |
| 9508 | VkPipelineObj pipe(m_device); |
| 9509 | pipe.AddColorAttachment(); |
| 9510 | pipe.AddShader(&vs); |
| 9511 | pipe.AddShader(&fs); |
| 9512 | |
| 9513 | VkDescriptorSetObj descriptorSet(m_device); |
| 9514 | descriptorSet.AppendDummy(); |
| 9515 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9516 | |
| 9517 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9518 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9519 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9520 | } |
| 9521 | |
| 9522 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9523 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9524 | "location 0.1 which is not written by vertex shader"); |
| 9525 | |
| 9526 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9527 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9528 | |
| 9529 | char const *vsSource = |
| 9530 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9531 | "\n" |
| 9532 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9533 | "out gl_PerVertex {\n" |
| 9534 | " vec4 gl_Position;\n" |
| 9535 | "};\n" |
| 9536 | "void main(){\n" |
| 9537 | " outs.x = 0;\n" |
| 9538 | " gl_Position = vec4(1);\n" |
| 9539 | "}\n"; |
| 9540 | char const *fsSource = |
| 9541 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9542 | "\n" |
| 9543 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9544 | "layout(location=0) out vec4 color;\n" |
| 9545 | "void main(){\n" |
| 9546 | " color = vec4(ins.x);\n" |
| 9547 | "}\n"; |
| 9548 | |
| 9549 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9550 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9551 | |
| 9552 | VkPipelineObj pipe(m_device); |
| 9553 | pipe.AddColorAttachment(); |
| 9554 | pipe.AddShader(&vs); |
| 9555 | pipe.AddShader(&fs); |
| 9556 | |
| 9557 | VkDescriptorSetObj descriptorSet(m_device); |
| 9558 | descriptorSet.AppendDummy(); |
| 9559 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9560 | |
| 9561 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9562 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9563 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9564 | } |
| 9565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9566 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9567 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9568 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9569 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9570 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9571 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9572 | |
| 9573 | VkVertexInputBindingDescription input_binding; |
| 9574 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9575 | |
| 9576 | VkVertexInputAttributeDescription input_attrib; |
| 9577 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9578 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9579 | |
| 9580 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9581 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9582 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9583 | "out gl_PerVertex {\n" |
| 9584 | " vec4 gl_Position;\n" |
| 9585 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9586 | "void main(){\n" |
| 9587 | " gl_Position = vec4(1);\n" |
| 9588 | "}\n"; |
| 9589 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9590 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9591 | "\n" |
| 9592 | "layout(location=0) out vec4 color;\n" |
| 9593 | "void main(){\n" |
| 9594 | " color = vec4(1);\n" |
| 9595 | "}\n"; |
| 9596 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9597 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9598 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9599 | |
| 9600 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9601 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9602 | pipe.AddShader(&vs); |
| 9603 | pipe.AddShader(&fs); |
| 9604 | |
| 9605 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9606 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9607 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9608 | VkDescriptorSetObj descriptorSet(m_device); |
| 9609 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9610 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9611 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9612 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9614 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9615 | } |
| 9616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9617 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9618 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9619 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9620 | |
| 9621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9623 | |
| 9624 | VkVertexInputBindingDescription input_binding; |
| 9625 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9626 | |
| 9627 | VkVertexInputAttributeDescription input_attrib; |
| 9628 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9629 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9630 | |
| 9631 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9632 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9633 | "\n" |
| 9634 | "layout(location=1) in float x;\n" |
| 9635 | "out gl_PerVertex {\n" |
| 9636 | " vec4 gl_Position;\n" |
| 9637 | "};\n" |
| 9638 | "void main(){\n" |
| 9639 | " gl_Position = vec4(x);\n" |
| 9640 | "}\n"; |
| 9641 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9642 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9643 | "\n" |
| 9644 | "layout(location=0) out vec4 color;\n" |
| 9645 | "void main(){\n" |
| 9646 | " color = vec4(1);\n" |
| 9647 | "}\n"; |
| 9648 | |
| 9649 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9650 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9651 | |
| 9652 | VkPipelineObj pipe(m_device); |
| 9653 | pipe.AddColorAttachment(); |
| 9654 | pipe.AddShader(&vs); |
| 9655 | pipe.AddShader(&fs); |
| 9656 | |
| 9657 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9658 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9659 | |
| 9660 | VkDescriptorSetObj descriptorSet(m_device); |
| 9661 | descriptorSet.AppendDummy(); |
| 9662 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9663 | |
| 9664 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9665 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9666 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9667 | } |
| 9668 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9669 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9670 | m_errorMonitor->SetDesiredFailureMsg( |
| 9671 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9672 | "VS consumes input at location 0 but not provided"); |
| 9673 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9674 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9675 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9676 | |
| 9677 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9678 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9679 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9680 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9681 | "out gl_PerVertex {\n" |
| 9682 | " vec4 gl_Position;\n" |
| 9683 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9684 | "void main(){\n" |
| 9685 | " gl_Position = x;\n" |
| 9686 | "}\n"; |
| 9687 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9688 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9689 | "\n" |
| 9690 | "layout(location=0) out vec4 color;\n" |
| 9691 | "void main(){\n" |
| 9692 | " color = vec4(1);\n" |
| 9693 | "}\n"; |
| 9694 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9695 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9696 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9697 | |
| 9698 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9699 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9700 | pipe.AddShader(&vs); |
| 9701 | pipe.AddShader(&fs); |
| 9702 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9703 | VkDescriptorSetObj descriptorSet(m_device); |
| 9704 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9705 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9706 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9707 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9708 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9709 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9710 | } |
| 9711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9712 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9713 | m_errorMonitor->SetDesiredFailureMsg( |
| 9714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9715 | "location 0 does not match VS input type"); |
| 9716 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9719 | |
| 9720 | VkVertexInputBindingDescription input_binding; |
| 9721 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9722 | |
| 9723 | VkVertexInputAttributeDescription input_attrib; |
| 9724 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9725 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9726 | |
| 9727 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9728 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9729 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9730 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9731 | "out gl_PerVertex {\n" |
| 9732 | " vec4 gl_Position;\n" |
| 9733 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9734 | "void main(){\n" |
| 9735 | " gl_Position = vec4(x);\n" |
| 9736 | "}\n"; |
| 9737 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9738 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9739 | "\n" |
| 9740 | "layout(location=0) out vec4 color;\n" |
| 9741 | "void main(){\n" |
| 9742 | " color = vec4(1);\n" |
| 9743 | "}\n"; |
| 9744 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9745 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9746 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9747 | |
| 9748 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9749 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9750 | pipe.AddShader(&vs); |
| 9751 | pipe.AddShader(&fs); |
| 9752 | |
| 9753 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9754 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9755 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9756 | VkDescriptorSetObj descriptorSet(m_device); |
| 9757 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9758 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9759 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9760 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9761 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9762 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9763 | } |
| 9764 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9765 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9766 | m_errorMonitor->SetDesiredFailureMsg( |
| 9767 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9768 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9769 | |
| 9770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9772 | |
| 9773 | char const *vsSource = |
| 9774 | "#version 450\n" |
| 9775 | "\n" |
| 9776 | "out gl_PerVertex {\n" |
| 9777 | " vec4 gl_Position;\n" |
| 9778 | "};\n" |
| 9779 | "void main(){\n" |
| 9780 | " gl_Position = vec4(1);\n" |
| 9781 | "}\n"; |
| 9782 | char const *fsSource = |
| 9783 | "#version 450\n" |
| 9784 | "\n" |
| 9785 | "layout(location=0) out vec4 color;\n" |
| 9786 | "void main(){\n" |
| 9787 | " color = vec4(1);\n" |
| 9788 | "}\n"; |
| 9789 | |
| 9790 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9791 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9792 | |
| 9793 | VkPipelineObj pipe(m_device); |
| 9794 | pipe.AddColorAttachment(); |
| 9795 | pipe.AddShader(&vs); |
| 9796 | pipe.AddShader(&vs); |
| 9797 | pipe.AddShader(&fs); |
| 9798 | |
| 9799 | VkDescriptorSetObj descriptorSet(m_device); |
| 9800 | descriptorSet.AppendDummy(); |
| 9801 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9802 | |
| 9803 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9804 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9805 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9806 | } |
| 9807 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9808 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9809 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9810 | |
| 9811 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9812 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9813 | |
| 9814 | VkVertexInputBindingDescription input_binding; |
| 9815 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9816 | |
| 9817 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9818 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9819 | |
| 9820 | for (int i = 0; i < 2; i++) { |
| 9821 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9822 | input_attribs[i].location = i; |
| 9823 | } |
| 9824 | |
| 9825 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9826 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9827 | "\n" |
| 9828 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9829 | "out gl_PerVertex {\n" |
| 9830 | " vec4 gl_Position;\n" |
| 9831 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9832 | "void main(){\n" |
| 9833 | " gl_Position = x[0] + x[1];\n" |
| 9834 | "}\n"; |
| 9835 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9836 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9837 | "\n" |
| 9838 | "layout(location=0) out vec4 color;\n" |
| 9839 | "void main(){\n" |
| 9840 | " color = vec4(1);\n" |
| 9841 | "}\n"; |
| 9842 | |
| 9843 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9844 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9845 | |
| 9846 | VkPipelineObj pipe(m_device); |
| 9847 | pipe.AddColorAttachment(); |
| 9848 | pipe.AddShader(&vs); |
| 9849 | pipe.AddShader(&fs); |
| 9850 | |
| 9851 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9852 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9853 | |
| 9854 | VkDescriptorSetObj descriptorSet(m_device); |
| 9855 | descriptorSet.AppendDummy(); |
| 9856 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9857 | |
| 9858 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9859 | |
| 9860 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9861 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9862 | } |
| 9863 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9864 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9865 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9866 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9867 | |
| 9868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9869 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9870 | |
| 9871 | VkVertexInputBindingDescription input_binding; |
| 9872 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9873 | |
| 9874 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9875 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9876 | |
| 9877 | for (int i = 0; i < 2; i++) { |
| 9878 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9879 | input_attribs[i].location = i; |
| 9880 | } |
| 9881 | |
| 9882 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9883 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9884 | "\n" |
| 9885 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9886 | "out gl_PerVertex {\n" |
| 9887 | " vec4 gl_Position;\n" |
| 9888 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9889 | "void main(){\n" |
| 9890 | " gl_Position = x[0] + x[1];\n" |
| 9891 | "}\n"; |
| 9892 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9893 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9894 | "\n" |
| 9895 | "layout(location=0) out vec4 color;\n" |
| 9896 | "void main(){\n" |
| 9897 | " color = vec4(1);\n" |
| 9898 | "}\n"; |
| 9899 | |
| 9900 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9901 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9902 | |
| 9903 | VkPipelineObj pipe(m_device); |
| 9904 | pipe.AddColorAttachment(); |
| 9905 | pipe.AddShader(&vs); |
| 9906 | pipe.AddShader(&fs); |
| 9907 | |
| 9908 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9909 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9910 | |
| 9911 | VkDescriptorSetObj descriptorSet(m_device); |
| 9912 | descriptorSet.AppendDummy(); |
| 9913 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9914 | |
| 9915 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9916 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9917 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9918 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9919 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9920 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9921 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9922 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9923 | |
| 9924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9925 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9926 | |
| 9927 | char const *vsSource = |
| 9928 | "#version 450\n" |
| 9929 | "out gl_PerVertex {\n" |
| 9930 | " vec4 gl_Position;\n" |
| 9931 | "};\n" |
| 9932 | "void main(){\n" |
| 9933 | " gl_Position = vec4(0);\n" |
| 9934 | "}\n"; |
| 9935 | char const *fsSource = |
| 9936 | "#version 450\n" |
| 9937 | "\n" |
| 9938 | "layout(location=0) out vec4 color;\n" |
| 9939 | "void main(){\n" |
| 9940 | " color = vec4(1);\n" |
| 9941 | "}\n"; |
| 9942 | |
| 9943 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9944 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9945 | |
| 9946 | VkPipelineObj pipe(m_device); |
| 9947 | pipe.AddColorAttachment(); |
| 9948 | pipe.AddShader(&vs); |
| 9949 | pipe.AddShader(&fs); |
| 9950 | |
| 9951 | VkDescriptorSetObj descriptorSet(m_device); |
| 9952 | descriptorSet.AppendDummy(); |
| 9953 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9954 | |
| 9955 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9956 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9957 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9958 | } |
| 9959 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9960 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9961 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9962 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9963 | |
| 9964 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9965 | |
| 9966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9968 | |
| 9969 | char const *vsSource = |
| 9970 | "#version 450\n" |
| 9971 | "out gl_PerVertex {\n" |
| 9972 | " vec4 gl_Position;\n" |
| 9973 | "};\n" |
| 9974 | "layout(location=0) out vec3 x;\n" |
| 9975 | "layout(location=1) out ivec3 y;\n" |
| 9976 | "layout(location=2) out vec3 z;\n" |
| 9977 | "void main(){\n" |
| 9978 | " gl_Position = vec4(0);\n" |
| 9979 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9980 | "}\n"; |
| 9981 | char const *fsSource = |
| 9982 | "#version 450\n" |
| 9983 | "\n" |
| 9984 | "layout(location=0) out vec4 color;\n" |
| 9985 | "layout(location=0) in float x;\n" |
| 9986 | "layout(location=1) flat in int y;\n" |
| 9987 | "layout(location=2) in vec2 z;\n" |
| 9988 | "void main(){\n" |
| 9989 | " color = vec4(1 + x + y + z.x);\n" |
| 9990 | "}\n"; |
| 9991 | |
| 9992 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9993 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9994 | |
| 9995 | VkPipelineObj pipe(m_device); |
| 9996 | pipe.AddColorAttachment(); |
| 9997 | pipe.AddShader(&vs); |
| 9998 | pipe.AddShader(&fs); |
| 9999 | |
| 10000 | VkDescriptorSetObj descriptorSet(m_device); |
| 10001 | descriptorSet.AppendDummy(); |
| 10002 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10003 | |
| 10004 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10005 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10006 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 10007 | } |
| 10008 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10009 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 10010 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10011 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10012 | |
| 10013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10015 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10016 | if (!m_device->phy().features().tessellationShader) { |
| 10017 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10018 | return; |
| 10019 | } |
| 10020 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10021 | char const *vsSource = |
| 10022 | "#version 450\n" |
| 10023 | "void main(){}\n"; |
| 10024 | char const *tcsSource = |
| 10025 | "#version 450\n" |
| 10026 | "layout(location=0) out int x[];\n" |
| 10027 | "layout(vertices=3) out;\n" |
| 10028 | "void main(){\n" |
| 10029 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10030 | " gl_TessLevelInner[0] = 1;\n" |
| 10031 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10032 | "}\n"; |
| 10033 | char const *tesSource = |
| 10034 | "#version 450\n" |
| 10035 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10036 | "layout(location=0) in int x[];\n" |
| 10037 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10038 | "void main(){\n" |
| 10039 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10040 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 10041 | "}\n"; |
| 10042 | char const *fsSource = |
| 10043 | "#version 450\n" |
| 10044 | "layout(location=0) out vec4 color;\n" |
| 10045 | "void main(){\n" |
| 10046 | " color = vec4(1);\n" |
| 10047 | "}\n"; |
| 10048 | |
| 10049 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10050 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10051 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10052 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10053 | |
| 10054 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10055 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10056 | nullptr, |
| 10057 | 0, |
| 10058 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10059 | VK_FALSE}; |
| 10060 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10061 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10062 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10063 | nullptr, |
| 10064 | 0, |
| 10065 | 3}; |
| 10066 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10067 | VkPipelineObj pipe(m_device); |
| 10068 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 10069 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10070 | pipe.AddColorAttachment(); |
| 10071 | pipe.AddShader(&vs); |
| 10072 | pipe.AddShader(&tcs); |
| 10073 | pipe.AddShader(&tes); |
| 10074 | pipe.AddShader(&fs); |
| 10075 | |
| 10076 | VkDescriptorSetObj descriptorSet(m_device); |
| 10077 | descriptorSet.AppendDummy(); |
| 10078 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10079 | |
| 10080 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10082 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 10083 | } |
| 10084 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 10085 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 10086 | { |
| 10087 | m_errorMonitor->ExpectSuccess(); |
| 10088 | |
| 10089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10090 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10091 | |
| 10092 | if (!m_device->phy().features().geometryShader) { |
| 10093 | printf("Device does not support geometry shaders; skipped.\n"); |
| 10094 | return; |
| 10095 | } |
| 10096 | |
| 10097 | char const *vsSource = |
| 10098 | "#version 450\n" |
| 10099 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 10100 | "void main(){\n" |
| 10101 | " vs_out.x = vec4(1);\n" |
| 10102 | "}\n"; |
| 10103 | char const *gsSource = |
| 10104 | "#version 450\n" |
| 10105 | "layout(triangles) in;\n" |
| 10106 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 10107 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 10108 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10109 | "void main() {\n" |
| 10110 | " gl_Position = gs_in[0].x;\n" |
| 10111 | " EmitVertex();\n" |
| 10112 | "}\n"; |
| 10113 | char const *fsSource = |
| 10114 | "#version 450\n" |
| 10115 | "layout(location=0) out vec4 color;\n" |
| 10116 | "void main(){\n" |
| 10117 | " color = vec4(1);\n" |
| 10118 | "}\n"; |
| 10119 | |
| 10120 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10121 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 10122 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10123 | |
| 10124 | VkPipelineObj pipe(m_device); |
| 10125 | pipe.AddColorAttachment(); |
| 10126 | pipe.AddShader(&vs); |
| 10127 | pipe.AddShader(&gs); |
| 10128 | pipe.AddShader(&fs); |
| 10129 | |
| 10130 | VkDescriptorSetObj descriptorSet(m_device); |
| 10131 | descriptorSet.AppendDummy(); |
| 10132 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10133 | |
| 10134 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10135 | |
| 10136 | m_errorMonitor->VerifyNotFound(); |
| 10137 | } |
| 10138 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10139 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 10140 | { |
| 10141 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10142 | "is per-vertex in tessellation control shader stage " |
| 10143 | "but per-patch in tessellation evaluation shader stage"); |
| 10144 | |
| 10145 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10146 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10147 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10148 | if (!m_device->phy().features().tessellationShader) { |
| 10149 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 10150 | return; |
| 10151 | } |
| 10152 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10153 | char const *vsSource = |
| 10154 | "#version 450\n" |
| 10155 | "void main(){}\n"; |
| 10156 | char const *tcsSource = |
| 10157 | "#version 450\n" |
| 10158 | "layout(location=0) out int x[];\n" |
| 10159 | "layout(vertices=3) out;\n" |
| 10160 | "void main(){\n" |
| 10161 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 10162 | " gl_TessLevelInner[0] = 1;\n" |
| 10163 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 10164 | "}\n"; |
| 10165 | char const *tesSource = |
| 10166 | "#version 450\n" |
| 10167 | "layout(triangles, equal_spacing, cw) in;\n" |
| 10168 | "layout(location=0) patch in int x;\n" |
| 10169 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 10170 | "void main(){\n" |
| 10171 | " gl_Position.xyz = gl_TessCoord;\n" |
| 10172 | " gl_Position.w = x;\n" |
| 10173 | "}\n"; |
| 10174 | char const *fsSource = |
| 10175 | "#version 450\n" |
| 10176 | "layout(location=0) out vec4 color;\n" |
| 10177 | "void main(){\n" |
| 10178 | " color = vec4(1);\n" |
| 10179 | "}\n"; |
| 10180 | |
| 10181 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10182 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 10183 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 10184 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10185 | |
| 10186 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 10187 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 10188 | nullptr, |
| 10189 | 0, |
| 10190 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 10191 | VK_FALSE}; |
| 10192 | |
| 10193 | VkPipelineTessellationStateCreateInfo tsci{ |
| 10194 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 10195 | nullptr, |
| 10196 | 0, |
| 10197 | 3}; |
| 10198 | |
| 10199 | VkPipelineObj pipe(m_device); |
| 10200 | pipe.SetInputAssembly(&iasci); |
| 10201 | pipe.SetTessellation(&tsci); |
| 10202 | pipe.AddColorAttachment(); |
| 10203 | pipe.AddShader(&vs); |
| 10204 | pipe.AddShader(&tcs); |
| 10205 | pipe.AddShader(&tes); |
| 10206 | pipe.AddShader(&fs); |
| 10207 | |
| 10208 | VkDescriptorSetObj descriptorSet(m_device); |
| 10209 | descriptorSet.AppendDummy(); |
| 10210 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10211 | |
| 10212 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10214 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10215 | } |
| 10216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10217 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 10218 | m_errorMonitor->SetDesiredFailureMsg( |
| 10219 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10220 | "Duplicate vertex input binding descriptions for binding 0"); |
| 10221 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10222 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10223 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10224 | |
| 10225 | /* Two binding descriptions for binding 0 */ |
| 10226 | VkVertexInputBindingDescription input_bindings[2]; |
| 10227 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10228 | |
| 10229 | VkVertexInputAttributeDescription input_attrib; |
| 10230 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 10231 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 10232 | |
| 10233 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10234 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10235 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10236 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10237 | "out gl_PerVertex {\n" |
| 10238 | " vec4 gl_Position;\n" |
| 10239 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10240 | "void main(){\n" |
| 10241 | " gl_Position = vec4(x);\n" |
| 10242 | "}\n"; |
| 10243 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10244 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10245 | "\n" |
| 10246 | "layout(location=0) out vec4 color;\n" |
| 10247 | "void main(){\n" |
| 10248 | " color = vec4(1);\n" |
| 10249 | "}\n"; |
| 10250 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10251 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10252 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10253 | |
| 10254 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10255 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10256 | pipe.AddShader(&vs); |
| 10257 | pipe.AddShader(&fs); |
| 10258 | |
| 10259 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 10260 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 10261 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10262 | VkDescriptorSetObj descriptorSet(m_device); |
| 10263 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10264 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10265 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10266 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10267 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10268 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10269 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 10270 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 10271 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 10272 | m_errorMonitor->ExpectSuccess(); |
| 10273 | |
| 10274 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10275 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10276 | |
| 10277 | if (!m_device->phy().features().tessellationShader) { |
| 10278 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 10279 | return; |
| 10280 | } |
| 10281 | |
| 10282 | VkVertexInputBindingDescription input_bindings[1]; |
| 10283 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 10284 | |
| 10285 | VkVertexInputAttributeDescription input_attribs[4]; |
| 10286 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 10287 | input_attribs[0].location = 0; |
| 10288 | input_attribs[0].offset = 0; |
| 10289 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10290 | input_attribs[1].location = 2; |
| 10291 | input_attribs[1].offset = 32; |
| 10292 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10293 | input_attribs[2].location = 4; |
| 10294 | input_attribs[2].offset = 64; |
| 10295 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10296 | input_attribs[3].location = 6; |
| 10297 | input_attribs[3].offset = 96; |
| 10298 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 10299 | |
| 10300 | char const *vsSource = |
| 10301 | "#version 450\n" |
| 10302 | "\n" |
| 10303 | "layout(location=0) in dmat4 x;\n" |
| 10304 | "out gl_PerVertex {\n" |
| 10305 | " vec4 gl_Position;\n" |
| 10306 | "};\n" |
| 10307 | "void main(){\n" |
| 10308 | " gl_Position = vec4(x[0][0]);\n" |
| 10309 | "}\n"; |
| 10310 | char const *fsSource = |
| 10311 | "#version 450\n" |
| 10312 | "\n" |
| 10313 | "layout(location=0) out vec4 color;\n" |
| 10314 | "void main(){\n" |
| 10315 | " color = vec4(1);\n" |
| 10316 | "}\n"; |
| 10317 | |
| 10318 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10319 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10320 | |
| 10321 | VkPipelineObj pipe(m_device); |
| 10322 | pipe.AddColorAttachment(); |
| 10323 | pipe.AddShader(&vs); |
| 10324 | pipe.AddShader(&fs); |
| 10325 | |
| 10326 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 10327 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 10328 | |
| 10329 | VkDescriptorSetObj descriptorSet(m_device); |
| 10330 | descriptorSet.AppendDummy(); |
| 10331 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10332 | |
| 10333 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10334 | |
| 10335 | m_errorMonitor->VerifyNotFound(); |
| 10336 | } |
| 10337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10338 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10339 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10340 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10341 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10342 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10343 | |
| 10344 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10345 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10346 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10347 | "out gl_PerVertex {\n" |
| 10348 | " vec4 gl_Position;\n" |
| 10349 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10350 | "void main(){\n" |
| 10351 | " gl_Position = vec4(1);\n" |
| 10352 | "}\n"; |
| 10353 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10354 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10355 | "\n" |
| 10356 | "void main(){\n" |
| 10357 | "}\n"; |
| 10358 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10359 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10360 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10361 | |
| 10362 | VkPipelineObj pipe(m_device); |
| 10363 | pipe.AddShader(&vs); |
| 10364 | pipe.AddShader(&fs); |
| 10365 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10366 | /* set up CB 0, not written */ |
| 10367 | pipe.AddColorAttachment(); |
| 10368 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10369 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10370 | VkDescriptorSetObj descriptorSet(m_device); |
| 10371 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10372 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10373 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10374 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10375 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10376 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10377 | } |
| 10378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10379 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10380 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10381 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10382 | "FS writes to output location 1 with no matching attachment"); |
| 10383 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10385 | |
| 10386 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10387 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10388 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10389 | "out gl_PerVertex {\n" |
| 10390 | " vec4 gl_Position;\n" |
| 10391 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10392 | "void main(){\n" |
| 10393 | " gl_Position = vec4(1);\n" |
| 10394 | "}\n"; |
| 10395 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10396 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10397 | "\n" |
| 10398 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10399 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10400 | "void main(){\n" |
| 10401 | " x = vec4(1);\n" |
| 10402 | " y = vec4(1);\n" |
| 10403 | "}\n"; |
| 10404 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10405 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10406 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10407 | |
| 10408 | VkPipelineObj pipe(m_device); |
| 10409 | pipe.AddShader(&vs); |
| 10410 | pipe.AddShader(&fs); |
| 10411 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10412 | /* set up CB 0, not written */ |
| 10413 | pipe.AddColorAttachment(); |
| 10414 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10415 | /* FS writes CB 1, but we don't configure it */ |
| 10416 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10417 | VkDescriptorSetObj descriptorSet(m_device); |
| 10418 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10419 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10420 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10421 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10422 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10423 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10424 | } |
| 10425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10426 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10427 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10428 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10429 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10431 | |
| 10432 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10433 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10434 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10435 | "out gl_PerVertex {\n" |
| 10436 | " vec4 gl_Position;\n" |
| 10437 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10438 | "void main(){\n" |
| 10439 | " gl_Position = vec4(1);\n" |
| 10440 | "}\n"; |
| 10441 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10442 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10443 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10444 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10445 | "void main(){\n" |
| 10446 | " x = ivec4(1);\n" |
| 10447 | "}\n"; |
| 10448 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10449 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10450 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10451 | |
| 10452 | VkPipelineObj pipe(m_device); |
| 10453 | pipe.AddShader(&vs); |
| 10454 | pipe.AddShader(&fs); |
| 10455 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10456 | /* set up CB 0; type is UNORM by default */ |
| 10457 | pipe.AddColorAttachment(); |
| 10458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10459 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10460 | VkDescriptorSetObj descriptorSet(m_device); |
| 10461 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10462 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10463 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10464 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10465 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10466 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10467 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10469 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10470 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10471 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10472 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10473 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10474 | |
| 10475 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10476 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10477 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10478 | "out gl_PerVertex {\n" |
| 10479 | " vec4 gl_Position;\n" |
| 10480 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10481 | "void main(){\n" |
| 10482 | " gl_Position = vec4(1);\n" |
| 10483 | "}\n"; |
| 10484 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10485 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10486 | "\n" |
| 10487 | "layout(location=0) out vec4 x;\n" |
| 10488 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10489 | "void main(){\n" |
| 10490 | " x = vec4(bar.y);\n" |
| 10491 | "}\n"; |
| 10492 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10493 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10494 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10495 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10496 | VkPipelineObj pipe(m_device); |
| 10497 | pipe.AddShader(&vs); |
| 10498 | pipe.AddShader(&fs); |
| 10499 | |
| 10500 | /* set up CB 0; type is UNORM by default */ |
| 10501 | pipe.AddColorAttachment(); |
| 10502 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10503 | |
| 10504 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10505 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10506 | |
| 10507 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10508 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10509 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10510 | } |
| 10511 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10512 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10513 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10514 | "not declared in layout"); |
| 10515 | |
| 10516 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10517 | |
| 10518 | char const *vsSource = |
| 10519 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10520 | "\n" |
| 10521 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10522 | "out gl_PerVertex {\n" |
| 10523 | " vec4 gl_Position;\n" |
| 10524 | "};\n" |
| 10525 | "void main(){\n" |
| 10526 | " gl_Position = vec4(consts.x);\n" |
| 10527 | "}\n"; |
| 10528 | char const *fsSource = |
| 10529 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10530 | "\n" |
| 10531 | "layout(location=0) out vec4 x;\n" |
| 10532 | "void main(){\n" |
| 10533 | " x = vec4(1);\n" |
| 10534 | "}\n"; |
| 10535 | |
| 10536 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10537 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10538 | |
| 10539 | VkPipelineObj pipe(m_device); |
| 10540 | pipe.AddShader(&vs); |
| 10541 | pipe.AddShader(&fs); |
| 10542 | |
| 10543 | /* set up CB 0; type is UNORM by default */ |
| 10544 | pipe.AddColorAttachment(); |
| 10545 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10546 | |
| 10547 | VkDescriptorSetObj descriptorSet(m_device); |
| 10548 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10549 | |
| 10550 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10551 | |
| 10552 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10553 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10554 | } |
| 10555 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10556 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10557 | m_errorMonitor->SetDesiredFailureMsg( |
| 10558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10559 | "Shader uses descriptor slot 0.0"); |
| 10560 | |
| 10561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10562 | |
| 10563 | char const *csSource = |
| 10564 | "#version 450\n" |
| 10565 | "\n" |
| 10566 | "layout(local_size_x=1) in;\n" |
| 10567 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10568 | "void main(){\n" |
| 10569 | " x = vec4(1);\n" |
| 10570 | "}\n"; |
| 10571 | |
| 10572 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10573 | |
| 10574 | VkDescriptorSetObj descriptorSet(m_device); |
| 10575 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10576 | |
| 10577 | VkComputePipelineCreateInfo cpci = { |
| 10578 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10579 | nullptr, 0, { |
| 10580 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10581 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10582 | cs.handle(), "main", nullptr |
| 10583 | }, |
| 10584 | descriptorSet.GetPipelineLayout(), |
| 10585 | VK_NULL_HANDLE, -1 |
| 10586 | }; |
| 10587 | |
| 10588 | VkPipeline pipe; |
| 10589 | VkResult err = vkCreateComputePipelines( |
| 10590 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10591 | |
| 10592 | m_errorMonitor->VerifyFound(); |
| 10593 | |
| 10594 | if (err == VK_SUCCESS) { |
| 10595 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10596 | } |
| 10597 | } |
| 10598 | |
| 10599 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10600 | m_errorMonitor->ExpectSuccess(); |
| 10601 | |
| 10602 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10603 | |
| 10604 | char const *csSource = |
| 10605 | "#version 450\n" |
| 10606 | "\n" |
| 10607 | "layout(local_size_x=1) in;\n" |
| 10608 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10609 | "void main(){\n" |
| 10610 | " // x is not used.\n" |
| 10611 | "}\n"; |
| 10612 | |
| 10613 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10614 | |
| 10615 | VkDescriptorSetObj descriptorSet(m_device); |
| 10616 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10617 | |
| 10618 | VkComputePipelineCreateInfo cpci = { |
| 10619 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10620 | nullptr, 0, { |
| 10621 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10622 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10623 | cs.handle(), "main", nullptr |
| 10624 | }, |
| 10625 | descriptorSet.GetPipelineLayout(), |
| 10626 | VK_NULL_HANDLE, -1 |
| 10627 | }; |
| 10628 | |
| 10629 | VkPipeline pipe; |
| 10630 | VkResult err = vkCreateComputePipelines( |
| 10631 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10632 | |
| 10633 | m_errorMonitor->VerifyNotFound(); |
| 10634 | |
| 10635 | if (err == VK_SUCCESS) { |
| 10636 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10637 | } |
| 10638 | } |
| 10639 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10640 | #endif // SHADER_CHECKER_TESTS |
| 10641 | |
| 10642 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10643 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10644 | m_errorMonitor->SetDesiredFailureMsg( |
| 10645 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10646 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10647 | |
| 10648 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10649 | |
| 10650 | // Create an image |
| 10651 | VkImage image; |
| 10652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10653 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10654 | const int32_t tex_width = 32; |
| 10655 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10656 | |
| 10657 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10658 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10659 | image_create_info.pNext = NULL; |
| 10660 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10661 | image_create_info.format = tex_format; |
| 10662 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10663 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10664 | image_create_info.extent.depth = 1; |
| 10665 | image_create_info.mipLevels = 1; |
| 10666 | image_create_info.arrayLayers = 1; |
| 10667 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10668 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10669 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10670 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10671 | |
| 10672 | // Introduce error by sending down a bogus width extent |
| 10673 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10674 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10675 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10676 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10677 | } |
| 10678 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10679 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10680 | m_errorMonitor->SetDesiredFailureMsg( |
| 10681 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10682 | "CreateImage extents is 0 for at least one required dimension"); |
| 10683 | |
| 10684 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10685 | |
| 10686 | // Create an image |
| 10687 | VkImage image; |
| 10688 | |
| 10689 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10690 | const int32_t tex_width = 32; |
| 10691 | const int32_t tex_height = 32; |
| 10692 | |
| 10693 | VkImageCreateInfo image_create_info = {}; |
| 10694 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10695 | image_create_info.pNext = NULL; |
| 10696 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10697 | image_create_info.format = tex_format; |
| 10698 | image_create_info.extent.width = tex_width; |
| 10699 | image_create_info.extent.height = tex_height; |
| 10700 | image_create_info.extent.depth = 1; |
| 10701 | image_create_info.mipLevels = 1; |
| 10702 | image_create_info.arrayLayers = 1; |
| 10703 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10704 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10705 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10706 | image_create_info.flags = 0; |
| 10707 | |
| 10708 | // Introduce error by sending down a bogus width extent |
| 10709 | image_create_info.extent.width = 0; |
| 10710 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10711 | |
| 10712 | m_errorMonitor->VerifyFound(); |
| 10713 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10714 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10715 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10716 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10717 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10718 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10719 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10720 | m_errorMonitor->SetDesiredFailureMsg( |
| 10721 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10722 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10723 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10725 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10726 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10727 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10729 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10730 | const int32_t tex_width = 32; |
| 10731 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10732 | |
| 10733 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10734 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10735 | image_create_info.pNext = NULL; |
| 10736 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10737 | image_create_info.format = tex_format; |
| 10738 | image_create_info.extent.width = tex_width; |
| 10739 | image_create_info.extent.height = tex_height; |
| 10740 | image_create_info.extent.depth = 1; |
| 10741 | image_create_info.mipLevels = 1; |
| 10742 | image_create_info.arrayLayers = 1; |
| 10743 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10744 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10745 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10746 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10747 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10748 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10749 | ASSERT_VK_SUCCESS(err); |
| 10750 | |
| 10751 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10752 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10753 | image_view_create_info.image = image; |
| 10754 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10755 | image_view_create_info.format = tex_format; |
| 10756 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10757 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10758 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10759 | image_view_create_info.subresourceRange.aspectMask = |
| 10760 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10761 | |
| 10762 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10763 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10764 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10765 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10766 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10767 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10768 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10769 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10770 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10771 | TEST_DESCRIPTION( |
| 10772 | "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] | 10773 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10774 | "vkCreateImageView: Color image " |
| 10775 | "formats must have ONLY the " |
| 10776 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10777 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10778 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10780 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10781 | VkImageObj image(m_device); |
| 10782 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10783 | VK_IMAGE_TILING_LINEAR, 0); |
| 10784 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10785 | |
| 10786 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10787 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10788 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10789 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10790 | image_view_create_info.format = tex_format; |
| 10791 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10792 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10793 | // Cause an error by setting an invalid image aspect |
| 10794 | image_view_create_info.subresourceRange.aspectMask = |
| 10795 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10796 | |
| 10797 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10798 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10799 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10800 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10801 | } |
| 10802 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10803 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10804 | VkResult err; |
| 10805 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10806 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10807 | m_errorMonitor->SetDesiredFailureMsg( |
| 10808 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10809 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10810 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10811 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10812 | |
| 10813 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10814 | VkImage srcImage; |
| 10815 | VkImage dstImage; |
| 10816 | VkDeviceMemory srcMem; |
| 10817 | VkDeviceMemory destMem; |
| 10818 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10819 | |
| 10820 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10821 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10822 | image_create_info.pNext = NULL; |
| 10823 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10824 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10825 | image_create_info.extent.width = 32; |
| 10826 | image_create_info.extent.height = 32; |
| 10827 | image_create_info.extent.depth = 1; |
| 10828 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10829 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10830 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10831 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10832 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10833 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10835 | err = |
| 10836 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10837 | ASSERT_VK_SUCCESS(err); |
| 10838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10839 | err = |
| 10840 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10841 | ASSERT_VK_SUCCESS(err); |
| 10842 | |
| 10843 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10844 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10845 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10846 | memAlloc.pNext = NULL; |
| 10847 | memAlloc.allocationSize = 0; |
| 10848 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10849 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10850 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10851 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10852 | pass = |
| 10853 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10854 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10855 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10856 | ASSERT_VK_SUCCESS(err); |
| 10857 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10858 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10859 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10860 | pass = |
| 10861 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10862 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10863 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10864 | ASSERT_VK_SUCCESS(err); |
| 10865 | |
| 10866 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10867 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10868 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10869 | ASSERT_VK_SUCCESS(err); |
| 10870 | |
| 10871 | BeginCommandBuffer(); |
| 10872 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10873 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10874 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10875 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10876 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10877 | copyRegion.srcOffset.x = 0; |
| 10878 | copyRegion.srcOffset.y = 0; |
| 10879 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10880 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10881 | copyRegion.dstSubresource.mipLevel = 0; |
| 10882 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10883 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10884 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10885 | copyRegion.dstOffset.x = 0; |
| 10886 | copyRegion.dstOffset.y = 0; |
| 10887 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10888 | copyRegion.extent.width = 1; |
| 10889 | copyRegion.extent.height = 1; |
| 10890 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10891 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10892 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10893 | EndCommandBuffer(); |
| 10894 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10895 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10896 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10897 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10898 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10899 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10900 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10901 | } |
| 10902 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10903 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10904 | |
| 10905 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10906 | |
| 10907 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10908 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10909 | VkImageObj image(m_device); |
| 10910 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10911 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10912 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10913 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10914 | ASSERT_TRUE(image.initialized()); |
| 10915 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10916 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10917 | VkImageCreateInfo image_create_info; |
| 10918 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10919 | image_create_info.pNext = NULL; |
| 10920 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10921 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10922 | image_create_info.extent.width = 32; |
| 10923 | image_create_info.extent.height = 32; |
| 10924 | image_create_info.extent.depth = 1; |
| 10925 | image_create_info.mipLevels = 1; |
| 10926 | image_create_info.arrayLayers = 1; |
| 10927 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10928 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10929 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10930 | image_create_info.flags = 0; |
| 10931 | |
| 10932 | m_errorMonitor->SetDesiredFailureMsg( |
| 10933 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10934 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10935 | |
| 10936 | VkImage localImage; |
| 10937 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10938 | m_errorMonitor->VerifyFound(); |
| 10939 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10940 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10941 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10942 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10943 | VkFormat format = static_cast<VkFormat>(f); |
| 10944 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10945 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10946 | fProps.optimalTilingFeatures == 0) { |
| 10947 | unsupported = format; |
| 10948 | break; |
| 10949 | } |
| 10950 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10951 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10952 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10953 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10954 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10955 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10956 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10957 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10958 | m_errorMonitor->VerifyFound(); |
| 10959 | } |
| 10960 | } |
| 10961 | |
| 10962 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10963 | VkResult ret; |
| 10964 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10965 | |
| 10966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10967 | |
| 10968 | VkImageObj image(m_device); |
| 10969 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10970 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10971 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10972 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10973 | ASSERT_TRUE(image.initialized()); |
| 10974 | |
| 10975 | VkImageView imgView; |
| 10976 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10977 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10978 | imgViewInfo.image = image.handle(); |
| 10979 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10980 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10981 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10982 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10983 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10984 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10985 | |
| 10986 | m_errorMonitor->SetDesiredFailureMsg( |
| 10987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10988 | "vkCreateImageView called with baseMipLevel"); |
| 10989 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10990 | // VIEW_CREATE_ERROR |
| 10991 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10992 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10993 | m_errorMonitor->VerifyFound(); |
| 10994 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10995 | |
| 10996 | m_errorMonitor->SetDesiredFailureMsg( |
| 10997 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10998 | "vkCreateImageView called with baseArrayLayer"); |
| 10999 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 11000 | // VIEW_CREATE_ERROR |
| 11001 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 11002 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11003 | m_errorMonitor->VerifyFound(); |
| 11004 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 11005 | |
| 11006 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11007 | "vkCreateImageView called with 0 in " |
| 11008 | "pCreateInfo->subresourceRange." |
| 11009 | "levelCount"); |
| 11010 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11011 | imgViewInfo.subresourceRange.levelCount = 0; |
| 11012 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11013 | m_errorMonitor->VerifyFound(); |
| 11014 | imgViewInfo.subresourceRange.levelCount = 1; |
| 11015 | |
| 11016 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11017 | "vkCreateImageView called with 0 in " |
| 11018 | "pCreateInfo->subresourceRange." |
| 11019 | "layerCount"); |
| 11020 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 11021 | imgViewInfo.subresourceRange.layerCount = 0; |
| 11022 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11023 | m_errorMonitor->VerifyFound(); |
| 11024 | imgViewInfo.subresourceRange.layerCount = 1; |
| 11025 | |
| 11026 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11027 | "but both must be color formats"); |
| 11028 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 11029 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11030 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11031 | m_errorMonitor->VerifyFound(); |
| 11032 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11033 | |
| 11034 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11035 | "Formats MUST be IDENTICAL unless " |
| 11036 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 11037 | "was set on image creation."); |
| 11038 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 11039 | // VIEW_CREATE_ERROR |
| 11040 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 11041 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11042 | m_errorMonitor->VerifyFound(); |
| 11043 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11044 | |
| 11045 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11046 | "can support ImageViews with " |
| 11047 | "differing formats but they must be " |
| 11048 | "in the same compatibility class."); |
| 11049 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 11050 | // VIEW_CREATE_ERROR |
| 11051 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 11052 | VkImage mutImage; |
| 11053 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 11054 | assert( |
| 11055 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 11056 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 11057 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 11058 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11059 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 11060 | ASSERT_VK_SUCCESS(ret); |
| 11061 | imgViewInfo.image = mutImage; |
| 11062 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 11063 | m_errorMonitor->VerifyFound(); |
| 11064 | imgViewInfo.image = image.handle(); |
| 11065 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 11066 | } |
| 11067 | |
| 11068 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 11069 | |
| 11070 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 11071 | |
| 11072 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11073 | |
| 11074 | VkImageObj image(m_device); |
| 11075 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 11076 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 11077 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 11078 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 11079 | ASSERT_TRUE(image.initialized()); |
| 11080 | |
| 11081 | m_errorMonitor->SetDesiredFailureMsg( |
| 11082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11083 | "number of layers in image subresource is zero"); |
| 11084 | vk_testing::Buffer buffer; |
| 11085 | VkMemoryPropertyFlags reqs = 0; |
| 11086 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 11087 | VkBufferImageCopy region = {}; |
| 11088 | region.bufferRowLength = 128; |
| 11089 | region.bufferImageHeight = 128; |
| 11090 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11091 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 11092 | region.imageSubresource.layerCount = 0; |
| 11093 | region.imageExtent.height = 4; |
| 11094 | region.imageExtent.width = 4; |
| 11095 | region.imageExtent.depth = 1; |
| 11096 | m_commandBuffer->BeginCommandBuffer(); |
| 11097 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11098 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11099 | 1, ®ion); |
| 11100 | m_errorMonitor->VerifyFound(); |
| 11101 | region.imageSubresource.layerCount = 1; |
| 11102 | |
| 11103 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11104 | "aspectMasks for each region must " |
| 11105 | "specify only COLOR or DEPTH or " |
| 11106 | "STENCIL"); |
| 11107 | // Expect MISMATCHED_IMAGE_ASPECT |
| 11108 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 11109 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 11110 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 11111 | 1, ®ion); |
| 11112 | m_errorMonitor->VerifyFound(); |
| 11113 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11114 | |
| 11115 | m_errorMonitor->SetDesiredFailureMsg( |
| 11116 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11117 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 11118 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 11119 | // Expect INVALID_FILTER |
| 11120 | VkImageObj intImage1(m_device); |
| 11121 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 11122 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11123 | 0); |
| 11124 | VkImageObj intImage2(m_device); |
| 11125 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 11126 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 11127 | 0); |
| 11128 | VkImageBlit blitRegion = {}; |
| 11129 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11130 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 11131 | blitRegion.srcSubresource.layerCount = 1; |
| 11132 | blitRegion.srcSubresource.mipLevel = 0; |
| 11133 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11134 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 11135 | blitRegion.dstSubresource.layerCount = 1; |
| 11136 | blitRegion.dstSubresource.mipLevel = 0; |
| 11137 | |
| 11138 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 11139 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 11140 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 11141 | m_errorMonitor->VerifyFound(); |
| 11142 | |
| 11143 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11144 | "called with 0 in ppMemoryBarriers"); |
| 11145 | VkImageMemoryBarrier img_barrier; |
| 11146 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 11147 | img_barrier.pNext = NULL; |
| 11148 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 11149 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 11150 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11151 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11152 | img_barrier.image = image.handle(); |
| 11153 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11154 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 11155 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11156 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 11157 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 11158 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 11159 | img_barrier.subresourceRange.layerCount = 0; |
| 11160 | img_barrier.subresourceRange.levelCount = 1; |
| 11161 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 11162 | VK_PIPELINE_STAGE_HOST_BIT, |
| 11163 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 11164 | nullptr, 1, &img_barrier); |
| 11165 | m_errorMonitor->VerifyFound(); |
| 11166 | img_barrier.subresourceRange.layerCount = 1; |
| 11167 | } |
| 11168 | |
| 11169 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 11170 | |
| 11171 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 11172 | |
| 11173 | m_errorMonitor->SetDesiredFailureMsg( |
| 11174 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11175 | "CreateImage extents exceed allowable limits for format"); |
| 11176 | VkImageCreateInfo image_create_info = {}; |
| 11177 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11178 | image_create_info.pNext = NULL; |
| 11179 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11180 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11181 | image_create_info.extent.width = 32; |
| 11182 | image_create_info.extent.height = 32; |
| 11183 | image_create_info.extent.depth = 1; |
| 11184 | image_create_info.mipLevels = 1; |
| 11185 | image_create_info.arrayLayers = 1; |
| 11186 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11187 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11188 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11189 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11190 | image_create_info.flags = 0; |
| 11191 | |
| 11192 | VkImage nullImg; |
| 11193 | VkImageFormatProperties imgFmtProps; |
| 11194 | vkGetPhysicalDeviceImageFormatProperties( |
| 11195 | gpu(), image_create_info.format, image_create_info.imageType, |
| 11196 | image_create_info.tiling, image_create_info.usage, |
| 11197 | image_create_info.flags, &imgFmtProps); |
| 11198 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 11199 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11200 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11201 | m_errorMonitor->VerifyFound(); |
| 11202 | image_create_info.extent.depth = 1; |
| 11203 | |
| 11204 | m_errorMonitor->SetDesiredFailureMsg( |
| 11205 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11206 | "exceeds allowable maximum supported by format of"); |
| 11207 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 11208 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11209 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11210 | m_errorMonitor->VerifyFound(); |
| 11211 | image_create_info.mipLevels = 1; |
| 11212 | |
| 11213 | m_errorMonitor->SetDesiredFailureMsg( |
| 11214 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11215 | "exceeds allowable maximum supported by format of"); |
| 11216 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 11217 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11218 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11219 | m_errorMonitor->VerifyFound(); |
| 11220 | image_create_info.arrayLayers = 1; |
| 11221 | |
| 11222 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11223 | "is not supported by format"); |
| 11224 | int samples = imgFmtProps.sampleCounts >> 1; |
| 11225 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 11226 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 11227 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11228 | m_errorMonitor->VerifyFound(); |
| 11229 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11230 | |
| 11231 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11232 | "pCreateInfo->initialLayout, must be " |
| 11233 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 11234 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 11235 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 11236 | // Expect INVALID_LAYOUT |
| 11237 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 11238 | m_errorMonitor->VerifyFound(); |
| 11239 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 11240 | } |
| 11241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11242 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11243 | VkResult err; |
| 11244 | bool pass; |
| 11245 | |
| 11246 | // Create color images with different format sizes and try to copy between them |
| 11247 | m_errorMonitor->SetDesiredFailureMsg( |
| 11248 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11249 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 11250 | |
| 11251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11252 | |
| 11253 | // Create two images of different types and try to copy between them |
| 11254 | VkImage srcImage; |
| 11255 | VkImage dstImage; |
| 11256 | VkDeviceMemory srcMem; |
| 11257 | VkDeviceMemory destMem; |
| 11258 | VkMemoryRequirements memReqs; |
| 11259 | |
| 11260 | VkImageCreateInfo image_create_info = {}; |
| 11261 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11262 | image_create_info.pNext = NULL; |
| 11263 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11264 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11265 | image_create_info.extent.width = 32; |
| 11266 | image_create_info.extent.height = 32; |
| 11267 | image_create_info.extent.depth = 1; |
| 11268 | image_create_info.mipLevels = 1; |
| 11269 | image_create_info.arrayLayers = 1; |
| 11270 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11271 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11272 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11273 | image_create_info.flags = 0; |
| 11274 | |
| 11275 | err = |
| 11276 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 11277 | ASSERT_VK_SUCCESS(err); |
| 11278 | |
| 11279 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11280 | // Introduce failure by creating second image with a different-sized format. |
| 11281 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 11282 | |
| 11283 | err = |
| 11284 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 11285 | ASSERT_VK_SUCCESS(err); |
| 11286 | |
| 11287 | // Allocate memory |
| 11288 | VkMemoryAllocateInfo memAlloc = {}; |
| 11289 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11290 | memAlloc.pNext = NULL; |
| 11291 | memAlloc.allocationSize = 0; |
| 11292 | memAlloc.memoryTypeIndex = 0; |
| 11293 | |
| 11294 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 11295 | memAlloc.allocationSize = memReqs.size; |
| 11296 | pass = |
| 11297 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11298 | ASSERT_TRUE(pass); |
| 11299 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 11300 | ASSERT_VK_SUCCESS(err); |
| 11301 | |
| 11302 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 11303 | memAlloc.allocationSize = memReqs.size; |
| 11304 | pass = |
| 11305 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 11306 | ASSERT_TRUE(pass); |
| 11307 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 11308 | ASSERT_VK_SUCCESS(err); |
| 11309 | |
| 11310 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11311 | ASSERT_VK_SUCCESS(err); |
| 11312 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 11313 | ASSERT_VK_SUCCESS(err); |
| 11314 | |
| 11315 | BeginCommandBuffer(); |
| 11316 | VkImageCopy copyRegion; |
| 11317 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11318 | copyRegion.srcSubresource.mipLevel = 0; |
| 11319 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 11320 | copyRegion.srcSubresource.layerCount = 0; |
| 11321 | copyRegion.srcOffset.x = 0; |
| 11322 | copyRegion.srcOffset.y = 0; |
| 11323 | copyRegion.srcOffset.z = 0; |
| 11324 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11325 | copyRegion.dstSubresource.mipLevel = 0; |
| 11326 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11327 | copyRegion.dstSubresource.layerCount = 0; |
| 11328 | copyRegion.dstOffset.x = 0; |
| 11329 | copyRegion.dstOffset.y = 0; |
| 11330 | copyRegion.dstOffset.z = 0; |
| 11331 | copyRegion.extent.width = 1; |
| 11332 | copyRegion.extent.height = 1; |
| 11333 | copyRegion.extent.depth = 1; |
| 11334 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11335 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 11336 | EndCommandBuffer(); |
| 11337 | |
| 11338 | m_errorMonitor->VerifyFound(); |
| 11339 | |
| 11340 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 11341 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 11342 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11343 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11344 | } |
| 11345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11346 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 11347 | VkResult err; |
| 11348 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11349 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11350 | // 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] | 11351 | m_errorMonitor->SetDesiredFailureMsg( |
| 11352 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11353 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11354 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11355 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11356 | |
| 11357 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11358 | VkImage srcImage; |
| 11359 | VkImage dstImage; |
| 11360 | VkDeviceMemory srcMem; |
| 11361 | VkDeviceMemory destMem; |
| 11362 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11363 | |
| 11364 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11365 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11366 | image_create_info.pNext = NULL; |
| 11367 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11368 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11369 | image_create_info.extent.width = 32; |
| 11370 | image_create_info.extent.height = 32; |
| 11371 | image_create_info.extent.depth = 1; |
| 11372 | image_create_info.mipLevels = 1; |
| 11373 | image_create_info.arrayLayers = 1; |
| 11374 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11375 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11376 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11377 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11379 | err = |
| 11380 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11381 | ASSERT_VK_SUCCESS(err); |
| 11382 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11383 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11384 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11385 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11386 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11387 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11388 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11390 | err = |
| 11391 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11392 | ASSERT_VK_SUCCESS(err); |
| 11393 | |
| 11394 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11395 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11396 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11397 | memAlloc.pNext = NULL; |
| 11398 | memAlloc.allocationSize = 0; |
| 11399 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11400 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11401 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11402 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11403 | pass = |
| 11404 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11405 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11406 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11407 | ASSERT_VK_SUCCESS(err); |
| 11408 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11409 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11410 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11411 | pass = |
| 11412 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11413 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11414 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11415 | ASSERT_VK_SUCCESS(err); |
| 11416 | |
| 11417 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11418 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11419 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11420 | ASSERT_VK_SUCCESS(err); |
| 11421 | |
| 11422 | BeginCommandBuffer(); |
| 11423 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11424 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11425 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11426 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11427 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11428 | copyRegion.srcOffset.x = 0; |
| 11429 | copyRegion.srcOffset.y = 0; |
| 11430 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11431 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11432 | copyRegion.dstSubresource.mipLevel = 0; |
| 11433 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11434 | copyRegion.dstSubresource.layerCount = 0; |
| 11435 | copyRegion.dstOffset.x = 0; |
| 11436 | copyRegion.dstOffset.y = 0; |
| 11437 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11438 | copyRegion.extent.width = 1; |
| 11439 | copyRegion.extent.height = 1; |
| 11440 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11441 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11442 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11443 | EndCommandBuffer(); |
| 11444 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11445 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11446 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11447 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11448 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11449 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11450 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11451 | } |
| 11452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11453 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11454 | VkResult err; |
| 11455 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11457 | m_errorMonitor->SetDesiredFailureMsg( |
| 11458 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11459 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11460 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11461 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11462 | |
| 11463 | // 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] | 11464 | VkImage srcImage; |
| 11465 | VkImage dstImage; |
| 11466 | VkDeviceMemory srcMem; |
| 11467 | VkDeviceMemory destMem; |
| 11468 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11469 | |
| 11470 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11471 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11472 | image_create_info.pNext = NULL; |
| 11473 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11474 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11475 | image_create_info.extent.width = 32; |
| 11476 | image_create_info.extent.height = 1; |
| 11477 | image_create_info.extent.depth = 1; |
| 11478 | image_create_info.mipLevels = 1; |
| 11479 | image_create_info.arrayLayers = 1; |
| 11480 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11481 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11482 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11483 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11484 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11485 | err = |
| 11486 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11487 | ASSERT_VK_SUCCESS(err); |
| 11488 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11489 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11491 | err = |
| 11492 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11493 | ASSERT_VK_SUCCESS(err); |
| 11494 | |
| 11495 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11496 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11497 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11498 | memAlloc.pNext = NULL; |
| 11499 | memAlloc.allocationSize = 0; |
| 11500 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11501 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11502 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11503 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11504 | pass = |
| 11505 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11506 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11507 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11508 | ASSERT_VK_SUCCESS(err); |
| 11509 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11510 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11511 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11512 | pass = |
| 11513 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11514 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11515 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11516 | ASSERT_VK_SUCCESS(err); |
| 11517 | |
| 11518 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11519 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11520 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11521 | ASSERT_VK_SUCCESS(err); |
| 11522 | |
| 11523 | BeginCommandBuffer(); |
| 11524 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11525 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11526 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11527 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11528 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11529 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11530 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11531 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11532 | resolveRegion.srcOffset.x = 0; |
| 11533 | resolveRegion.srcOffset.y = 0; |
| 11534 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11535 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11536 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11537 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11538 | resolveRegion.dstSubresource.layerCount = 0; |
| 11539 | resolveRegion.dstOffset.x = 0; |
| 11540 | resolveRegion.dstOffset.y = 0; |
| 11541 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11542 | resolveRegion.extent.width = 1; |
| 11543 | resolveRegion.extent.height = 1; |
| 11544 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11545 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11546 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11547 | EndCommandBuffer(); |
| 11548 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11549 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11550 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11551 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11552 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11553 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11554 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11555 | } |
| 11556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11557 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11558 | VkResult err; |
| 11559 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11561 | m_errorMonitor->SetDesiredFailureMsg( |
| 11562 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11563 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11564 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11565 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11566 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11567 | // 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] | 11568 | VkImage srcImage; |
| 11569 | VkImage dstImage; |
| 11570 | VkDeviceMemory srcMem; |
| 11571 | VkDeviceMemory destMem; |
| 11572 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11573 | |
| 11574 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11575 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11576 | image_create_info.pNext = NULL; |
| 11577 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11578 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11579 | image_create_info.extent.width = 32; |
| 11580 | image_create_info.extent.height = 1; |
| 11581 | image_create_info.extent.depth = 1; |
| 11582 | image_create_info.mipLevels = 1; |
| 11583 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11584 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11585 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11586 | // Note: Some implementations expect color attachment usage for any |
| 11587 | // multisample surface |
| 11588 | image_create_info.usage = |
| 11589 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11590 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11591 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11592 | err = |
| 11593 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11594 | ASSERT_VK_SUCCESS(err); |
| 11595 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11596 | // Note: Some implementations expect color attachment usage for any |
| 11597 | // multisample surface |
| 11598 | image_create_info.usage = |
| 11599 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11601 | err = |
| 11602 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11603 | ASSERT_VK_SUCCESS(err); |
| 11604 | |
| 11605 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11606 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11607 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11608 | memAlloc.pNext = NULL; |
| 11609 | memAlloc.allocationSize = 0; |
| 11610 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11611 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11612 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11613 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11614 | pass = |
| 11615 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11616 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11617 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11618 | ASSERT_VK_SUCCESS(err); |
| 11619 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11620 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11621 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11622 | pass = |
| 11623 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11624 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11625 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11626 | ASSERT_VK_SUCCESS(err); |
| 11627 | |
| 11628 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11629 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11630 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11631 | ASSERT_VK_SUCCESS(err); |
| 11632 | |
| 11633 | BeginCommandBuffer(); |
| 11634 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11635 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11636 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11637 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11638 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11639 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11640 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11641 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11642 | resolveRegion.srcOffset.x = 0; |
| 11643 | resolveRegion.srcOffset.y = 0; |
| 11644 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11645 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11646 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11647 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11648 | resolveRegion.dstSubresource.layerCount = 0; |
| 11649 | resolveRegion.dstOffset.x = 0; |
| 11650 | resolveRegion.dstOffset.y = 0; |
| 11651 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11652 | resolveRegion.extent.width = 1; |
| 11653 | resolveRegion.extent.height = 1; |
| 11654 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11655 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11656 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11657 | EndCommandBuffer(); |
| 11658 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11659 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11660 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11661 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11662 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11663 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11664 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11665 | } |
| 11666 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11667 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11668 | VkResult err; |
| 11669 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11671 | m_errorMonitor->SetDesiredFailureMsg( |
| 11672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11673 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11674 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11675 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11676 | |
| 11677 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11678 | VkImage srcImage; |
| 11679 | VkImage dstImage; |
| 11680 | VkDeviceMemory srcMem; |
| 11681 | VkDeviceMemory destMem; |
| 11682 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11683 | |
| 11684 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11685 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11686 | image_create_info.pNext = NULL; |
| 11687 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11688 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11689 | image_create_info.extent.width = 32; |
| 11690 | image_create_info.extent.height = 1; |
| 11691 | image_create_info.extent.depth = 1; |
| 11692 | image_create_info.mipLevels = 1; |
| 11693 | image_create_info.arrayLayers = 1; |
| 11694 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11695 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11696 | // Note: Some implementations expect color attachment usage for any |
| 11697 | // multisample surface |
| 11698 | image_create_info.usage = |
| 11699 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11700 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11701 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11702 | err = |
| 11703 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11704 | ASSERT_VK_SUCCESS(err); |
| 11705 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11706 | // Set format to something other than source image |
| 11707 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11708 | // Note: Some implementations expect color attachment usage for any |
| 11709 | // multisample surface |
| 11710 | image_create_info.usage = |
| 11711 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11712 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11713 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11714 | err = |
| 11715 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11716 | ASSERT_VK_SUCCESS(err); |
| 11717 | |
| 11718 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11719 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11720 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11721 | memAlloc.pNext = NULL; |
| 11722 | memAlloc.allocationSize = 0; |
| 11723 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11724 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11725 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11726 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11727 | pass = |
| 11728 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11729 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11730 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11731 | ASSERT_VK_SUCCESS(err); |
| 11732 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11733 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11734 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11735 | pass = |
| 11736 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11737 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11738 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11739 | ASSERT_VK_SUCCESS(err); |
| 11740 | |
| 11741 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11742 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11743 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11744 | ASSERT_VK_SUCCESS(err); |
| 11745 | |
| 11746 | BeginCommandBuffer(); |
| 11747 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11748 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11749 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11750 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11751 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11752 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11753 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11754 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11755 | resolveRegion.srcOffset.x = 0; |
| 11756 | resolveRegion.srcOffset.y = 0; |
| 11757 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11758 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11759 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11760 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11761 | resolveRegion.dstSubresource.layerCount = 0; |
| 11762 | resolveRegion.dstOffset.x = 0; |
| 11763 | resolveRegion.dstOffset.y = 0; |
| 11764 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11765 | resolveRegion.extent.width = 1; |
| 11766 | resolveRegion.extent.height = 1; |
| 11767 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11768 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11769 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11770 | EndCommandBuffer(); |
| 11771 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11772 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11773 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11774 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11775 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11776 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11777 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11778 | } |
| 11779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11780 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11781 | VkResult err; |
| 11782 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11784 | m_errorMonitor->SetDesiredFailureMsg( |
| 11785 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11786 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11787 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11788 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11789 | |
| 11790 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11791 | VkImage srcImage; |
| 11792 | VkImage dstImage; |
| 11793 | VkDeviceMemory srcMem; |
| 11794 | VkDeviceMemory destMem; |
| 11795 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11796 | |
| 11797 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11798 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11799 | image_create_info.pNext = NULL; |
| 11800 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11801 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11802 | image_create_info.extent.width = 32; |
| 11803 | image_create_info.extent.height = 1; |
| 11804 | image_create_info.extent.depth = 1; |
| 11805 | image_create_info.mipLevels = 1; |
| 11806 | image_create_info.arrayLayers = 1; |
| 11807 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11808 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11809 | // Note: Some implementations expect color attachment usage for any |
| 11810 | // multisample surface |
| 11811 | image_create_info.usage = |
| 11812 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11813 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11814 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11815 | err = |
| 11816 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11817 | ASSERT_VK_SUCCESS(err); |
| 11818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11819 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11820 | // Note: Some implementations expect color attachment usage for any |
| 11821 | // multisample surface |
| 11822 | image_create_info.usage = |
| 11823 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11824 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11825 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11826 | err = |
| 11827 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11828 | ASSERT_VK_SUCCESS(err); |
| 11829 | |
| 11830 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11831 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11832 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11833 | memAlloc.pNext = NULL; |
| 11834 | memAlloc.allocationSize = 0; |
| 11835 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11836 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11837 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11838 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11839 | pass = |
| 11840 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11841 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11842 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11843 | ASSERT_VK_SUCCESS(err); |
| 11844 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11845 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11846 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11847 | pass = |
| 11848 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11849 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11850 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11851 | ASSERT_VK_SUCCESS(err); |
| 11852 | |
| 11853 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11854 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11855 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11856 | ASSERT_VK_SUCCESS(err); |
| 11857 | |
| 11858 | BeginCommandBuffer(); |
| 11859 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11860 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11861 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11862 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11863 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11864 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11865 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11866 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11867 | resolveRegion.srcOffset.x = 0; |
| 11868 | resolveRegion.srcOffset.y = 0; |
| 11869 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11870 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11871 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11872 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11873 | resolveRegion.dstSubresource.layerCount = 0; |
| 11874 | resolveRegion.dstOffset.x = 0; |
| 11875 | resolveRegion.dstOffset.y = 0; |
| 11876 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11877 | resolveRegion.extent.width = 1; |
| 11878 | resolveRegion.extent.height = 1; |
| 11879 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11880 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11881 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11882 | EndCommandBuffer(); |
| 11883 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11884 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11885 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11886 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11887 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11888 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11889 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11890 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11892 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11893 | // 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] | 11894 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11895 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11896 | // The image format check comes 2nd in validation so we trigger it first, |
| 11897 | // 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] | 11898 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11899 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11900 | m_errorMonitor->SetDesiredFailureMsg( |
| 11901 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11902 | "Combination depth/stencil image formats can have only the "); |
| 11903 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11905 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11906 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11907 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11908 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11909 | |
| 11910 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11911 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11912 | ds_pool_ci.pNext = NULL; |
| 11913 | ds_pool_ci.maxSets = 1; |
| 11914 | ds_pool_ci.poolSizeCount = 1; |
| 11915 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11916 | |
| 11917 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11918 | err = |
| 11919 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11920 | ASSERT_VK_SUCCESS(err); |
| 11921 | |
| 11922 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11923 | dsl_binding.binding = 0; |
| 11924 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11925 | dsl_binding.descriptorCount = 1; |
| 11926 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11927 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11928 | |
| 11929 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11930 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11931 | ds_layout_ci.pNext = NULL; |
| 11932 | ds_layout_ci.bindingCount = 1; |
| 11933 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11934 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11935 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11936 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11937 | ASSERT_VK_SUCCESS(err); |
| 11938 | |
| 11939 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11940 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11941 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11942 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11943 | alloc_info.descriptorPool = ds_pool; |
| 11944 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11945 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11946 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11947 | ASSERT_VK_SUCCESS(err); |
| 11948 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11949 | VkImage image_bad; |
| 11950 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11951 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11952 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11953 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11954 | const int32_t tex_width = 32; |
| 11955 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11956 | |
| 11957 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11958 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11959 | image_create_info.pNext = NULL; |
| 11960 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11961 | image_create_info.format = tex_format_bad; |
| 11962 | image_create_info.extent.width = tex_width; |
| 11963 | image_create_info.extent.height = tex_height; |
| 11964 | image_create_info.extent.depth = 1; |
| 11965 | image_create_info.mipLevels = 1; |
| 11966 | image_create_info.arrayLayers = 1; |
| 11967 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11968 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11969 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11970 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11971 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11973 | err = |
| 11974 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11975 | ASSERT_VK_SUCCESS(err); |
| 11976 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11977 | image_create_info.usage = |
| 11978 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11979 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11980 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11981 | ASSERT_VK_SUCCESS(err); |
| 11982 | |
| 11983 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11984 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11985 | image_view_create_info.image = image_bad; |
| 11986 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11987 | image_view_create_info.format = tex_format_bad; |
| 11988 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11989 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11990 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11991 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11992 | image_view_create_info.subresourceRange.aspectMask = |
| 11993 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11994 | |
| 11995 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11996 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11997 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11998 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11999 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12000 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12001 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 12002 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12003 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 12004 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 12005 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12006 | |
| 12007 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 12008 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 12009 | "ClearDepthStencilImage with a color image."); |
| 12010 | |
| 12011 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 12012 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 12013 | |
| 12014 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 12015 | BeginCommandBuffer(); |
| 12016 | m_commandBuffer->EndRenderPass(); |
| 12017 | |
| 12018 | // Color image |
| 12019 | VkClearColorValue clear_color; |
| 12020 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 12021 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 12022 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 12023 | const int32_t img_width = 32; |
| 12024 | const int32_t img_height = 32; |
| 12025 | VkImageCreateInfo image_create_info = {}; |
| 12026 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 12027 | image_create_info.pNext = NULL; |
| 12028 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12029 | image_create_info.format = color_format; |
| 12030 | image_create_info.extent.width = img_width; |
| 12031 | image_create_info.extent.height = img_height; |
| 12032 | image_create_info.extent.depth = 1; |
| 12033 | image_create_info.mipLevels = 1; |
| 12034 | image_create_info.arrayLayers = 1; |
| 12035 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 12036 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 12037 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 12038 | |
| 12039 | vk_testing::Image color_image; |
| 12040 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 12041 | reqs); |
| 12042 | |
| 12043 | const VkImageSubresourceRange color_range = |
| 12044 | vk_testing::Image::subresource_range(image_create_info, |
| 12045 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 12046 | |
| 12047 | // Depth/Stencil image |
| 12048 | VkClearDepthStencilValue clear_value = {0}; |
| 12049 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 12050 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 12051 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 12052 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 12053 | ds_image_create_info.extent.width = 64; |
| 12054 | ds_image_create_info.extent.height = 64; |
| 12055 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 12056 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 12057 | |
| 12058 | vk_testing::Image ds_image; |
| 12059 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 12060 | reqs); |
| 12061 | |
| 12062 | const VkImageSubresourceRange ds_range = |
| 12063 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 12064 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 12065 | |
| 12066 | m_errorMonitor->SetDesiredFailureMsg( |
| 12067 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12068 | "vkCmdClearColorImage called with depth/stencil image."); |
| 12069 | |
| 12070 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12071 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12072 | &color_range); |
| 12073 | |
| 12074 | m_errorMonitor->VerifyFound(); |
| 12075 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 12076 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12077 | "vkCmdClearColorImage called with " |
| 12078 | "image created without " |
| 12079 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 12080 | |
| 12081 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 12082 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 12083 | &color_range); |
| 12084 | |
| 12085 | m_errorMonitor->VerifyFound(); |
| 12086 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 12087 | // Call CmdClearDepthStencilImage with color image |
| 12088 | m_errorMonitor->SetDesiredFailureMsg( |
| 12089 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 12090 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 12091 | |
| 12092 | vkCmdClearDepthStencilImage( |
| 12093 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 12094 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 12095 | &ds_range); |
| 12096 | |
| 12097 | m_errorMonitor->VerifyFound(); |
| 12098 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12099 | #endif // IMAGE_TESTS |
| 12100 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12101 | int main(int argc, char **argv) { |
| 12102 | int result; |
| 12103 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 12104 | #ifdef ANDROID |
| 12105 | int vulkanSupport = InitVulkan(); |
| 12106 | if (vulkanSupport == 0) |
| 12107 | return 1; |
| 12108 | #endif |
| 12109 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12110 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12111 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12112 | |
| 12113 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 12114 | |
| 12115 | result = RUN_ALL_TESTS(); |
| 12116 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12117 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12118 | return result; |
| 12119 | } |