Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 268 | |
| 269 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 270 | std::vector<const char *> instance_layer_names; |
| 271 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_extension_names; |
| 273 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 275 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 276 | /* |
| 277 | * Since CreateDbgMsgCallback is an instance level extension call |
| 278 | * any extension / layer that utilizes that feature also needs |
| 279 | * to be enabled at create instance time. |
| 280 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 281 | // Use Threading layer first to protect others from |
| 282 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 291 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 297 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 301 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 303 | this->app_info.pApplicationName = "layer_tests"; |
| 304 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 305 | this->app_info.pEngineName = "unittest"; |
| 306 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 307 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 309 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 310 | InitFramework(instance_layer_names, device_layer_names, |
| 311 | instance_extension_names, device_extension_names, |
| 312 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | virtual void TearDown() { |
| 316 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 317 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 318 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | } |
| 320 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 322 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 323 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 325 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * For render test all drawing happens in a single render pass |
| 329 | * on a single command buffer. |
| 330 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 331 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 332 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 338 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 339 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 340 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 341 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 342 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 343 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 345 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 346 | |
| 347 | return result; |
| 348 | } |
| 349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 350 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 351 | const char *fragShaderText, |
| 352 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 353 | // Create identity matrix |
| 354 | int i; |
| 355 | struct vktriangle_vs_uniform data; |
| 356 | |
| 357 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 358 | glm::mat4 View = glm::mat4(1.0f); |
| 359 | glm::mat4 Model = glm::mat4(1.0f); |
| 360 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 362 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 363 | |
| 364 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | static const Vertex tri_data[] = { |
| 367 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 368 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 369 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 370 | }; |
| 371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 372 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 373 | data.position[i][0] = tri_data[i].posX; |
| 374 | data.position[i][1] = tri_data[i].posY; |
| 375 | data.position[i][2] = tri_data[i].posZ; |
| 376 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 377 | data.color[i][0] = tri_data[i].r; |
| 378 | data.color[i][1] = tri_data[i].g; |
| 379 | data.color[i][2] = tri_data[i].b; |
| 380 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 384 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 386 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 387 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 389 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 390 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 391 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 394 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 395 | pipelineobj.AddShader(&vs); |
| 396 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 397 | if (failMask & BsoFailLineWidth) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 399 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 400 | ia_state.sType = |
| 401 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 402 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 403 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 404 | } |
| 405 | if (failMask & BsoFailDepthBias) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 407 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 408 | rs_state.sType = |
| 409 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 410 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 411 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 412 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 413 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 414 | // Viewport and scissors must stay in synch or other errors will occur than |
| 415 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 416 | if (failMask & BsoFailViewport) { |
| 417 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 418 | m_viewports.clear(); |
| 419 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 420 | } |
| 421 | if (failMask & BsoFailScissor) { |
| 422 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 423 | m_scissors.clear(); |
| 424 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 425 | } |
| 426 | if (failMask & BsoFailBlend) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 429 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 430 | att_state.blendEnable = VK_TRUE; |
| 431 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 432 | } |
| 433 | if (failMask & BsoFailDepthBounds) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 435 | } |
| 436 | if (failMask & BsoFailStencilReadMask) { |
| 437 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 438 | } |
| 439 | if (failMask & BsoFailStencilWriteMask) { |
| 440 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 441 | } |
| 442 | if (failMask & BsoFailStencilReference) { |
| 443 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 444 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 445 | |
| 446 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 447 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 448 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 449 | |
| 450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 451 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 452 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 453 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | |
| 455 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 456 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | |
| 458 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 459 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 460 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 461 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | } |
| 463 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 464 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 465 | VkPipelineObj &pipelineobj, |
| 466 | VkDescriptorSetObj &descriptorSet, |
| 467 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 469 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 470 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 471 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 472 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 473 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 476 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 478 | // correctly |
| 479 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 480 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 481 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 482 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 483 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 484 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 485 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | |
| 487 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 488 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 489 | ds_ci.pNext = NULL; |
| 490 | ds_ci.depthTestEnable = VK_FALSE; |
| 491 | ds_ci.depthWriteEnable = VK_TRUE; |
| 492 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 493 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 494 | if (failMask & BsoFailDepthBounds) { |
| 495 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 496 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 497 | ds_ci.stencilTestEnable = VK_TRUE; |
| 498 | ds_ci.front = stencil; |
| 499 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 500 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 501 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 502 | pipelineobj.SetViewport(m_viewports); |
| 503 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 505 | VkResult err = pipelineobj.CreateVKPipeline( |
| 506 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 507 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 508 | commandBuffer->BindPipeline(pipelineobj); |
| 509 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | // ******************************************************************************************************************** |
| 513 | // ******************************************************************************************************************** |
| 514 | // ******************************************************************************************************************** |
| 515 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 516 | #if PARAMETER_VALIDATION_TESTS |
| 517 | TEST_F(VkLayerTest, RequiredParameter) { |
| 518 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 519 | "pointer, array, and array count parameters"); |
| 520 | |
| 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | |
| 523 | m_errorMonitor->SetDesiredFailureMsg( |
| 524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 525 | "required parameter pFeatures specified as NULL"); |
| 526 | // Specify NULL for a pointer to a handle |
| 527 | // Expected to trigger an error with |
| 528 | // parameter_validation::validate_required_pointer |
| 529 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 530 | m_errorMonitor->VerifyFound(); |
| 531 | |
| 532 | m_errorMonitor->SetDesiredFailureMsg( |
| 533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 534 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 535 | // Specify NULL for pointer to array count |
| 536 | // Expected to trigger an error with parameter_validation::validate_array |
| 537 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 538 | m_errorMonitor->VerifyFound(); |
| 539 | |
| 540 | m_errorMonitor->SetDesiredFailureMsg( |
| 541 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 542 | "parameter viewportCount must be greater than 0"); |
| 543 | // Specify 0 for a required array count |
| 544 | // Expected to trigger an error with parameter_validation::validate_array |
| 545 | VkViewport view_port = {}; |
| 546 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 547 | m_errorMonitor->VerifyFound(); |
| 548 | |
| 549 | m_errorMonitor->SetDesiredFailureMsg( |
| 550 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 551 | "required parameter pViewports specified as NULL"); |
| 552 | // Specify NULL for a required array |
| 553 | // Expected to trigger an error with parameter_validation::validate_array |
| 554 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 555 | m_errorMonitor->VerifyFound(); |
| 556 | |
| 557 | m_errorMonitor->SetDesiredFailureMsg( |
| 558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 559 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 560 | // Specify VK_NULL_HANDLE for a required handle |
| 561 | // Expected to trigger an error with |
| 562 | // parameter_validation::validate_required_handle |
| 563 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 564 | m_errorMonitor->VerifyFound(); |
| 565 | |
| 566 | m_errorMonitor->SetDesiredFailureMsg( |
| 567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 568 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 569 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 570 | // Expected to trigger an error with |
| 571 | // parameter_validation::validate_required_handle_array |
| 572 | VkFence fence = VK_NULL_HANDLE; |
| 573 | vkResetFences(device(), 1, &fence); |
| 574 | m_errorMonitor->VerifyFound(); |
| 575 | |
| 576 | m_errorMonitor->SetDesiredFailureMsg( |
| 577 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 578 | "required parameter pAllocateInfo specified as NULL"); |
| 579 | // Specify NULL for a required struct pointer |
| 580 | // Expected to trigger an error with |
| 581 | // parameter_validation::validate_struct_type |
| 582 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 583 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 587 | "value of faceMask must not be 0"); |
| 588 | // Specify 0 for a required VkFlags parameter |
| 589 | // Expected to trigger an error with parameter_validation::validate_flags |
| 590 | m_commandBuffer->SetStencilReference(0, 0); |
| 591 | m_errorMonitor->VerifyFound(); |
| 592 | |
| 593 | m_errorMonitor->SetDesiredFailureMsg( |
| 594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 595 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 596 | // Specify 0 for a required VkFlags array entry |
| 597 | // Expected to trigger an error with |
| 598 | // parameter_validation::validate_flags_array |
| 599 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 600 | VkPipelineStageFlags stageFlags = 0; |
| 601 | VkSubmitInfo submitInfo = {}; |
| 602 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 603 | submitInfo.waitSemaphoreCount = 1; |
| 604 | submitInfo.pWaitSemaphores = &semaphore; |
| 605 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 606 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 607 | m_errorMonitor->VerifyFound(); |
| 608 | } |
| 609 | #endif // PARAMETER_VALIDATION_TESTS |
| 610 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 611 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 612 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 613 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 614 | { |
| 615 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 616 | VkFenceCreateInfo fenceInfo = {}; |
| 617 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 618 | fenceInfo.pNext = NULL; |
| 619 | fenceInfo.flags = 0; |
| 620 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 621 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 622 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 624 | |
| 625 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 626 | vk_testing::Buffer buffer; |
| 627 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 628 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 629 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 630 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 631 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 632 | |
| 633 | testFence.init(*m_device, fenceInfo); |
| 634 | |
| 635 | // Bypass framework since it does the waits automatically |
| 636 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 637 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 638 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 639 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 640 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 641 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 642 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 643 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 644 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 645 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 646 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 647 | |
| 648 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 649 | ASSERT_VK_SUCCESS( err ); |
| 650 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 651 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 652 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 653 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 654 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 655 | } |
| 656 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 657 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 658 | { |
| 659 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 660 | VkFenceCreateInfo fenceInfo = {}; |
| 661 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 662 | fenceInfo.pNext = NULL; |
| 663 | fenceInfo.flags = 0; |
| 664 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 665 | 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] | 666 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 667 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 668 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 669 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 670 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 671 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 672 | 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] | 673 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 674 | |
| 675 | testFence.init(*m_device, fenceInfo); |
| 676 | |
| 677 | // Bypass framework since it does the waits automatically |
| 678 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 679 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 680 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 681 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 682 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 683 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 684 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 685 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 686 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 687 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 688 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 689 | |
| 690 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 691 | ASSERT_VK_SUCCESS( err ); |
| 692 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 693 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 694 | VkCommandBufferBeginInfo info = {}; |
| 695 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 696 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 697 | info.renderPass = VK_NULL_HANDLE; |
| 698 | info.subpass = 0; |
| 699 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 700 | info.occlusionQueryEnable = VK_FALSE; |
| 701 | info.queryFlags = 0; |
| 702 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 703 | |
| 704 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 705 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 706 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 707 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 708 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 709 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 710 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 711 | // This is a positive test. No failures are expected. |
| 712 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 713 | VkResult err; |
| 714 | bool pass; |
| 715 | |
| 716 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 717 | "the buffer, create an image, and bind the same memory to " |
| 718 | "it"); |
| 719 | |
| 720 | m_errorMonitor->ExpectSuccess(); |
| 721 | |
| 722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 723 | |
| 724 | VkBuffer buffer; |
| 725 | VkImage image; |
| 726 | VkDeviceMemory mem; |
| 727 | VkMemoryRequirements mem_reqs; |
| 728 | |
| 729 | VkBufferCreateInfo buf_info = {}; |
| 730 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 731 | buf_info.pNext = NULL; |
| 732 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 733 | buf_info.size = 256; |
| 734 | buf_info.queueFamilyIndexCount = 0; |
| 735 | buf_info.pQueueFamilyIndices = NULL; |
| 736 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 737 | buf_info.flags = 0; |
| 738 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 739 | ASSERT_VK_SUCCESS(err); |
| 740 | |
| 741 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 742 | |
| 743 | VkMemoryAllocateInfo alloc_info = {}; |
| 744 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 745 | alloc_info.pNext = NULL; |
| 746 | alloc_info.memoryTypeIndex = 0; |
| 747 | |
| 748 | // Ensure memory is big enough for both bindings |
| 749 | alloc_info.allocationSize = 0x10000; |
| 750 | |
| 751 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 752 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 753 | if (!pass) { |
| 754 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 755 | return; |
| 756 | } |
| 757 | |
| 758 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 759 | ASSERT_VK_SUCCESS(err); |
| 760 | |
| 761 | uint8_t *pData; |
| 762 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 763 | (void **)&pData); |
| 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 766 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 767 | |
| 768 | vkUnmapMemory(m_device->device(), mem); |
| 769 | |
| 770 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 771 | ASSERT_VK_SUCCESS(err); |
| 772 | |
| 773 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 774 | // memory. In fact, it was never used by the GPU. |
| 775 | // Just be be sure, wait for idle. |
| 776 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 777 | vkDeviceWaitIdle(m_device->device()); |
| 778 | |
| 779 | VkImageCreateInfo image_create_info = {}; |
| 780 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 781 | image_create_info.pNext = NULL; |
| 782 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 783 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 784 | image_create_info.extent.width = 64; |
| 785 | image_create_info.extent.height = 64; |
| 786 | image_create_info.extent.depth = 1; |
| 787 | image_create_info.mipLevels = 1; |
| 788 | image_create_info.arrayLayers = 1; |
| 789 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 790 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 791 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 792 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 793 | image_create_info.queueFamilyIndexCount = 0; |
| 794 | image_create_info.pQueueFamilyIndices = NULL; |
| 795 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 796 | image_create_info.flags = 0; |
| 797 | |
| 798 | VkMemoryAllocateInfo mem_alloc = {}; |
| 799 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 800 | mem_alloc.pNext = NULL; |
| 801 | mem_alloc.allocationSize = 0; |
| 802 | mem_alloc.memoryTypeIndex = 0; |
| 803 | |
| 804 | /* Create a mappable image. It will be the texture if linear images are ok |
| 805 | * to be textures or it will be the staging image if they are not. |
| 806 | */ |
| 807 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 808 | ASSERT_VK_SUCCESS(err); |
| 809 | |
| 810 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 811 | |
| 812 | mem_alloc.allocationSize = mem_reqs.size; |
| 813 | |
| 814 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 815 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 816 | if (!pass) { |
| 817 | vkDestroyImage(m_device->device(), image, NULL); |
| 818 | return; |
| 819 | } |
| 820 | |
| 821 | // VALDIATION FAILURE: |
| 822 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 823 | ASSERT_VK_SUCCESS(err); |
| 824 | |
| 825 | m_errorMonitor->VerifyNotFound(); |
| 826 | |
| 827 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 828 | vkDestroyImage(m_device->device(), image, NULL); |
| 829 | } |
| 830 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 831 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 832 | VkResult err; |
| 833 | bool pass; |
| 834 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 835 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 836 | // following declaration (which is temporarily being moved below): |
| 837 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 838 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 839 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 840 | uint32_t swapchain_image_count = 0; |
| 841 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 842 | uint32_t image_index = 0; |
| 843 | // VkPresentInfoKHR present_info = {}; |
| 844 | |
| 845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 846 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 847 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 848 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 849 | // Use the functions from the VK_KHR_android_surface extension without |
| 850 | // enabling that extension: |
| 851 | |
| 852 | // Create a surface: |
| 853 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 854 | #if 0 |
| 855 | #endif |
| 856 | m_errorMonitor->SetDesiredFailureMsg( |
| 857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 858 | "extension was not enabled for this"); |
| 859 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 860 | &surface); |
| 861 | pass = (err != VK_SUCCESS); |
| 862 | ASSERT_TRUE(pass); |
| 863 | m_errorMonitor->VerifyFound(); |
| 864 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 865 | |
| 866 | |
| 867 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 868 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 869 | // that extension: |
| 870 | |
| 871 | // Create a surface: |
| 872 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 873 | #if 0 |
| 874 | #endif |
| 875 | m_errorMonitor->SetDesiredFailureMsg( |
| 876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 877 | "extension was not enabled for this"); |
| 878 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 879 | pass = (err != VK_SUCCESS); |
| 880 | ASSERT_TRUE(pass); |
| 881 | m_errorMonitor->VerifyFound(); |
| 882 | |
| 883 | // Tell whether an mir_connection supports presentation: |
| 884 | MirConnection *mir_connection = NULL; |
| 885 | m_errorMonitor->SetDesiredFailureMsg( |
| 886 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 887 | "extension was not enabled for this"); |
| 888 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 889 | visual_id); |
| 890 | m_errorMonitor->VerifyFound(); |
| 891 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 892 | |
| 893 | |
| 894 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 895 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 896 | // enabling that extension: |
| 897 | |
| 898 | // Create a surface: |
| 899 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 900 | #if 0 |
| 901 | #endif |
| 902 | m_errorMonitor->SetDesiredFailureMsg( |
| 903 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 904 | "extension was not enabled for this"); |
| 905 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 906 | &surface); |
| 907 | pass = (err != VK_SUCCESS); |
| 908 | ASSERT_TRUE(pass); |
| 909 | m_errorMonitor->VerifyFound(); |
| 910 | |
| 911 | // Tell whether an wayland_display supports presentation: |
| 912 | struct wl_display wayland_display = {}; |
| 913 | m_errorMonitor->SetDesiredFailureMsg( |
| 914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 915 | "extension was not enabled for this"); |
| 916 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 917 | &wayland_display); |
| 918 | m_errorMonitor->VerifyFound(); |
| 919 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 920 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 921 | |
| 922 | |
| 923 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 924 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 925 | // TO NON-LINUX PLATFORMS: |
| 926 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 927 | // Use the functions from the VK_KHR_win32_surface extension without |
| 928 | // enabling that extension: |
| 929 | |
| 930 | // Create a surface: |
| 931 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 932 | #if 0 |
| 933 | #endif |
| 934 | m_errorMonitor->SetDesiredFailureMsg( |
| 935 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 936 | "extension was not enabled for this"); |
| 937 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 938 | &surface); |
| 939 | pass = (err != VK_SUCCESS); |
| 940 | ASSERT_TRUE(pass); |
| 941 | m_errorMonitor->VerifyFound(); |
| 942 | |
| 943 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 944 | m_errorMonitor->SetDesiredFailureMsg( |
| 945 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 946 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 947 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 948 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 949 | // Set this (for now, until all platforms are supported and tested): |
| 950 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 951 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 952 | |
| 953 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 954 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 955 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 956 | // TO NON-LINUX PLATFORMS: |
| 957 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 958 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 959 | // that extension: |
| 960 | |
| 961 | // Create a surface: |
| 962 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 963 | #if 0 |
| 964 | #endif |
| 965 | m_errorMonitor->SetDesiredFailureMsg( |
| 966 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 967 | "extension was not enabled for this"); |
| 968 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 969 | pass = (err != VK_SUCCESS); |
| 970 | ASSERT_TRUE(pass); |
| 971 | m_errorMonitor->VerifyFound(); |
| 972 | |
| 973 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 974 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 975 | xcb_visualid_t visual_id = 0; |
| 976 | m_errorMonitor->SetDesiredFailureMsg( |
| 977 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 978 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 979 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 980 | visual_id); |
| 981 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 982 | // Set this (for now, until all platforms are supported and tested): |
| 983 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 984 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 985 | |
| 986 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 987 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 988 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 989 | // that extension: |
| 990 | |
| 991 | // Create a surface: |
| 992 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 993 | #if 0 |
| 994 | #endif |
| 995 | m_errorMonitor->SetDesiredFailureMsg( |
| 996 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 997 | "extension was not enabled for this"); |
| 998 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 999 | pass = (err != VK_SUCCESS); |
| 1000 | ASSERT_TRUE(pass); |
| 1001 | m_errorMonitor->VerifyFound(); |
| 1002 | |
| 1003 | // Tell whether an Xlib VisualID supports presentation: |
| 1004 | Display *dpy = NULL; |
| 1005 | VisualID visual = 0; |
| 1006 | m_errorMonitor->SetDesiredFailureMsg( |
| 1007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1008 | "extension was not enabled for this"); |
| 1009 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1010 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1011 | // Set this (for now, until all platforms are supported and tested): |
| 1012 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1013 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1014 | |
| 1015 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1016 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1017 | // that extension: |
| 1018 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1019 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1020 | // Destroy a surface: |
| 1021 | m_errorMonitor->SetDesiredFailureMsg( |
| 1022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1023 | "extension was not enabled for this"); |
| 1024 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1025 | m_errorMonitor->VerifyFound(); |
| 1026 | |
| 1027 | // Check if surface supports presentation: |
| 1028 | VkBool32 supported = false; |
| 1029 | m_errorMonitor->SetDesiredFailureMsg( |
| 1030 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1031 | "extension was not enabled for this"); |
| 1032 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1033 | pass = (err != VK_SUCCESS); |
| 1034 | ASSERT_TRUE(pass); |
| 1035 | m_errorMonitor->VerifyFound(); |
| 1036 | |
| 1037 | // Check surface capabilities: |
| 1038 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1039 | m_errorMonitor->SetDesiredFailureMsg( |
| 1040 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1041 | "extension was not enabled for this"); |
| 1042 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1043 | &capabilities); |
| 1044 | pass = (err != VK_SUCCESS); |
| 1045 | ASSERT_TRUE(pass); |
| 1046 | m_errorMonitor->VerifyFound(); |
| 1047 | |
| 1048 | // Check surface formats: |
| 1049 | uint32_t format_count = 0; |
| 1050 | VkSurfaceFormatKHR *formats = NULL; |
| 1051 | m_errorMonitor->SetDesiredFailureMsg( |
| 1052 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1053 | "extension was not enabled for this"); |
| 1054 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1055 | &format_count, formats); |
| 1056 | pass = (err != VK_SUCCESS); |
| 1057 | ASSERT_TRUE(pass); |
| 1058 | m_errorMonitor->VerifyFound(); |
| 1059 | |
| 1060 | // Check surface present modes: |
| 1061 | uint32_t present_mode_count = 0; |
| 1062 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1063 | m_errorMonitor->SetDesiredFailureMsg( |
| 1064 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1065 | "extension was not enabled for this"); |
| 1066 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1067 | &present_mode_count, present_modes); |
| 1068 | pass = (err != VK_SUCCESS); |
| 1069 | ASSERT_TRUE(pass); |
| 1070 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1071 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1072 | |
| 1073 | |
| 1074 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1075 | // that extension: |
| 1076 | |
| 1077 | // Create a swapchain: |
| 1078 | m_errorMonitor->SetDesiredFailureMsg( |
| 1079 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1080 | "extension was not enabled for this"); |
| 1081 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1082 | swapchain_create_info.pNext = NULL; |
| 1083 | #if 0 |
| 1084 | swapchain_create_info.flags = 0; |
| 1085 | swapchain_create_info.surface = 0; |
| 1086 | swapchain_create_info.minImageCount = 0; |
| 1087 | swapchain_create_info.imageFormat = 0; |
| 1088 | swapchain_create_info.imageColorSpace = 0; |
| 1089 | swapchain_create_info.imageExtent.width = 0; |
| 1090 | swapchain_create_info.imageExtent.height = 0; |
| 1091 | swapchain_create_info.imageArrayLayers = 0; |
| 1092 | swapchain_create_info.imageUsage = 0; |
| 1093 | swapchain_create_info.imageSharingMode = 0; |
| 1094 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1095 | swapchain_create_info.preTransform = 0; |
| 1096 | swapchain_create_info.compositeAlpha = 0; |
| 1097 | swapchain_create_info.presentMode = 0; |
| 1098 | swapchain_create_info.clipped = 0; |
| 1099 | swapchain_create_info.oldSwapchain = NULL; |
| 1100 | #endif |
| 1101 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1102 | NULL, &swapchain); |
| 1103 | pass = (err != VK_SUCCESS); |
| 1104 | ASSERT_TRUE(pass); |
| 1105 | m_errorMonitor->VerifyFound(); |
| 1106 | |
| 1107 | // Get the images from the swapchain: |
| 1108 | m_errorMonitor->SetDesiredFailureMsg( |
| 1109 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1110 | "extension was not enabled for this"); |
| 1111 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1112 | &swapchain_image_count, NULL); |
| 1113 | pass = (err != VK_SUCCESS); |
| 1114 | ASSERT_TRUE(pass); |
| 1115 | m_errorMonitor->VerifyFound(); |
| 1116 | |
| 1117 | // Try to acquire an image: |
| 1118 | m_errorMonitor->SetDesiredFailureMsg( |
| 1119 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1120 | "extension was not enabled for this"); |
| 1121 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1122 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1123 | pass = (err != VK_SUCCESS); |
| 1124 | ASSERT_TRUE(pass); |
| 1125 | m_errorMonitor->VerifyFound(); |
| 1126 | |
| 1127 | // Try to present an image: |
| 1128 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 1129 | // (as opposed to the fake one we created) in order for the layer to |
| 1130 | // lookup the VkDevice used to enable the extension: |
| 1131 | m_errorMonitor->SetDesiredFailureMsg( |
| 1132 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1133 | "extension was not enabled for this"); |
| 1134 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 1135 | present_info.pNext = NULL; |
| 1136 | #if 0 |
| 1137 | #endif |
| 1138 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 1139 | pass = (err != VK_SUCCESS); |
| 1140 | ASSERT_TRUE(pass); |
| 1141 | m_errorMonitor->VerifyFound(); |
| 1142 | #endif |
| 1143 | |
| 1144 | // Destroy the swapchain: |
| 1145 | m_errorMonitor->SetDesiredFailureMsg( |
| 1146 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1147 | "extension was not enabled for this"); |
| 1148 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1149 | m_errorMonitor->VerifyFound(); |
| 1150 | } |
| 1151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1152 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1153 | VkResult err; |
| 1154 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1156 | m_errorMonitor->SetDesiredFailureMsg( |
| 1157 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1158 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1159 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1161 | |
| 1162 | // 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] | 1163 | VkImage image; |
| 1164 | VkDeviceMemory mem; |
| 1165 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1167 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1168 | const int32_t tex_width = 32; |
| 1169 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1170 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1171 | VkImageCreateInfo image_create_info = {}; |
| 1172 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1173 | image_create_info.pNext = NULL; |
| 1174 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1175 | image_create_info.format = tex_format; |
| 1176 | image_create_info.extent.width = tex_width; |
| 1177 | image_create_info.extent.height = tex_height; |
| 1178 | image_create_info.extent.depth = 1; |
| 1179 | image_create_info.mipLevels = 1; |
| 1180 | image_create_info.arrayLayers = 1; |
| 1181 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1182 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1183 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1184 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1185 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1186 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1187 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1188 | mem_alloc.pNext = NULL; |
| 1189 | mem_alloc.allocationSize = 0; |
| 1190 | // Introduce failure, do NOT set memProps to |
| 1191 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1192 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1193 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1194 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1195 | ASSERT_VK_SUCCESS(err); |
| 1196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1197 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1198 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1199 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1200 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1201 | pass = |
| 1202 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1203 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1204 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1205 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1206 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1207 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1208 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1209 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1210 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1211 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1212 | ASSERT_VK_SUCCESS(err); |
| 1213 | |
| 1214 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1215 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1216 | ASSERT_VK_SUCCESS(err); |
| 1217 | |
| 1218 | // Map memory as if to initialize the image |
| 1219 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1220 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1221 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1222 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1223 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1224 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1225 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1226 | } |
| 1227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1228 | TEST_F(VkLayerTest, RebindMemory) { |
| 1229 | VkResult err; |
| 1230 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1232 | m_errorMonitor->SetDesiredFailureMsg( |
| 1233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1234 | "which has already been bound to mem object"); |
| 1235 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1237 | |
| 1238 | // 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] | 1239 | VkImage image; |
| 1240 | VkDeviceMemory mem1; |
| 1241 | VkDeviceMemory mem2; |
| 1242 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1244 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1245 | const int32_t tex_width = 32; |
| 1246 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1247 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1248 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1249 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1250 | image_create_info.pNext = NULL; |
| 1251 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1252 | image_create_info.format = tex_format; |
| 1253 | image_create_info.extent.width = tex_width; |
| 1254 | image_create_info.extent.height = tex_height; |
| 1255 | image_create_info.extent.depth = 1; |
| 1256 | image_create_info.mipLevels = 1; |
| 1257 | image_create_info.arrayLayers = 1; |
| 1258 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1259 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1260 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1261 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1262 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1263 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1264 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1265 | mem_alloc.pNext = NULL; |
| 1266 | mem_alloc.allocationSize = 0; |
| 1267 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1268 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1269 | // Introduce failure, do NOT set memProps to |
| 1270 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1271 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1272 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1273 | ASSERT_VK_SUCCESS(err); |
| 1274 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1275 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1276 | |
| 1277 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1278 | pass = |
| 1279 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1280 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1281 | |
| 1282 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1283 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1284 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1285 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1286 | ASSERT_VK_SUCCESS(err); |
| 1287 | |
| 1288 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1289 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1290 | ASSERT_VK_SUCCESS(err); |
| 1291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1292 | // Introduce validation failure, try to bind a different memory object to |
| 1293 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1294 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1296 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1297 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1298 | vkDestroyImage(m_device->device(), image, NULL); |
| 1299 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1300 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1301 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1302 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1303 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1304 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1306 | m_errorMonitor->SetDesiredFailureMsg( |
| 1307 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1308 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1309 | |
| 1310 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1311 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1312 | fenceInfo.pNext = NULL; |
| 1313 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1314 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1316 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1317 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1318 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1319 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1320 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1321 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1322 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1323 | |
| 1324 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1325 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1326 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1327 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1328 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1329 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1330 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1331 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1332 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1333 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1334 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1335 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1336 | |
| 1337 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1338 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1339 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1340 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1341 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1342 | // This is a positive test. We used to expect error in this case but spec now |
| 1343 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1344 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1345 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1346 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1347 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1348 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1349 | fenceInfo.pNext = NULL; |
| 1350 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1352 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1353 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1354 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1355 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1356 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1357 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1358 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1359 | |
| 1360 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1361 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1362 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1363 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1364 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1365 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1366 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1367 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1368 | |
| 1369 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1370 | VkImageObj image(m_device); |
| 1371 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1372 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1373 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1374 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1375 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1376 | VkImageView dsv; |
| 1377 | VkImageViewCreateInfo dsvci = {}; |
| 1378 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1379 | dsvci.image = image.handle(); |
| 1380 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1381 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1382 | dsvci.subresourceRange.layerCount = 1; |
| 1383 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1384 | dsvci.subresourceRange.levelCount = 1; |
| 1385 | dsvci.subresourceRange.aspectMask = |
| 1386 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1387 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1388 | // Create a view with depth / stencil aspect for image with different usage |
| 1389 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1391 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1392 | |
| 1393 | // Initialize buffer with TRANSFER_DST usage |
| 1394 | vk_testing::Buffer buffer; |
| 1395 | VkMemoryPropertyFlags reqs = 0; |
| 1396 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1397 | VkBufferImageCopy region = {}; |
| 1398 | region.bufferRowLength = 128; |
| 1399 | region.bufferImageHeight = 128; |
| 1400 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1401 | region.imageSubresource.layerCount = 1; |
| 1402 | region.imageExtent.height = 16; |
| 1403 | region.imageExtent.width = 16; |
| 1404 | region.imageExtent.depth = 1; |
| 1405 | |
| 1406 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1407 | "Invalid usage flag for buffer "); |
| 1408 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1409 | // TRANSFER_DST |
| 1410 | BeginCommandBuffer(); |
| 1411 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1412 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1413 | 1, ®ion); |
| 1414 | m_errorMonitor->VerifyFound(); |
| 1415 | |
| 1416 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1417 | "Invalid usage flag for image "); |
| 1418 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1419 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1420 | 1, ®ion); |
| 1421 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1422 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1423 | #endif // MEM_TRACKER_TESTS |
| 1424 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1425 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1426 | |
| 1427 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1428 | VkResult err; |
| 1429 | |
| 1430 | TEST_DESCRIPTION( |
| 1431 | "Create a fence and destroy its device without first destroying the fence."); |
| 1432 | |
| 1433 | // Note that we have to create a new device since destroying the |
| 1434 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1435 | // will destroy the errorMonitor. |
| 1436 | |
| 1437 | m_errorMonitor->SetDesiredFailureMsg( |
| 1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1439 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1440 | |
| 1441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1442 | |
| 1443 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1444 | m_device->queue_props; |
| 1445 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1446 | queue_info.reserve(queue_props.size()); |
| 1447 | std::vector<std::vector<float>> queue_priorities; |
| 1448 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1449 | VkDeviceQueueCreateInfo qi = {}; |
| 1450 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1451 | qi.pNext = NULL; |
| 1452 | qi.queueFamilyIndex = i; |
| 1453 | qi.queueCount = queue_props[i].queueCount; |
| 1454 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1455 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1456 | queue_info.push_back(qi); |
| 1457 | } |
| 1458 | |
| 1459 | std::vector<const char *> device_layer_names; |
| 1460 | std::vector<const char *> device_extension_names; |
| 1461 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1462 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1463 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1464 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1465 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1466 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1467 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1468 | |
| 1469 | // The sacrificial device object |
| 1470 | VkDevice testDevice; |
| 1471 | VkDeviceCreateInfo device_create_info = {}; |
| 1472 | auto features = m_device->phy().features(); |
| 1473 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1474 | device_create_info.pNext = NULL; |
| 1475 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1476 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1477 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1478 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1479 | device_create_info.pEnabledFeatures = &features; |
| 1480 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1481 | ASSERT_VK_SUCCESS(err); |
| 1482 | |
| 1483 | VkFence fence; |
| 1484 | VkFenceCreateInfo fence_create_info = {}; |
| 1485 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1486 | fence_create_info.pNext = NULL; |
| 1487 | fence_create_info.flags = 0; |
| 1488 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1489 | ASSERT_VK_SUCCESS(err); |
| 1490 | |
| 1491 | // Induce failure by not calling vkDestroyFence |
| 1492 | vkDestroyDevice(testDevice, NULL); |
| 1493 | m_errorMonitor->VerifyFound(); |
| 1494 | } |
| 1495 | |
| 1496 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1497 | |
| 1498 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1499 | "attempt to delete them from another."); |
| 1500 | |
| 1501 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1502 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1503 | |
| 1504 | VkCommandPool command_pool_one; |
| 1505 | VkCommandPool command_pool_two; |
| 1506 | |
| 1507 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1508 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1509 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1510 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1511 | |
| 1512 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1513 | &command_pool_one); |
| 1514 | |
| 1515 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1516 | &command_pool_two); |
| 1517 | |
| 1518 | VkCommandBuffer command_buffer[9]; |
| 1519 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1520 | command_buffer_allocate_info.sType = |
| 1521 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1522 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1523 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1524 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1525 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1526 | command_buffer); |
| 1527 | |
| 1528 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1529 | &command_buffer[3]); |
| 1530 | |
| 1531 | m_errorMonitor->VerifyFound(); |
| 1532 | |
| 1533 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1534 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1535 | } |
| 1536 | |
| 1537 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1538 | VkResult err; |
| 1539 | |
| 1540 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1541 | "attempt to delete them from another."); |
| 1542 | |
| 1543 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1544 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1545 | |
| 1546 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1547 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1548 | |
| 1549 | VkDescriptorPoolSize ds_type_count = {}; |
| 1550 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1551 | ds_type_count.descriptorCount = 1; |
| 1552 | |
| 1553 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1554 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1555 | ds_pool_ci.pNext = NULL; |
| 1556 | ds_pool_ci.flags = 0; |
| 1557 | ds_pool_ci.maxSets = 1; |
| 1558 | ds_pool_ci.poolSizeCount = 1; |
| 1559 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1560 | |
| 1561 | VkDescriptorPool ds_pool_one; |
| 1562 | err = |
| 1563 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1564 | ASSERT_VK_SUCCESS(err); |
| 1565 | |
| 1566 | // Create a second descriptor pool |
| 1567 | VkDescriptorPool ds_pool_two; |
| 1568 | err = |
| 1569 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1570 | ASSERT_VK_SUCCESS(err); |
| 1571 | |
| 1572 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1573 | dsl_binding.binding = 0; |
| 1574 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1575 | dsl_binding.descriptorCount = 1; |
| 1576 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1577 | dsl_binding.pImmutableSamplers = NULL; |
| 1578 | |
| 1579 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1580 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1581 | ds_layout_ci.pNext = NULL; |
| 1582 | ds_layout_ci.bindingCount = 1; |
| 1583 | ds_layout_ci.pBindings = &dsl_binding; |
| 1584 | |
| 1585 | VkDescriptorSetLayout ds_layout; |
| 1586 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1587 | &ds_layout); |
| 1588 | ASSERT_VK_SUCCESS(err); |
| 1589 | |
| 1590 | VkDescriptorSet descriptorSet; |
| 1591 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1592 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1593 | alloc_info.descriptorSetCount = 1; |
| 1594 | alloc_info.descriptorPool = ds_pool_one; |
| 1595 | alloc_info.pSetLayouts = &ds_layout; |
| 1596 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1597 | &descriptorSet); |
| 1598 | ASSERT_VK_SUCCESS(err); |
| 1599 | |
| 1600 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1601 | |
| 1602 | m_errorMonitor->VerifyFound(); |
| 1603 | |
| 1604 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1605 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1606 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1607 | } |
| 1608 | |
| 1609 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1610 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1611 | "Invalid VkImage Object "); |
| 1612 | |
| 1613 | TEST_DESCRIPTION( |
| 1614 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1615 | |
| 1616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1617 | |
| 1618 | // Pass bogus handle into GetImageMemoryRequirements |
| 1619 | VkMemoryRequirements mem_reqs; |
| 1620 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1621 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1622 | |
| 1623 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1624 | |
| 1625 | m_errorMonitor->VerifyFound(); |
| 1626 | } |
| 1627 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1628 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1629 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1630 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1631 | TEST_DESCRIPTION( |
| 1632 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1633 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1634 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1635 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1636 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1639 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1640 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1641 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1642 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1643 | |
| 1644 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1645 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1646 | ds_pool_ci.pNext = NULL; |
| 1647 | ds_pool_ci.maxSets = 1; |
| 1648 | ds_pool_ci.poolSizeCount = 1; |
| 1649 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1650 | |
| 1651 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1652 | err = |
| 1653 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1654 | ASSERT_VK_SUCCESS(err); |
| 1655 | |
| 1656 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1657 | dsl_binding.binding = 0; |
| 1658 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1659 | dsl_binding.descriptorCount = 1; |
| 1660 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1661 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1662 | |
| 1663 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1664 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1665 | ds_layout_ci.pNext = NULL; |
| 1666 | ds_layout_ci.bindingCount = 1; |
| 1667 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1668 | |
| 1669 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1670 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1671 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1672 | ASSERT_VK_SUCCESS(err); |
| 1673 | |
| 1674 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1675 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1676 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1677 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1678 | alloc_info.descriptorPool = ds_pool; |
| 1679 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1680 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1681 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1682 | ASSERT_VK_SUCCESS(err); |
| 1683 | |
| 1684 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1685 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1686 | pipeline_layout_ci.pNext = NULL; |
| 1687 | pipeline_layout_ci.setLayoutCount = 1; |
| 1688 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1689 | |
| 1690 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1691 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1692 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1693 | ASSERT_VK_SUCCESS(err); |
| 1694 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1695 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1696 | |
| 1697 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1698 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1699 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1700 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1701 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1702 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1703 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1704 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1705 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1706 | } |
| 1707 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1708 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1709 | VkResult err; |
| 1710 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1711 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1712 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1713 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1714 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1716 | |
| 1717 | // 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] | 1718 | VkImage image; |
| 1719 | VkDeviceMemory mem; |
| 1720 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1721 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1722 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1723 | const int32_t tex_width = 32; |
| 1724 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1725 | |
| 1726 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1727 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1728 | image_create_info.pNext = NULL; |
| 1729 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1730 | image_create_info.format = tex_format; |
| 1731 | image_create_info.extent.width = tex_width; |
| 1732 | image_create_info.extent.height = tex_height; |
| 1733 | image_create_info.extent.depth = 1; |
| 1734 | image_create_info.mipLevels = 1; |
| 1735 | image_create_info.arrayLayers = 1; |
| 1736 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1737 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1738 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1739 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1740 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1741 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1742 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1743 | mem_alloc.pNext = NULL; |
| 1744 | mem_alloc.allocationSize = 0; |
| 1745 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1746 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1747 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1748 | ASSERT_VK_SUCCESS(err); |
| 1749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1750 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1751 | |
| 1752 | mem_alloc.allocationSize = mem_reqs.size; |
| 1753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1754 | pass = |
| 1755 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1756 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1757 | |
| 1758 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1759 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1760 | ASSERT_VK_SUCCESS(err); |
| 1761 | |
| 1762 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1763 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1764 | |
| 1765 | // Try to bind free memory that has been freed |
| 1766 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1767 | // This may very well return an error. |
| 1768 | (void)err; |
| 1769 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1770 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1771 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1772 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1773 | } |
| 1774 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1775 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1776 | VkResult err; |
| 1777 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1778 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1779 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1780 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1781 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1784 | // Create an image object, allocate memory, destroy the object and then try |
| 1785 | // to bind it |
| 1786 | VkImage image; |
| 1787 | VkDeviceMemory mem; |
| 1788 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1789 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1790 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1791 | const int32_t tex_width = 32; |
| 1792 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1793 | |
| 1794 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1795 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1796 | image_create_info.pNext = NULL; |
| 1797 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1798 | image_create_info.format = tex_format; |
| 1799 | image_create_info.extent.width = tex_width; |
| 1800 | image_create_info.extent.height = tex_height; |
| 1801 | image_create_info.extent.depth = 1; |
| 1802 | image_create_info.mipLevels = 1; |
| 1803 | image_create_info.arrayLayers = 1; |
| 1804 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1805 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1806 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1807 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1808 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1809 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1810 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1811 | mem_alloc.pNext = NULL; |
| 1812 | mem_alloc.allocationSize = 0; |
| 1813 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1814 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1815 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1816 | ASSERT_VK_SUCCESS(err); |
| 1817 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1818 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1819 | |
| 1820 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1821 | pass = |
| 1822 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1823 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1824 | |
| 1825 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1826 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1827 | ASSERT_VK_SUCCESS(err); |
| 1828 | |
| 1829 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1830 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1831 | ASSERT_VK_SUCCESS(err); |
| 1832 | |
| 1833 | // Now Try to bind memory to this destroyed object |
| 1834 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1835 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1836 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1837 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1838 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1839 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1840 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1841 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1842 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1843 | #endif // OBJ_TRACKER_TESTS |
| 1844 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1845 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1846 | |
| 1847 | // This is a positive test. No errors should be generated. |
| 1848 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1849 | |
| 1850 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1851 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1852 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1853 | if ((m_device->queue_props.empty()) || |
| 1854 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1855 | return; |
| 1856 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1857 | m_errorMonitor->ExpectSuccess(); |
| 1858 | |
| 1859 | VkSemaphore semaphore; |
| 1860 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1861 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1862 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1863 | &semaphore); |
| 1864 | |
| 1865 | VkCommandPool command_pool; |
| 1866 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1867 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1868 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1869 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1870 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1871 | &command_pool); |
| 1872 | |
| 1873 | VkCommandBuffer command_buffer[2]; |
| 1874 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1875 | command_buffer_allocate_info.sType = |
| 1876 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1877 | command_buffer_allocate_info.commandPool = command_pool; |
| 1878 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1879 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1880 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1881 | command_buffer); |
| 1882 | |
| 1883 | VkQueue queue = VK_NULL_HANDLE; |
| 1884 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1885 | 1, &queue); |
| 1886 | |
| 1887 | { |
| 1888 | VkCommandBufferBeginInfo begin_info{}; |
| 1889 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1890 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1891 | |
| 1892 | vkCmdPipelineBarrier(command_buffer[0], |
| 1893 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1894 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1895 | 0, nullptr, 0, nullptr); |
| 1896 | |
| 1897 | VkViewport viewport{}; |
| 1898 | viewport.maxDepth = 1.0f; |
| 1899 | viewport.minDepth = 0.0f; |
| 1900 | viewport.width = 512; |
| 1901 | viewport.height = 512; |
| 1902 | viewport.x = 0; |
| 1903 | viewport.y = 0; |
| 1904 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1905 | vkEndCommandBuffer(command_buffer[0]); |
| 1906 | } |
| 1907 | { |
| 1908 | VkCommandBufferBeginInfo begin_info{}; |
| 1909 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1910 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1911 | |
| 1912 | VkViewport viewport{}; |
| 1913 | viewport.maxDepth = 1.0f; |
| 1914 | viewport.minDepth = 0.0f; |
| 1915 | viewport.width = 512; |
| 1916 | viewport.height = 512; |
| 1917 | viewport.x = 0; |
| 1918 | viewport.y = 0; |
| 1919 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1920 | vkEndCommandBuffer(command_buffer[1]); |
| 1921 | } |
| 1922 | { |
| 1923 | VkSubmitInfo submit_info{}; |
| 1924 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1925 | submit_info.commandBufferCount = 1; |
| 1926 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1927 | submit_info.signalSemaphoreCount = 1; |
| 1928 | submit_info.pSignalSemaphores = &semaphore; |
| 1929 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1930 | } |
| 1931 | { |
| 1932 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1933 | VkSubmitInfo submit_info{}; |
| 1934 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1935 | submit_info.commandBufferCount = 1; |
| 1936 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1937 | submit_info.waitSemaphoreCount = 1; |
| 1938 | submit_info.pWaitSemaphores = &semaphore; |
| 1939 | submit_info.pWaitDstStageMask = flags; |
| 1940 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1941 | } |
| 1942 | |
| 1943 | vkQueueWaitIdle(m_device->m_queue); |
| 1944 | |
| 1945 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1946 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1947 | &command_buffer[0]); |
| 1948 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1949 | |
| 1950 | m_errorMonitor->VerifyNotFound(); |
| 1951 | } |
| 1952 | |
| 1953 | // This is a positive test. No errors should be generated. |
| 1954 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1955 | |
| 1956 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1957 | "submitted on separate queues, the second having a fence" |
| 1958 | "followed by a QueueWaitIdle."); |
| 1959 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1960 | if ((m_device->queue_props.empty()) || |
| 1961 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1962 | return; |
| 1963 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1964 | m_errorMonitor->ExpectSuccess(); |
| 1965 | |
| 1966 | VkFence fence; |
| 1967 | VkFenceCreateInfo fence_create_info{}; |
| 1968 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1969 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1970 | |
| 1971 | VkSemaphore semaphore; |
| 1972 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1973 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1974 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1975 | &semaphore); |
| 1976 | |
| 1977 | VkCommandPool command_pool; |
| 1978 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1979 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1980 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1981 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1982 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1983 | &command_pool); |
| 1984 | |
| 1985 | VkCommandBuffer command_buffer[2]; |
| 1986 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1987 | command_buffer_allocate_info.sType = |
| 1988 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1989 | command_buffer_allocate_info.commandPool = command_pool; |
| 1990 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1991 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1992 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1993 | command_buffer); |
| 1994 | |
| 1995 | VkQueue queue = VK_NULL_HANDLE; |
| 1996 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1997 | 1, &queue); |
| 1998 | |
| 1999 | { |
| 2000 | VkCommandBufferBeginInfo begin_info{}; |
| 2001 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2002 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2003 | |
| 2004 | vkCmdPipelineBarrier(command_buffer[0], |
| 2005 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2006 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2007 | 0, nullptr, 0, nullptr); |
| 2008 | |
| 2009 | VkViewport viewport{}; |
| 2010 | viewport.maxDepth = 1.0f; |
| 2011 | viewport.minDepth = 0.0f; |
| 2012 | viewport.width = 512; |
| 2013 | viewport.height = 512; |
| 2014 | viewport.x = 0; |
| 2015 | viewport.y = 0; |
| 2016 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2017 | vkEndCommandBuffer(command_buffer[0]); |
| 2018 | } |
| 2019 | { |
| 2020 | VkCommandBufferBeginInfo begin_info{}; |
| 2021 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2022 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2023 | |
| 2024 | VkViewport viewport{}; |
| 2025 | viewport.maxDepth = 1.0f; |
| 2026 | viewport.minDepth = 0.0f; |
| 2027 | viewport.width = 512; |
| 2028 | viewport.height = 512; |
| 2029 | viewport.x = 0; |
| 2030 | viewport.y = 0; |
| 2031 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2032 | vkEndCommandBuffer(command_buffer[1]); |
| 2033 | } |
| 2034 | { |
| 2035 | VkSubmitInfo submit_info{}; |
| 2036 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2037 | submit_info.commandBufferCount = 1; |
| 2038 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2039 | submit_info.signalSemaphoreCount = 1; |
| 2040 | submit_info.pSignalSemaphores = &semaphore; |
| 2041 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2042 | } |
| 2043 | { |
| 2044 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2045 | VkSubmitInfo submit_info{}; |
| 2046 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2047 | submit_info.commandBufferCount = 1; |
| 2048 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2049 | submit_info.waitSemaphoreCount = 1; |
| 2050 | submit_info.pWaitSemaphores = &semaphore; |
| 2051 | submit_info.pWaitDstStageMask = flags; |
| 2052 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2053 | } |
| 2054 | |
| 2055 | vkQueueWaitIdle(m_device->m_queue); |
| 2056 | |
| 2057 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2058 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2059 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2060 | &command_buffer[0]); |
| 2061 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2062 | |
| 2063 | m_errorMonitor->VerifyNotFound(); |
| 2064 | } |
| 2065 | |
| 2066 | // This is a positive test. No errors should be generated. |
| 2067 | TEST_F(VkLayerTest, |
| 2068 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2069 | |
| 2070 | TEST_DESCRIPTION( |
| 2071 | "Two command buffers, each in a separate QueueSubmit call " |
| 2072 | "submitted on separate queues, the second having a fence" |
| 2073 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2074 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2075 | if ((m_device->queue_props.empty()) || |
| 2076 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2077 | return; |
| 2078 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2079 | m_errorMonitor->ExpectSuccess(); |
| 2080 | |
| 2081 | VkFence fence; |
| 2082 | VkFenceCreateInfo fence_create_info{}; |
| 2083 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2084 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2085 | |
| 2086 | VkSemaphore semaphore; |
| 2087 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2088 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2089 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2090 | &semaphore); |
| 2091 | |
| 2092 | VkCommandPool command_pool; |
| 2093 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2094 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2095 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2096 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2097 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2098 | &command_pool); |
| 2099 | |
| 2100 | VkCommandBuffer command_buffer[2]; |
| 2101 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2102 | command_buffer_allocate_info.sType = |
| 2103 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2104 | command_buffer_allocate_info.commandPool = command_pool; |
| 2105 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2106 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2107 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2108 | command_buffer); |
| 2109 | |
| 2110 | VkQueue queue = VK_NULL_HANDLE; |
| 2111 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2112 | 1, &queue); |
| 2113 | |
| 2114 | { |
| 2115 | VkCommandBufferBeginInfo begin_info{}; |
| 2116 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2117 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2118 | |
| 2119 | vkCmdPipelineBarrier(command_buffer[0], |
| 2120 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2121 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2122 | 0, nullptr, 0, nullptr); |
| 2123 | |
| 2124 | VkViewport viewport{}; |
| 2125 | viewport.maxDepth = 1.0f; |
| 2126 | viewport.minDepth = 0.0f; |
| 2127 | viewport.width = 512; |
| 2128 | viewport.height = 512; |
| 2129 | viewport.x = 0; |
| 2130 | viewport.y = 0; |
| 2131 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2132 | vkEndCommandBuffer(command_buffer[0]); |
| 2133 | } |
| 2134 | { |
| 2135 | VkCommandBufferBeginInfo begin_info{}; |
| 2136 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2137 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2138 | |
| 2139 | VkViewport viewport{}; |
| 2140 | viewport.maxDepth = 1.0f; |
| 2141 | viewport.minDepth = 0.0f; |
| 2142 | viewport.width = 512; |
| 2143 | viewport.height = 512; |
| 2144 | viewport.x = 0; |
| 2145 | viewport.y = 0; |
| 2146 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2147 | vkEndCommandBuffer(command_buffer[1]); |
| 2148 | } |
| 2149 | { |
| 2150 | VkSubmitInfo submit_info{}; |
| 2151 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2152 | submit_info.commandBufferCount = 1; |
| 2153 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2154 | submit_info.signalSemaphoreCount = 1; |
| 2155 | submit_info.pSignalSemaphores = &semaphore; |
| 2156 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2157 | } |
| 2158 | { |
| 2159 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2160 | VkSubmitInfo submit_info{}; |
| 2161 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2162 | submit_info.commandBufferCount = 1; |
| 2163 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2164 | submit_info.waitSemaphoreCount = 1; |
| 2165 | submit_info.pWaitSemaphores = &semaphore; |
| 2166 | submit_info.pWaitDstStageMask = flags; |
| 2167 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2168 | } |
| 2169 | |
| 2170 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2171 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2172 | |
| 2173 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2174 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2175 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2176 | &command_buffer[0]); |
| 2177 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2178 | |
| 2179 | m_errorMonitor->VerifyNotFound(); |
| 2180 | } |
| 2181 | |
| 2182 | // This is a positive test. No errors should be generated. |
| 2183 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2184 | |
| 2185 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2186 | "submitted on separate queues, the second having a fence, " |
| 2187 | "followed by a WaitForFences call."); |
| 2188 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2189 | if ((m_device->queue_props.empty()) || |
| 2190 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2191 | return; |
| 2192 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2193 | m_errorMonitor->ExpectSuccess(); |
| 2194 | |
| 2195 | VkFence fence; |
| 2196 | VkFenceCreateInfo fence_create_info{}; |
| 2197 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2198 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2199 | |
| 2200 | VkSemaphore semaphore; |
| 2201 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2202 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2203 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2204 | &semaphore); |
| 2205 | |
| 2206 | VkCommandPool command_pool; |
| 2207 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2208 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2209 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2210 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2211 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2212 | &command_pool); |
| 2213 | |
| 2214 | VkCommandBuffer command_buffer[2]; |
| 2215 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2216 | command_buffer_allocate_info.sType = |
| 2217 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2218 | command_buffer_allocate_info.commandPool = command_pool; |
| 2219 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2220 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2221 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2222 | command_buffer); |
| 2223 | |
| 2224 | VkQueue queue = VK_NULL_HANDLE; |
| 2225 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2226 | 1, &queue); |
| 2227 | |
| 2228 | |
| 2229 | { |
| 2230 | VkCommandBufferBeginInfo begin_info{}; |
| 2231 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2232 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2233 | |
| 2234 | vkCmdPipelineBarrier(command_buffer[0], |
| 2235 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2236 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2237 | 0, nullptr, 0, nullptr); |
| 2238 | |
| 2239 | VkViewport viewport{}; |
| 2240 | viewport.maxDepth = 1.0f; |
| 2241 | viewport.minDepth = 0.0f; |
| 2242 | viewport.width = 512; |
| 2243 | viewport.height = 512; |
| 2244 | viewport.x = 0; |
| 2245 | viewport.y = 0; |
| 2246 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2247 | vkEndCommandBuffer(command_buffer[0]); |
| 2248 | } |
| 2249 | { |
| 2250 | VkCommandBufferBeginInfo begin_info{}; |
| 2251 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2252 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2253 | |
| 2254 | VkViewport viewport{}; |
| 2255 | viewport.maxDepth = 1.0f; |
| 2256 | viewport.minDepth = 0.0f; |
| 2257 | viewport.width = 512; |
| 2258 | viewport.height = 512; |
| 2259 | viewport.x = 0; |
| 2260 | viewport.y = 0; |
| 2261 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2262 | vkEndCommandBuffer(command_buffer[1]); |
| 2263 | } |
| 2264 | { |
| 2265 | VkSubmitInfo submit_info{}; |
| 2266 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2267 | submit_info.commandBufferCount = 1; |
| 2268 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2269 | submit_info.signalSemaphoreCount = 1; |
| 2270 | submit_info.pSignalSemaphores = &semaphore; |
| 2271 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2272 | } |
| 2273 | { |
| 2274 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2275 | VkSubmitInfo submit_info{}; |
| 2276 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2277 | submit_info.commandBufferCount = 1; |
| 2278 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2279 | submit_info.waitSemaphoreCount = 1; |
| 2280 | submit_info.pWaitSemaphores = &semaphore; |
| 2281 | submit_info.pWaitDstStageMask = flags; |
| 2282 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2283 | } |
| 2284 | |
| 2285 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2286 | |
| 2287 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2288 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2289 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2290 | &command_buffer[0]); |
| 2291 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2292 | |
| 2293 | m_errorMonitor->VerifyNotFound(); |
| 2294 | } |
| 2295 | |
| 2296 | // This is a positive test. No errors should be generated. |
| 2297 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2298 | |
| 2299 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2300 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2301 | "second having a fence, " |
| 2302 | "followed by a WaitForFences call."); |
| 2303 | |
| 2304 | m_errorMonitor->ExpectSuccess(); |
| 2305 | |
| 2306 | VkFence fence; |
| 2307 | VkFenceCreateInfo fence_create_info{}; |
| 2308 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2309 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2310 | |
| 2311 | VkSemaphore semaphore; |
| 2312 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2313 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2314 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2315 | &semaphore); |
| 2316 | |
| 2317 | VkCommandPool command_pool; |
| 2318 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2319 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2320 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2321 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2322 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2323 | &command_pool); |
| 2324 | |
| 2325 | VkCommandBuffer command_buffer[2]; |
| 2326 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2327 | command_buffer_allocate_info.sType = |
| 2328 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2329 | command_buffer_allocate_info.commandPool = command_pool; |
| 2330 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2331 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2332 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2333 | command_buffer); |
| 2334 | |
| 2335 | { |
| 2336 | VkCommandBufferBeginInfo begin_info{}; |
| 2337 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2338 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2339 | |
| 2340 | vkCmdPipelineBarrier(command_buffer[0], |
| 2341 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2342 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2343 | 0, nullptr, 0, nullptr); |
| 2344 | |
| 2345 | VkViewport viewport{}; |
| 2346 | viewport.maxDepth = 1.0f; |
| 2347 | viewport.minDepth = 0.0f; |
| 2348 | viewport.width = 512; |
| 2349 | viewport.height = 512; |
| 2350 | viewport.x = 0; |
| 2351 | viewport.y = 0; |
| 2352 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2353 | vkEndCommandBuffer(command_buffer[0]); |
| 2354 | } |
| 2355 | { |
| 2356 | VkCommandBufferBeginInfo begin_info{}; |
| 2357 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2358 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2359 | |
| 2360 | VkViewport viewport{}; |
| 2361 | viewport.maxDepth = 1.0f; |
| 2362 | viewport.minDepth = 0.0f; |
| 2363 | viewport.width = 512; |
| 2364 | viewport.height = 512; |
| 2365 | viewport.x = 0; |
| 2366 | viewport.y = 0; |
| 2367 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2368 | vkEndCommandBuffer(command_buffer[1]); |
| 2369 | } |
| 2370 | { |
| 2371 | VkSubmitInfo submit_info{}; |
| 2372 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2373 | submit_info.commandBufferCount = 1; |
| 2374 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2375 | submit_info.signalSemaphoreCount = 1; |
| 2376 | submit_info.pSignalSemaphores = &semaphore; |
| 2377 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2378 | } |
| 2379 | { |
| 2380 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2381 | VkSubmitInfo submit_info{}; |
| 2382 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2383 | submit_info.commandBufferCount = 1; |
| 2384 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2385 | submit_info.waitSemaphoreCount = 1; |
| 2386 | submit_info.pWaitSemaphores = &semaphore; |
| 2387 | submit_info.pWaitDstStageMask = flags; |
| 2388 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2389 | } |
| 2390 | |
| 2391 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2392 | |
| 2393 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2394 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2395 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2396 | &command_buffer[0]); |
| 2397 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2398 | |
| 2399 | m_errorMonitor->VerifyNotFound(); |
| 2400 | } |
| 2401 | |
| 2402 | // This is a positive test. No errors should be generated. |
| 2403 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2404 | |
| 2405 | TEST_DESCRIPTION( |
| 2406 | "Two command buffers, each in a separate QueueSubmit call " |
| 2407 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2408 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2409 | |
| 2410 | m_errorMonitor->ExpectSuccess(); |
| 2411 | |
| 2412 | VkFence fence; |
| 2413 | VkFenceCreateInfo fence_create_info{}; |
| 2414 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2415 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2416 | |
| 2417 | VkCommandPool command_pool; |
| 2418 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2419 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2420 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2421 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2422 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2423 | &command_pool); |
| 2424 | |
| 2425 | VkCommandBuffer command_buffer[2]; |
| 2426 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2427 | command_buffer_allocate_info.sType = |
| 2428 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2429 | command_buffer_allocate_info.commandPool = command_pool; |
| 2430 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2431 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2432 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2433 | command_buffer); |
| 2434 | |
| 2435 | { |
| 2436 | VkCommandBufferBeginInfo begin_info{}; |
| 2437 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2438 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2439 | |
| 2440 | vkCmdPipelineBarrier(command_buffer[0], |
| 2441 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2442 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2443 | 0, nullptr, 0, nullptr); |
| 2444 | |
| 2445 | VkViewport viewport{}; |
| 2446 | viewport.maxDepth = 1.0f; |
| 2447 | viewport.minDepth = 0.0f; |
| 2448 | viewport.width = 512; |
| 2449 | viewport.height = 512; |
| 2450 | viewport.x = 0; |
| 2451 | viewport.y = 0; |
| 2452 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2453 | vkEndCommandBuffer(command_buffer[0]); |
| 2454 | } |
| 2455 | { |
| 2456 | VkCommandBufferBeginInfo begin_info{}; |
| 2457 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2458 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2459 | |
| 2460 | VkViewport viewport{}; |
| 2461 | viewport.maxDepth = 1.0f; |
| 2462 | viewport.minDepth = 0.0f; |
| 2463 | viewport.width = 512; |
| 2464 | viewport.height = 512; |
| 2465 | viewport.x = 0; |
| 2466 | viewport.y = 0; |
| 2467 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2468 | vkEndCommandBuffer(command_buffer[1]); |
| 2469 | } |
| 2470 | { |
| 2471 | VkSubmitInfo submit_info{}; |
| 2472 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2473 | submit_info.commandBufferCount = 1; |
| 2474 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2475 | submit_info.signalSemaphoreCount = 0; |
| 2476 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2477 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2478 | } |
| 2479 | { |
| 2480 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2481 | VkSubmitInfo submit_info{}; |
| 2482 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2483 | submit_info.commandBufferCount = 1; |
| 2484 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2485 | submit_info.waitSemaphoreCount = 0; |
| 2486 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2487 | submit_info.pWaitDstStageMask = flags; |
| 2488 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2489 | } |
| 2490 | |
| 2491 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2492 | |
| 2493 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2494 | |
| 2495 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2496 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2497 | &command_buffer[0]); |
| 2498 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2499 | |
| 2500 | m_errorMonitor->VerifyNotFound(); |
| 2501 | } |
| 2502 | |
| 2503 | // This is a positive test. No errors should be generated. |
| 2504 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2505 | |
| 2506 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2507 | "on the same queue, the second having a fence, followed " |
| 2508 | "by a WaitForFences call."); |
| 2509 | |
| 2510 | m_errorMonitor->ExpectSuccess(); |
| 2511 | |
| 2512 | VkFence fence; |
| 2513 | VkFenceCreateInfo fence_create_info{}; |
| 2514 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2515 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2516 | |
| 2517 | VkCommandPool command_pool; |
| 2518 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2519 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2520 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2521 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2522 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2523 | &command_pool); |
| 2524 | |
| 2525 | VkCommandBuffer command_buffer[2]; |
| 2526 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2527 | command_buffer_allocate_info.sType = |
| 2528 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2529 | command_buffer_allocate_info.commandPool = command_pool; |
| 2530 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2531 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2532 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2533 | command_buffer); |
| 2534 | |
| 2535 | { |
| 2536 | VkCommandBufferBeginInfo begin_info{}; |
| 2537 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2538 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2539 | |
| 2540 | vkCmdPipelineBarrier(command_buffer[0], |
| 2541 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2542 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2543 | 0, nullptr, 0, nullptr); |
| 2544 | |
| 2545 | VkViewport viewport{}; |
| 2546 | viewport.maxDepth = 1.0f; |
| 2547 | viewport.minDepth = 0.0f; |
| 2548 | viewport.width = 512; |
| 2549 | viewport.height = 512; |
| 2550 | viewport.x = 0; |
| 2551 | viewport.y = 0; |
| 2552 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2553 | vkEndCommandBuffer(command_buffer[0]); |
| 2554 | } |
| 2555 | { |
| 2556 | VkCommandBufferBeginInfo begin_info{}; |
| 2557 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2558 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2559 | |
| 2560 | VkViewport viewport{}; |
| 2561 | viewport.maxDepth = 1.0f; |
| 2562 | viewport.minDepth = 0.0f; |
| 2563 | viewport.width = 512; |
| 2564 | viewport.height = 512; |
| 2565 | viewport.x = 0; |
| 2566 | viewport.y = 0; |
| 2567 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2568 | vkEndCommandBuffer(command_buffer[1]); |
| 2569 | } |
| 2570 | { |
| 2571 | VkSubmitInfo submit_info{}; |
| 2572 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2573 | submit_info.commandBufferCount = 1; |
| 2574 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2575 | submit_info.signalSemaphoreCount = 0; |
| 2576 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2577 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2578 | } |
| 2579 | { |
| 2580 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2581 | VkSubmitInfo submit_info{}; |
| 2582 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2583 | submit_info.commandBufferCount = 1; |
| 2584 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2585 | submit_info.waitSemaphoreCount = 0; |
| 2586 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2587 | submit_info.pWaitDstStageMask = flags; |
| 2588 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2589 | } |
| 2590 | |
| 2591 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2592 | |
| 2593 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2594 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2595 | &command_buffer[0]); |
| 2596 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2597 | |
| 2598 | m_errorMonitor->VerifyNotFound(); |
| 2599 | } |
| 2600 | |
| 2601 | // This is a positive test. No errors should be generated. |
| 2602 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2603 | |
| 2604 | TEST_DESCRIPTION( |
| 2605 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2606 | "QueueSubmit call followed by a WaitForFences call."); |
| 2607 | |
| 2608 | m_errorMonitor->ExpectSuccess(); |
| 2609 | |
| 2610 | VkFence fence; |
| 2611 | VkFenceCreateInfo fence_create_info{}; |
| 2612 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2613 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2614 | |
| 2615 | VkSemaphore semaphore; |
| 2616 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2617 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2618 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2619 | &semaphore); |
| 2620 | |
| 2621 | VkCommandPool command_pool; |
| 2622 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2623 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2624 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2625 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2626 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2627 | &command_pool); |
| 2628 | |
| 2629 | VkCommandBuffer command_buffer[2]; |
| 2630 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2631 | command_buffer_allocate_info.sType = |
| 2632 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2633 | command_buffer_allocate_info.commandPool = command_pool; |
| 2634 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2635 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2636 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2637 | command_buffer); |
| 2638 | |
| 2639 | { |
| 2640 | VkCommandBufferBeginInfo begin_info{}; |
| 2641 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2642 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2643 | |
| 2644 | vkCmdPipelineBarrier(command_buffer[0], |
| 2645 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2646 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2647 | 0, nullptr, 0, nullptr); |
| 2648 | |
| 2649 | VkViewport viewport{}; |
| 2650 | viewport.maxDepth = 1.0f; |
| 2651 | viewport.minDepth = 0.0f; |
| 2652 | viewport.width = 512; |
| 2653 | viewport.height = 512; |
| 2654 | viewport.x = 0; |
| 2655 | viewport.y = 0; |
| 2656 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2657 | vkEndCommandBuffer(command_buffer[0]); |
| 2658 | } |
| 2659 | { |
| 2660 | VkCommandBufferBeginInfo begin_info{}; |
| 2661 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2662 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2663 | |
| 2664 | VkViewport viewport{}; |
| 2665 | viewport.maxDepth = 1.0f; |
| 2666 | viewport.minDepth = 0.0f; |
| 2667 | viewport.width = 512; |
| 2668 | viewport.height = 512; |
| 2669 | viewport.x = 0; |
| 2670 | viewport.y = 0; |
| 2671 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2672 | vkEndCommandBuffer(command_buffer[1]); |
| 2673 | } |
| 2674 | { |
| 2675 | VkSubmitInfo submit_info[2]; |
| 2676 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2677 | |
| 2678 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2679 | submit_info[0].pNext = NULL; |
| 2680 | submit_info[0].commandBufferCount = 1; |
| 2681 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2682 | submit_info[0].signalSemaphoreCount = 1; |
| 2683 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2684 | submit_info[0].waitSemaphoreCount = 0; |
| 2685 | submit_info[0].pWaitSemaphores = NULL; |
| 2686 | submit_info[0].pWaitDstStageMask = 0; |
| 2687 | |
| 2688 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2689 | submit_info[1].pNext = NULL; |
| 2690 | submit_info[1].commandBufferCount = 1; |
| 2691 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2692 | submit_info[1].waitSemaphoreCount = 1; |
| 2693 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2694 | submit_info[1].pWaitDstStageMask = flags; |
| 2695 | submit_info[1].signalSemaphoreCount = 0; |
| 2696 | submit_info[1].pSignalSemaphores = NULL; |
| 2697 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2698 | } |
| 2699 | |
| 2700 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2701 | |
| 2702 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2703 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2704 | &command_buffer[0]); |
| 2705 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2706 | |
| 2707 | m_errorMonitor->VerifyNotFound(); |
| 2708 | } |
| 2709 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2710 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2711 | TEST_DESCRIPTION( |
| 2712 | "Run a series of simple draw calls to validate all the different " |
| 2713 | "failure cases that can occur when dynamic state is required but not " |
| 2714 | "correctly bound." |
| 2715 | "Here are the different dynamic state cases verified by this test:\n" |
| 2716 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2717 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2718 | "Mask\n-Stencil Reference"); |
| 2719 | |
| 2720 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2721 | m_errorMonitor->SetDesiredFailureMsg( |
| 2722 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2723 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2725 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2726 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2727 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2728 | m_errorMonitor->SetDesiredFailureMsg( |
| 2729 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2730 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2732 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2733 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2734 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2735 | m_errorMonitor->SetDesiredFailureMsg( |
| 2736 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2737 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2738 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2739 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2740 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2741 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2742 | m_errorMonitor->SetDesiredFailureMsg( |
| 2743 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2744 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2745 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2746 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2747 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2748 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2749 | m_errorMonitor->SetDesiredFailureMsg( |
| 2750 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2751 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2752 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2753 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2754 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2755 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2756 | m_errorMonitor->SetDesiredFailureMsg( |
| 2757 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2758 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2760 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2761 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2762 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2763 | m_errorMonitor->SetDesiredFailureMsg( |
| 2764 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2765 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2766 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2767 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2768 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2769 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2770 | m_errorMonitor->SetDesiredFailureMsg( |
| 2771 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2772 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2773 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2774 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2775 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2776 | } |
| 2777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2778 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2779 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2781 | m_errorMonitor->SetDesiredFailureMsg( |
| 2782 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2783 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2784 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2785 | |
| 2786 | VkFenceCreateInfo fenceInfo = {}; |
| 2787 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2788 | fenceInfo.pNext = NULL; |
| 2789 | fenceInfo.flags = 0; |
| 2790 | |
| 2791 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2792 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2793 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2795 | // We luck out b/c by default the framework creates CB w/ the |
| 2796 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2797 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2799 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2800 | EndCommandBuffer(); |
| 2801 | |
| 2802 | testFence.init(*m_device, fenceInfo); |
| 2803 | |
| 2804 | // Bypass framework since it does the waits automatically |
| 2805 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2806 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2807 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2808 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2809 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2810 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2811 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2812 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2813 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2814 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2815 | submit_info.pSignalSemaphores = NULL; |
| 2816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2817 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2818 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2821 | // submitted once |
| 2822 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2823 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2824 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2825 | } |
| 2826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2827 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2828 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2829 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2830 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2831 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | "Unable to allocate 1 descriptors of " |
| 2833 | "type " |
| 2834 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2835 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2837 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2840 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2841 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2842 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2843 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2844 | |
| 2845 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2846 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2847 | ds_pool_ci.pNext = NULL; |
| 2848 | ds_pool_ci.flags = 0; |
| 2849 | ds_pool_ci.maxSets = 1; |
| 2850 | ds_pool_ci.poolSizeCount = 1; |
| 2851 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2852 | |
| 2853 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2854 | err = |
| 2855 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2856 | ASSERT_VK_SUCCESS(err); |
| 2857 | |
| 2858 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2859 | dsl_binding.binding = 0; |
| 2860 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2861 | dsl_binding.descriptorCount = 1; |
| 2862 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2863 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2864 | |
| 2865 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2866 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2867 | ds_layout_ci.pNext = NULL; |
| 2868 | ds_layout_ci.bindingCount = 1; |
| 2869 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2870 | |
| 2871 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2872 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2873 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2874 | ASSERT_VK_SUCCESS(err); |
| 2875 | |
| 2876 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2877 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2878 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2879 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2880 | alloc_info.descriptorPool = ds_pool; |
| 2881 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2882 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2883 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2884 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2885 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2887 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2888 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2889 | } |
| 2890 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2891 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2892 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2894 | m_errorMonitor->SetDesiredFailureMsg( |
| 2895 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2896 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2897 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2898 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2900 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2901 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2902 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2904 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2905 | |
| 2906 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2907 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2908 | ds_pool_ci.pNext = NULL; |
| 2909 | ds_pool_ci.maxSets = 1; |
| 2910 | ds_pool_ci.poolSizeCount = 1; |
| 2911 | ds_pool_ci.flags = 0; |
| 2912 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2913 | // app can only call vkResetDescriptorPool on this pool.; |
| 2914 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2915 | |
| 2916 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2917 | err = |
| 2918 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2919 | ASSERT_VK_SUCCESS(err); |
| 2920 | |
| 2921 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2922 | dsl_binding.binding = 0; |
| 2923 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2924 | dsl_binding.descriptorCount = 1; |
| 2925 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2926 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2927 | |
| 2928 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2929 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2930 | ds_layout_ci.pNext = NULL; |
| 2931 | ds_layout_ci.bindingCount = 1; |
| 2932 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2933 | |
| 2934 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2935 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2936 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2937 | ASSERT_VK_SUCCESS(err); |
| 2938 | |
| 2939 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2940 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2941 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2942 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2943 | alloc_info.descriptorPool = ds_pool; |
| 2944 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2946 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2947 | ASSERT_VK_SUCCESS(err); |
| 2948 | |
| 2949 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2950 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2951 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2952 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2953 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2954 | } |
| 2955 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2956 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2957 | // Attempt to clear Descriptor Pool with bad object. |
| 2958 | // ObjectTracker should catch this. |
| 2959 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2960 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 2961 | uint64_t fake_pool_handle = 0xbaad6001; |
| 2962 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 2963 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2964 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2965 | } |
| 2966 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2967 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2968 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2969 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2970 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2971 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 2972 | |
| 2973 | uint64_t fake_set_handle = 0xbaad6001; |
| 2974 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2975 | VkResult err; |
| 2976 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2977 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2978 | |
| 2979 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2980 | |
| 2981 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2982 | layout_bindings[0].binding = 0; |
| 2983 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2984 | layout_bindings[0].descriptorCount = 1; |
| 2985 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2986 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2987 | |
| 2988 | VkDescriptorSetLayout descriptor_set_layout; |
| 2989 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2990 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2991 | dslci.pNext = NULL; |
| 2992 | dslci.bindingCount = 1; |
| 2993 | dslci.pBindings = layout_bindings; |
| 2994 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2995 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2996 | |
| 2997 | VkPipelineLayout pipeline_layout; |
| 2998 | VkPipelineLayoutCreateInfo plci = {}; |
| 2999 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3000 | plci.pNext = NULL; |
| 3001 | plci.setLayoutCount = 1; |
| 3002 | plci.pSetLayouts = &descriptor_set_layout; |
| 3003 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3004 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3005 | |
| 3006 | BeginCommandBuffer(); |
| 3007 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3008 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3009 | m_errorMonitor->VerifyFound(); |
| 3010 | EndCommandBuffer(); |
| 3011 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3012 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3013 | } |
| 3014 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3015 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3016 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3017 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3018 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3019 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3020 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3021 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3022 | |
| 3023 | VkPipelineLayout pipeline_layout; |
| 3024 | VkPipelineLayoutCreateInfo plci = {}; |
| 3025 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3026 | plci.pNext = NULL; |
| 3027 | plci.setLayoutCount = 1; |
| 3028 | plci.pSetLayouts = &bad_layout; |
| 3029 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3030 | |
| 3031 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3032 | } |
| 3033 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3034 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3035 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3036 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3037 | // Create a valid cmd buffer |
| 3038 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3039 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3040 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3041 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3042 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3043 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3044 | BeginCommandBuffer(); |
| 3045 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3046 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3047 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3048 | |
| 3049 | // Now issue a draw call with no pipeline bound |
| 3050 | m_errorMonitor->SetDesiredFailureMsg( |
| 3051 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3052 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3054 | BeginCommandBuffer(); |
| 3055 | Draw(1, 0, 0, 0); |
| 3056 | m_errorMonitor->VerifyFound(); |
| 3057 | // Finally same check once more but with Dispatch/Compute |
| 3058 | m_errorMonitor->SetDesiredFailureMsg( |
| 3059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3060 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3061 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3062 | BeginCommandBuffer(); |
| 3063 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3064 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3065 | } |
| 3066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3067 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3068 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3069 | // CommandBuffer |
| 3070 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3071 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3072 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3073 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3074 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3075 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3076 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3077 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3078 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3079 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3080 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3081 | |
| 3082 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3083 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3084 | ds_pool_ci.pNext = NULL; |
| 3085 | ds_pool_ci.maxSets = 1; |
| 3086 | ds_pool_ci.poolSizeCount = 1; |
| 3087 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3088 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3089 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3090 | err = |
| 3091 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3092 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3093 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3094 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3095 | dsl_binding.binding = 0; |
| 3096 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3097 | dsl_binding.descriptorCount = 1; |
| 3098 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3099 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3100 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3101 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3102 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3103 | ds_layout_ci.pNext = NULL; |
| 3104 | ds_layout_ci.bindingCount = 1; |
| 3105 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3106 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3107 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3108 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3109 | ASSERT_VK_SUCCESS(err); |
| 3110 | |
| 3111 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3112 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3113 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3114 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3115 | alloc_info.descriptorPool = ds_pool; |
| 3116 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3117 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3118 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3119 | ASSERT_VK_SUCCESS(err); |
| 3120 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3121 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3122 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3123 | pipeline_layout_ci.pNext = NULL; |
| 3124 | pipeline_layout_ci.setLayoutCount = 1; |
| 3125 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3126 | |
| 3127 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3128 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3129 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3130 | ASSERT_VK_SUCCESS(err); |
| 3131 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3132 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3133 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3134 | // 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] | 3135 | // on more devices |
| 3136 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3137 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3138 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3139 | VkPipelineObj pipe(m_device); |
| 3140 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3141 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3142 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3143 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3144 | |
| 3145 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3146 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3147 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3148 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3149 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3150 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3152 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3153 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3154 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3155 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3156 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3157 | } |
| 3158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3159 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3160 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3161 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3163 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3164 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3165 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3166 | |
| 3167 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3168 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3169 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3170 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3171 | |
| 3172 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3173 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3174 | ds_pool_ci.pNext = NULL; |
| 3175 | ds_pool_ci.maxSets = 1; |
| 3176 | ds_pool_ci.poolSizeCount = 1; |
| 3177 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3178 | |
| 3179 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3180 | err = |
| 3181 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3182 | ASSERT_VK_SUCCESS(err); |
| 3183 | |
| 3184 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3185 | dsl_binding.binding = 0; |
| 3186 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3187 | dsl_binding.descriptorCount = 1; |
| 3188 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3189 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3190 | |
| 3191 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3192 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3193 | ds_layout_ci.pNext = NULL; |
| 3194 | ds_layout_ci.bindingCount = 1; |
| 3195 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3196 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3197 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3198 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3199 | ASSERT_VK_SUCCESS(err); |
| 3200 | |
| 3201 | VkDescriptorSet descriptorSet; |
| 3202 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3203 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3204 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3205 | alloc_info.descriptorPool = ds_pool; |
| 3206 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3207 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3208 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3209 | ASSERT_VK_SUCCESS(err); |
| 3210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3211 | VkBufferView view = |
| 3212 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3213 | VkWriteDescriptorSet descriptor_write; |
| 3214 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3215 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3216 | descriptor_write.dstSet = descriptorSet; |
| 3217 | descriptor_write.dstBinding = 0; |
| 3218 | descriptor_write.descriptorCount = 1; |
| 3219 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3220 | descriptor_write.pTexelBufferView = &view; |
| 3221 | |
| 3222 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3223 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3224 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3225 | |
| 3226 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3227 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3228 | } |
| 3229 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3230 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3231 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3232 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3233 | // 1. No dynamicOffset supplied |
| 3234 | // 2. Too many dynamicOffsets supplied |
| 3235 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3236 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3238 | " requires 1 dynamicOffsets, but only " |
| 3239 | "0 dynamicOffsets are left in " |
| 3240 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3241 | |
| 3242 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3243 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3244 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3245 | |
| 3246 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3247 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3248 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3249 | |
| 3250 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3252 | ds_pool_ci.pNext = NULL; |
| 3253 | ds_pool_ci.maxSets = 1; |
| 3254 | ds_pool_ci.poolSizeCount = 1; |
| 3255 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3256 | |
| 3257 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3258 | err = |
| 3259 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3260 | ASSERT_VK_SUCCESS(err); |
| 3261 | |
| 3262 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3263 | dsl_binding.binding = 0; |
| 3264 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3265 | dsl_binding.descriptorCount = 1; |
| 3266 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3267 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3268 | |
| 3269 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3270 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3271 | ds_layout_ci.pNext = NULL; |
| 3272 | ds_layout_ci.bindingCount = 1; |
| 3273 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3274 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3275 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3276 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3277 | ASSERT_VK_SUCCESS(err); |
| 3278 | |
| 3279 | VkDescriptorSet descriptorSet; |
| 3280 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3281 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3282 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3283 | alloc_info.descriptorPool = ds_pool; |
| 3284 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3285 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3286 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3287 | ASSERT_VK_SUCCESS(err); |
| 3288 | |
| 3289 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3290 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3291 | pipeline_layout_ci.pNext = NULL; |
| 3292 | pipeline_layout_ci.setLayoutCount = 1; |
| 3293 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3294 | |
| 3295 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3296 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3297 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3298 | ASSERT_VK_SUCCESS(err); |
| 3299 | |
| 3300 | // Create a buffer to update the descriptor with |
| 3301 | uint32_t qfi = 0; |
| 3302 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3303 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3304 | buffCI.size = 1024; |
| 3305 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3306 | buffCI.queueFamilyIndexCount = 1; |
| 3307 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3308 | |
| 3309 | VkBuffer dyub; |
| 3310 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3311 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3312 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3313 | // error |
| 3314 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3315 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3316 | mem_alloc.pNext = NULL; |
| 3317 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 3318 | mem_alloc.memoryTypeIndex = 0; |
| 3319 | |
| 3320 | VkMemoryRequirements memReqs; |
| 3321 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 3322 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 3323 | 0); |
| 3324 | if (!pass) { |
| 3325 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3326 | return; |
| 3327 | } |
| 3328 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3329 | VkDeviceMemory mem; |
| 3330 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3333 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3334 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3335 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3336 | buffInfo.buffer = dyub; |
| 3337 | buffInfo.offset = 0; |
| 3338 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3339 | |
| 3340 | VkWriteDescriptorSet descriptor_write; |
| 3341 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3342 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3343 | descriptor_write.dstSet = descriptorSet; |
| 3344 | descriptor_write.dstBinding = 0; |
| 3345 | descriptor_write.descriptorCount = 1; |
| 3346 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3347 | descriptor_write.pBufferInfo = &buffInfo; |
| 3348 | |
| 3349 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3350 | |
| 3351 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3352 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3353 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3354 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3355 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3356 | uint32_t pDynOff[2] = {512, 756}; |
| 3357 | // 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] | 3358 | m_errorMonitor->SetDesiredFailureMsg( |
| 3359 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3360 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3361 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3362 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3363 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3364 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3365 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3366 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3367 | " dynamic offset 512 combined with " |
| 3368 | "offset 0 and range 1024 that " |
| 3369 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3370 | // Create PSO to be used for draw-time errors below |
| 3371 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3372 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3373 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3374 | "out gl_PerVertex { \n" |
| 3375 | " vec4 gl_Position;\n" |
| 3376 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3377 | "void main(){\n" |
| 3378 | " gl_Position = vec4(1);\n" |
| 3379 | "}\n"; |
| 3380 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3381 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3382 | "\n" |
| 3383 | "layout(location=0) out vec4 x;\n" |
| 3384 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3385 | "void main(){\n" |
| 3386 | " x = vec4(bar.y);\n" |
| 3387 | "}\n"; |
| 3388 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3389 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3390 | VkPipelineObj pipe(m_device); |
| 3391 | pipe.AddShader(&vs); |
| 3392 | pipe.AddShader(&fs); |
| 3393 | pipe.AddColorAttachment(); |
| 3394 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3396 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3397 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3398 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3399 | // /w range 1024 & size 1024 |
| 3400 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3401 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3402 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3403 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3404 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3405 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3406 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3407 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3408 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3409 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3410 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3411 | } |
| 3412 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3413 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3414 | // Hit push constant error cases: |
| 3415 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3416 | // 2. Incorrectly set push constant size to 0 |
| 3417 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3418 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3419 | VkResult err; |
| 3420 | m_errorMonitor->SetDesiredFailureMsg( |
| 3421 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3422 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3423 | |
| 3424 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3425 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3426 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3427 | |
| 3428 | VkPushConstantRange pc_range = {}; |
| 3429 | pc_range.size = 0xFFFFFFFFu; |
| 3430 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3431 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3432 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3433 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3434 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3435 | |
| 3436 | VkPipelineLayout pipeline_layout; |
| 3437 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3438 | &pipeline_layout); |
| 3439 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3440 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3441 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3442 | pc_range.size = 0; |
| 3443 | m_errorMonitor->SetDesiredFailureMsg( |
| 3444 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3445 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3446 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3447 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3448 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3449 | pc_range.size = 1; |
| 3450 | m_errorMonitor->SetDesiredFailureMsg( |
| 3451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3452 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3453 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3454 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3455 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3456 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3457 | m_errorMonitor->SetDesiredFailureMsg( |
| 3458 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3459 | "vkCmdPushConstants() call has push constants with offset "); |
| 3460 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3461 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3462 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3463 | &pipeline_layout); |
| 3464 | ASSERT_VK_SUCCESS(err); |
| 3465 | BeginCommandBuffer(); |
| 3466 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3467 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3468 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3469 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3470 | } |
| 3471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3472 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3473 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3474 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3475 | |
| 3476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3477 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3478 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3479 | |
| 3480 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3481 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3482 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3483 | ds_type_count[0].descriptorCount = 10; |
| 3484 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3485 | ds_type_count[1].descriptorCount = 2; |
| 3486 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3487 | ds_type_count[2].descriptorCount = 2; |
| 3488 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3489 | ds_type_count[3].descriptorCount = 5; |
| 3490 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3491 | // type |
| 3492 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3493 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3494 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3495 | |
| 3496 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3497 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3498 | ds_pool_ci.pNext = NULL; |
| 3499 | ds_pool_ci.maxSets = 5; |
| 3500 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3501 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3502 | |
| 3503 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3504 | err = |
| 3505 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3506 | ASSERT_VK_SUCCESS(err); |
| 3507 | |
| 3508 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3509 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3510 | dsl_binding[0].binding = 0; |
| 3511 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3512 | dsl_binding[0].descriptorCount = 5; |
| 3513 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3514 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3515 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3516 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3517 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3518 | dsl_fs_stage_only.binding = 0; |
| 3519 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3520 | dsl_fs_stage_only.descriptorCount = 5; |
| 3521 | dsl_fs_stage_only.stageFlags = |
| 3522 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3523 | // bind time |
| 3524 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3525 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3527 | ds_layout_ci.pNext = NULL; |
| 3528 | ds_layout_ci.bindingCount = 1; |
| 3529 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3530 | static const uint32_t NUM_LAYOUTS = 4; |
| 3531 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3532 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3533 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3534 | // layout for error case |
| 3535 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3536 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3537 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3538 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3539 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3540 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3541 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3542 | dsl_binding[0].binding = 0; |
| 3543 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3544 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3545 | dsl_binding[1].binding = 1; |
| 3546 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3547 | dsl_binding[1].descriptorCount = 2; |
| 3548 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3549 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3550 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3551 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3552 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3553 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3554 | ASSERT_VK_SUCCESS(err); |
| 3555 | dsl_binding[0].binding = 0; |
| 3556 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3557 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3558 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3559 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3560 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3561 | ASSERT_VK_SUCCESS(err); |
| 3562 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3563 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3565 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3566 | ASSERT_VK_SUCCESS(err); |
| 3567 | |
| 3568 | static const uint32_t NUM_SETS = 4; |
| 3569 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3570 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3571 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3572 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3573 | alloc_info.descriptorPool = ds_pool; |
| 3574 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3575 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3576 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3577 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3578 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3579 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3580 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3581 | err = |
| 3582 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3583 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3584 | |
| 3585 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3586 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3587 | pipeline_layout_ci.pNext = NULL; |
| 3588 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3589 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3590 | |
| 3591 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3592 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3593 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3594 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3595 | // Create pipelineLayout with only one setLayout |
| 3596 | pipeline_layout_ci.setLayoutCount = 1; |
| 3597 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3598 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3599 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3600 | ASSERT_VK_SUCCESS(err); |
| 3601 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3602 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3603 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3604 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3605 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3606 | ASSERT_VK_SUCCESS(err); |
| 3607 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3608 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3609 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3610 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3611 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3612 | ASSERT_VK_SUCCESS(err); |
| 3613 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3614 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3615 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3617 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3618 | ASSERT_VK_SUCCESS(err); |
| 3619 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3620 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3621 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3622 | pl_bad_s0[1] = ds_layout[1]; |
| 3623 | pipeline_layout_ci.setLayoutCount = 2; |
| 3624 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3625 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3626 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3627 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3628 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3629 | |
| 3630 | // Create a buffer to update the descriptor with |
| 3631 | uint32_t qfi = 0; |
| 3632 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3633 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3634 | buffCI.size = 1024; |
| 3635 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3636 | buffCI.queueFamilyIndexCount = 1; |
| 3637 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3638 | |
| 3639 | VkBuffer dyub; |
| 3640 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3641 | ASSERT_VK_SUCCESS(err); |
| 3642 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3643 | static const uint32_t NUM_BUFFS = 5; |
| 3644 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3645 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3646 | buffInfo[i].buffer = dyub; |
| 3647 | buffInfo[i].offset = 0; |
| 3648 | buffInfo[i].range = 1024; |
| 3649 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3650 | VkImage image; |
| 3651 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3652 | const int32_t tex_width = 32; |
| 3653 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3654 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3655 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3656 | image_create_info.pNext = NULL; |
| 3657 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3658 | image_create_info.format = tex_format; |
| 3659 | image_create_info.extent.width = tex_width; |
| 3660 | image_create_info.extent.height = tex_height; |
| 3661 | image_create_info.extent.depth = 1; |
| 3662 | image_create_info.mipLevels = 1; |
| 3663 | image_create_info.arrayLayers = 1; |
| 3664 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3665 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3666 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3667 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3668 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3669 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3671 | VkMemoryRequirements memReqs; |
| 3672 | VkDeviceMemory imageMem; |
| 3673 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3674 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3675 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3676 | memAlloc.pNext = NULL; |
| 3677 | memAlloc.allocationSize = 0; |
| 3678 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3679 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3680 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3681 | pass = |
| 3682 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3683 | ASSERT_TRUE(pass); |
| 3684 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3685 | ASSERT_VK_SUCCESS(err); |
| 3686 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3687 | ASSERT_VK_SUCCESS(err); |
| 3688 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3689 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3690 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3691 | image_view_create_info.image = image; |
| 3692 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3693 | image_view_create_info.format = tex_format; |
| 3694 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3695 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3696 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3697 | image_view_create_info.subresourceRange.aspectMask = |
| 3698 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3699 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3700 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3701 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3702 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3703 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3704 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3705 | imageInfo[0].imageView = view; |
| 3706 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3707 | imageInfo[1].imageView = view; |
| 3708 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3709 | imageInfo[2].imageView = view; |
| 3710 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3711 | imageInfo[3].imageView = view; |
| 3712 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3713 | |
| 3714 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3715 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3716 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3717 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3718 | descriptor_write[0].dstBinding = 0; |
| 3719 | descriptor_write[0].descriptorCount = 5; |
| 3720 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3721 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3722 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3723 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3724 | descriptor_write[1].dstBinding = 0; |
| 3725 | descriptor_write[1].descriptorCount = 2; |
| 3726 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3727 | descriptor_write[1].pImageInfo = imageInfo; |
| 3728 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3729 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3730 | descriptor_write[2].dstBinding = 1; |
| 3731 | descriptor_write[2].descriptorCount = 2; |
| 3732 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3733 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3734 | |
| 3735 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3736 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3737 | // Create PSO to be used for draw-time errors below |
| 3738 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3739 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3740 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3741 | "out gl_PerVertex {\n" |
| 3742 | " vec4 gl_Position;\n" |
| 3743 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3744 | "void main(){\n" |
| 3745 | " gl_Position = vec4(1);\n" |
| 3746 | "}\n"; |
| 3747 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3748 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3749 | "\n" |
| 3750 | "layout(location=0) out vec4 x;\n" |
| 3751 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3752 | "void main(){\n" |
| 3753 | " x = vec4(bar.y);\n" |
| 3754 | "}\n"; |
| 3755 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3756 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3757 | VkPipelineObj pipe(m_device); |
| 3758 | pipe.AddShader(&vs); |
| 3759 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3760 | pipe.AddColorAttachment(); |
| 3761 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3762 | |
| 3763 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3764 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3765 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3766 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3767 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3768 | // of PSO |
| 3769 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3770 | // cmd_pipeline.c |
| 3771 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3772 | // cmd_bind_graphics_pipeline() |
| 3773 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3774 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3775 | // First cause various verify_layout_compatibility() fails |
| 3776 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3777 | // verify_set_layout_compatibility fail cases: |
| 3778 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3779 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3780 | " due to: invalid VkPipelineLayout "); |
| 3781 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3782 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3783 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3784 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3785 | m_errorMonitor->VerifyFound(); |
| 3786 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3787 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3788 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3789 | " attempting to bind set to index 1"); |
| 3790 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3791 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3792 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3793 | m_errorMonitor->VerifyFound(); |
| 3794 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3795 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3796 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3797 | // descriptors |
| 3798 | m_errorMonitor->SetDesiredFailureMsg( |
| 3799 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3800 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3801 | vkCmdBindDescriptorSets( |
| 3802 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3803 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3804 | m_errorMonitor->VerifyFound(); |
| 3805 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3806 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3807 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3808 | m_errorMonitor->SetDesiredFailureMsg( |
| 3809 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3810 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3811 | vkCmdBindDescriptorSets( |
| 3812 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3813 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3814 | m_errorMonitor->VerifyFound(); |
| 3815 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3816 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3817 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3818 | m_errorMonitor->SetDesiredFailureMsg( |
| 3819 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3820 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3821 | vkCmdBindDescriptorSets( |
| 3822 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3823 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3824 | m_errorMonitor->VerifyFound(); |
| 3825 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3826 | // Cause INFO messages due to disturbing previously bound Sets |
| 3827 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3828 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3829 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3830 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3831 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3832 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3833 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3834 | " previously bound as set #0 was disturbed "); |
| 3835 | vkCmdBindDescriptorSets( |
| 3836 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3837 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3838 | m_errorMonitor->VerifyFound(); |
| 3839 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3840 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3841 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3842 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3843 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3844 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3845 | " newly bound as set #0 so set #1 and " |
| 3846 | "any subsequent sets were disturbed "); |
| 3847 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3848 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3849 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3850 | m_errorMonitor->VerifyFound(); |
| 3851 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3852 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3853 | // 1. Error due to not binding required set (we actually use same code as |
| 3854 | // above to disturb set0) |
| 3855 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3856 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3857 | 2, &descriptorSet[0], 0, NULL); |
| 3858 | vkCmdBindDescriptorSets( |
| 3859 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3860 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3861 | m_errorMonitor->SetDesiredFailureMsg( |
| 3862 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3863 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3864 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3865 | m_errorMonitor->VerifyFound(); |
| 3866 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3867 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3868 | // 2. Error due to bound set not being compatible with PSO's |
| 3869 | // VkPipelineLayout (diff stageFlags in this case) |
| 3870 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3871 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3872 | 2, &descriptorSet[0], 0, NULL); |
| 3873 | m_errorMonitor->SetDesiredFailureMsg( |
| 3874 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3875 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3876 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3877 | m_errorMonitor->VerifyFound(); |
| 3878 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3879 | // Remaining clean-up |
| 3880 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3881 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3882 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3883 | } |
| 3884 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 3885 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 3886 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3887 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3888 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3889 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3890 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3892 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3894 | m_errorMonitor->SetDesiredFailureMsg( |
| 3895 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3896 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3897 | |
| 3898 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3899 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3900 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3901 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3902 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3903 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3904 | } |
| 3905 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3906 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3907 | VkResult err; |
| 3908 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3909 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3910 | m_errorMonitor->SetDesiredFailureMsg( |
| 3911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3912 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3913 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3914 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3915 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3916 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3917 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3918 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3919 | cmd.commandPool = m_commandPool; |
| 3920 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3921 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3922 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3923 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3924 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3925 | |
| 3926 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3927 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3928 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3929 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3930 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3932 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3933 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3934 | |
| 3935 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3936 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3937 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3938 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3939 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3940 | } |
| 3941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3942 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3943 | // Cause error due to Begin while recording CB |
| 3944 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3945 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3946 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3947 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3949 | |
| 3950 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3951 | |
| 3952 | // Calls AllocateCommandBuffers |
| 3953 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3955 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3956 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3957 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3958 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3959 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3960 | cmd_buf_info.pNext = NULL; |
| 3961 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3962 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3963 | |
| 3964 | // Begin CB to transition to recording state |
| 3965 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3966 | // Can't re-begin. This should trigger error |
| 3967 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3968 | m_errorMonitor->VerifyFound(); |
| 3969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3971 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3972 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3973 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3974 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3975 | m_errorMonitor->VerifyFound(); |
| 3976 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3977 | m_errorMonitor->SetDesiredFailureMsg( |
| 3978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3979 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3980 | // Transition CB to RECORDED state |
| 3981 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3982 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3983 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3984 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3985 | } |
| 3986 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3987 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3988 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3990 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3991 | m_errorMonitor->SetDesiredFailureMsg( |
| 3992 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3993 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3994 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3995 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3996 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3997 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3998 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3999 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4000 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4001 | |
| 4002 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4003 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4004 | ds_pool_ci.pNext = NULL; |
| 4005 | ds_pool_ci.maxSets = 1; |
| 4006 | ds_pool_ci.poolSizeCount = 1; |
| 4007 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4008 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4009 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4010 | err = |
| 4011 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4012 | ASSERT_VK_SUCCESS(err); |
| 4013 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4014 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | dsl_binding.binding = 0; |
| 4016 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4017 | dsl_binding.descriptorCount = 1; |
| 4018 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4019 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4020 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4021 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4022 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4023 | ds_layout_ci.pNext = NULL; |
| 4024 | ds_layout_ci.bindingCount = 1; |
| 4025 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4026 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4027 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4028 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4029 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4030 | ASSERT_VK_SUCCESS(err); |
| 4031 | |
| 4032 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4033 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4034 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4035 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4036 | alloc_info.descriptorPool = ds_pool; |
| 4037 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4038 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4039 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4040 | ASSERT_VK_SUCCESS(err); |
| 4041 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4042 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4043 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4044 | pipeline_layout_ci.setLayoutCount = 1; |
| 4045 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4046 | |
| 4047 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4048 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4049 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4050 | ASSERT_VK_SUCCESS(err); |
| 4051 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4052 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4054 | |
| 4055 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4056 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4057 | vp_state_ci.scissorCount = 1; |
| 4058 | vp_state_ci.pScissors = ≻ |
| 4059 | vp_state_ci.viewportCount = 1; |
| 4060 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4061 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4062 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4063 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4064 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4065 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4066 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4067 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4068 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4069 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4070 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4071 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4072 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4073 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4074 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4076 | gp_ci.layout = pipeline_layout; |
| 4077 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4078 | |
| 4079 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4080 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4081 | pc_ci.initialDataSize = 0; |
| 4082 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4083 | |
| 4084 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4085 | VkPipelineCache pipelineCache; |
| 4086 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4087 | err = |
| 4088 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4089 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4091 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4092 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4093 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4094 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4095 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4096 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4097 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4098 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4099 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4100 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 4101 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 4102 | { |
| 4103 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4104 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4105 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4106 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 4108 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4109 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4110 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4111 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4112 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4113 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4114 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4115 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4116 | |
| 4117 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4118 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4119 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4120 | ds_pool_ci.poolSizeCount = 1; |
| 4121 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4122 | |
| 4123 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | err = vkCreateDescriptorPool(m_device->device(), |
| 4125 | 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] | 4126 | ASSERT_VK_SUCCESS(err); |
| 4127 | |
| 4128 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4129 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4130 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4131 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4132 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4133 | dsl_binding.pImmutableSamplers = NULL; |
| 4134 | |
| 4135 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4136 | ds_layout_ci.sType = |
| 4137 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4138 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4139 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4140 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4141 | |
| 4142 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4143 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4144 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4145 | ASSERT_VK_SUCCESS(err); |
| 4146 | |
| 4147 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4148 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4149 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4150 | ASSERT_VK_SUCCESS(err); |
| 4151 | |
| 4152 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4153 | pipeline_layout_ci.sType = |
| 4154 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4155 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4156 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4157 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4158 | |
| 4159 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4160 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4161 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4162 | ASSERT_VK_SUCCESS(err); |
| 4163 | |
| 4164 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4165 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4168 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4169 | // 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] | 4170 | VkShaderObj |
| 4171 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4172 | this); |
| 4173 | VkShaderObj |
| 4174 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4175 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4177 | shaderStages[0].sType = |
| 4178 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4179 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4180 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4181 | shaderStages[1].sType = |
| 4182 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4183 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4184 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4185 | shaderStages[2].sType = |
| 4186 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4187 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4188 | shaderStages[2].shader = te.handle(); |
| 4189 | |
| 4190 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4191 | iaCI.sType = |
| 4192 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4193 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4194 | |
| 4195 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4196 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4197 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4198 | |
| 4199 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4200 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4201 | gp_ci.pNext = NULL; |
| 4202 | gp_ci.stageCount = 3; |
| 4203 | gp_ci.pStages = shaderStages; |
| 4204 | gp_ci.pVertexInputState = NULL; |
| 4205 | gp_ci.pInputAssemblyState = &iaCI; |
| 4206 | gp_ci.pTessellationState = &tsCI; |
| 4207 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4208 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4209 | gp_ci.pMultisampleState = NULL; |
| 4210 | gp_ci.pDepthStencilState = NULL; |
| 4211 | gp_ci.pColorBlendState = NULL; |
| 4212 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4213 | gp_ci.layout = pipeline_layout; |
| 4214 | gp_ci.renderPass = renderPass(); |
| 4215 | |
| 4216 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4217 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4218 | pc_ci.pNext = NULL; |
| 4219 | pc_ci.initialSize = 0; |
| 4220 | pc_ci.initialData = 0; |
| 4221 | pc_ci.maxSize = 0; |
| 4222 | |
| 4223 | VkPipeline pipeline; |
| 4224 | VkPipelineCache pipelineCache; |
| 4225 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4226 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4227 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4228 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4229 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4230 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4231 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4232 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4233 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4234 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4235 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4236 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4237 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4238 | } |
| 4239 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4240 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4242 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4244 | m_errorMonitor->SetDesiredFailureMsg( |
| 4245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4246 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4247 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4248 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4249 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4250 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4251 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4252 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4253 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4254 | |
| 4255 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4256 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4257 | ds_pool_ci.maxSets = 1; |
| 4258 | ds_pool_ci.poolSizeCount = 1; |
| 4259 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4260 | |
| 4261 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4262 | err = |
| 4263 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4264 | ASSERT_VK_SUCCESS(err); |
| 4265 | |
| 4266 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4267 | dsl_binding.binding = 0; |
| 4268 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4269 | dsl_binding.descriptorCount = 1; |
| 4270 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4271 | |
| 4272 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4274 | ds_layout_ci.bindingCount = 1; |
| 4275 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4276 | |
| 4277 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4278 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4279 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4280 | ASSERT_VK_SUCCESS(err); |
| 4281 | |
| 4282 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4283 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4284 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4285 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4286 | alloc_info.descriptorPool = ds_pool; |
| 4287 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4288 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4289 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4290 | ASSERT_VK_SUCCESS(err); |
| 4291 | |
| 4292 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4293 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4294 | pipeline_layout_ci.setLayoutCount = 1; |
| 4295 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4296 | |
| 4297 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4298 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4299 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4300 | ASSERT_VK_SUCCESS(err); |
| 4301 | |
| 4302 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4303 | |
| 4304 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4305 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4306 | vp_state_ci.scissorCount = 0; |
| 4307 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4308 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4309 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4310 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4311 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4312 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4313 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4314 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4315 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4316 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4317 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4318 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4319 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4320 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4322 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4323 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4324 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4325 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4326 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4328 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4329 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4330 | |
| 4331 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4332 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4333 | gp_ci.stageCount = 2; |
| 4334 | gp_ci.pStages = shaderStages; |
| 4335 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4336 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4338 | gp_ci.layout = pipeline_layout; |
| 4339 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4340 | |
| 4341 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4342 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4343 | |
| 4344 | VkPipeline pipeline; |
| 4345 | VkPipelineCache pipelineCache; |
| 4346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4347 | err = |
| 4348 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4349 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4350 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4351 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4352 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4353 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4354 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4355 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4356 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4357 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4358 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4359 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4361 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4362 | // 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] | 4363 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4364 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4365 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4367 | m_errorMonitor->SetDesiredFailureMsg( |
| 4368 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4369 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4370 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4371 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4372 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4373 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4374 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4375 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4376 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4377 | |
| 4378 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4379 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4380 | ds_pool_ci.maxSets = 1; |
| 4381 | ds_pool_ci.poolSizeCount = 1; |
| 4382 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4383 | |
| 4384 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4385 | err = |
| 4386 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4387 | ASSERT_VK_SUCCESS(err); |
| 4388 | |
| 4389 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | dsl_binding.binding = 0; |
| 4391 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4392 | dsl_binding.descriptorCount = 1; |
| 4393 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4394 | |
| 4395 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4396 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4397 | ds_layout_ci.bindingCount = 1; |
| 4398 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4399 | |
| 4400 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4401 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4402 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4403 | ASSERT_VK_SUCCESS(err); |
| 4404 | |
| 4405 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4406 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4407 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4408 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4409 | alloc_info.descriptorPool = ds_pool; |
| 4410 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4411 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4412 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4413 | ASSERT_VK_SUCCESS(err); |
| 4414 | |
| 4415 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4416 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4417 | pipeline_layout_ci.setLayoutCount = 1; |
| 4418 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4419 | |
| 4420 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4422 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4423 | ASSERT_VK_SUCCESS(err); |
| 4424 | |
| 4425 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4426 | // Set scissor as dynamic to avoid second error |
| 4427 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4428 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4429 | dyn_state_ci.dynamicStateCount = 1; |
| 4430 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4431 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4432 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4433 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4434 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4436 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4437 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4438 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4439 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4440 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4441 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4442 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4443 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4444 | |
| 4445 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4446 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4447 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4448 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4449 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4450 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4451 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4452 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4453 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4454 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4456 | gp_ci.stageCount = 2; |
| 4457 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4458 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4459 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4460 | // should cause validation error |
| 4461 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4462 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4463 | gp_ci.layout = pipeline_layout; |
| 4464 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4465 | |
| 4466 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4467 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4468 | |
| 4469 | VkPipeline pipeline; |
| 4470 | VkPipelineCache pipelineCache; |
| 4471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4472 | err = |
| 4473 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4474 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4475 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4476 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4477 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4478 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4479 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4480 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4481 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4482 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4483 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4484 | } |
| 4485 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4486 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4487 | // count |
| 4488 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4489 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4491 | m_errorMonitor->SetDesiredFailureMsg( |
| 4492 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4493 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4494 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4495 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4496 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4497 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4498 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4499 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4500 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4501 | |
| 4502 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4503 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4504 | ds_pool_ci.maxSets = 1; |
| 4505 | ds_pool_ci.poolSizeCount = 1; |
| 4506 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4507 | |
| 4508 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | err = |
| 4510 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4511 | ASSERT_VK_SUCCESS(err); |
| 4512 | |
| 4513 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4514 | dsl_binding.binding = 0; |
| 4515 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4516 | dsl_binding.descriptorCount = 1; |
| 4517 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4518 | |
| 4519 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4520 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4521 | ds_layout_ci.bindingCount = 1; |
| 4522 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4523 | |
| 4524 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4525 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4526 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4527 | ASSERT_VK_SUCCESS(err); |
| 4528 | |
| 4529 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4530 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4531 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4532 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4533 | alloc_info.descriptorPool = ds_pool; |
| 4534 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4535 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4536 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4537 | ASSERT_VK_SUCCESS(err); |
| 4538 | |
| 4539 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4540 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4541 | pipeline_layout_ci.setLayoutCount = 1; |
| 4542 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4543 | |
| 4544 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4545 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4546 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4547 | ASSERT_VK_SUCCESS(err); |
| 4548 | |
| 4549 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4550 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4551 | vp_state_ci.viewportCount = 1; |
| 4552 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4553 | vp_state_ci.scissorCount = 1; |
| 4554 | vp_state_ci.pScissors = |
| 4555 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4556 | |
| 4557 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4558 | // Set scissor as dynamic to avoid that error |
| 4559 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4560 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4561 | dyn_state_ci.dynamicStateCount = 1; |
| 4562 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4563 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4564 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4565 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4567 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4568 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4569 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4570 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4571 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4572 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4573 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4574 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4575 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4576 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4577 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4578 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4579 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4580 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4581 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4582 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4583 | |
| 4584 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4585 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4586 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4587 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4588 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4589 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4590 | rs_ci.pNext = nullptr; |
| 4591 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4592 | VkPipelineColorBlendAttachmentState att = {}; |
| 4593 | att.blendEnable = VK_FALSE; |
| 4594 | att.colorWriteMask = 0xf; |
| 4595 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4596 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4597 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4598 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4599 | cb_ci.attachmentCount = 1; |
| 4600 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4601 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4602 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4603 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4604 | gp_ci.stageCount = 2; |
| 4605 | gp_ci.pStages = shaderStages; |
| 4606 | gp_ci.pVertexInputState = &vi_ci; |
| 4607 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4608 | gp_ci.pViewportState = &vp_state_ci; |
| 4609 | gp_ci.pRasterizationState = &rs_ci; |
| 4610 | gp_ci.pColorBlendState = &cb_ci; |
| 4611 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4612 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4613 | gp_ci.layout = pipeline_layout; |
| 4614 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4615 | |
| 4616 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4617 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4618 | |
| 4619 | VkPipeline pipeline; |
| 4620 | VkPipelineCache pipelineCache; |
| 4621 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4622 | err = |
| 4623 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4624 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4625 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4626 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4628 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4629 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4630 | // 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] | 4631 | // First need to successfully create the PSO from above by setting |
| 4632 | // pViewports |
| 4633 | m_errorMonitor->SetDesiredFailureMsg( |
| 4634 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4635 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4636 | "scissorCount is 1. These counts must match."); |
| 4637 | |
| 4638 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4639 | vp_state_ci.pViewports = &vp; |
| 4640 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4641 | &gp_ci, NULL, &pipeline); |
| 4642 | ASSERT_VK_SUCCESS(err); |
| 4643 | BeginCommandBuffer(); |
| 4644 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4645 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4646 | VkRect2D scissors[2] = {}; // don't care about data |
| 4647 | // Count of 2 doesn't match PSO count of 1 |
| 4648 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4649 | Draw(1, 0, 0, 0); |
| 4650 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4651 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4652 | |
| 4653 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4654 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4655 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4656 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4657 | } |
| 4658 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4659 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4660 | // viewportCount |
| 4661 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4662 | VkResult err; |
| 4663 | |
| 4664 | m_errorMonitor->SetDesiredFailureMsg( |
| 4665 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4666 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4667 | |
| 4668 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4669 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4670 | |
| 4671 | VkDescriptorPoolSize ds_type_count = {}; |
| 4672 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4673 | ds_type_count.descriptorCount = 1; |
| 4674 | |
| 4675 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4676 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4677 | ds_pool_ci.maxSets = 1; |
| 4678 | ds_pool_ci.poolSizeCount = 1; |
| 4679 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4680 | |
| 4681 | VkDescriptorPool ds_pool; |
| 4682 | err = |
| 4683 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4684 | ASSERT_VK_SUCCESS(err); |
| 4685 | |
| 4686 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4687 | dsl_binding.binding = 0; |
| 4688 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4689 | dsl_binding.descriptorCount = 1; |
| 4690 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4691 | |
| 4692 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4693 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4694 | ds_layout_ci.bindingCount = 1; |
| 4695 | ds_layout_ci.pBindings = &dsl_binding; |
| 4696 | |
| 4697 | VkDescriptorSetLayout ds_layout; |
| 4698 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4699 | &ds_layout); |
| 4700 | ASSERT_VK_SUCCESS(err); |
| 4701 | |
| 4702 | VkDescriptorSet descriptorSet; |
| 4703 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4704 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4705 | alloc_info.descriptorSetCount = 1; |
| 4706 | alloc_info.descriptorPool = ds_pool; |
| 4707 | alloc_info.pSetLayouts = &ds_layout; |
| 4708 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4709 | &descriptorSet); |
| 4710 | ASSERT_VK_SUCCESS(err); |
| 4711 | |
| 4712 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4713 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4714 | pipeline_layout_ci.setLayoutCount = 1; |
| 4715 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4716 | |
| 4717 | VkPipelineLayout pipeline_layout; |
| 4718 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4719 | &pipeline_layout); |
| 4720 | ASSERT_VK_SUCCESS(err); |
| 4721 | |
| 4722 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4723 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4724 | vp_state_ci.scissorCount = 1; |
| 4725 | vp_state_ci.pScissors = |
| 4726 | NULL; // Null scissor w/ count of 1 should cause error |
| 4727 | vp_state_ci.viewportCount = 1; |
| 4728 | vp_state_ci.pViewports = |
| 4729 | NULL; // vp is dynamic (below) so this won't cause error |
| 4730 | |
| 4731 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4732 | // Set scissor as dynamic to avoid that error |
| 4733 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4734 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4735 | dyn_state_ci.dynamicStateCount = 1; |
| 4736 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4737 | |
| 4738 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4739 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4740 | |
| 4741 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4742 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4743 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4744 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4745 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4746 | // but add it to be able to run on more devices |
| 4747 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4748 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4749 | |
| 4750 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4751 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4752 | vi_ci.pNext = nullptr; |
| 4753 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4754 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4755 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4756 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4757 | |
| 4758 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4759 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4760 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4761 | |
| 4762 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4763 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4764 | rs_ci.pNext = nullptr; |
| 4765 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4766 | VkPipelineColorBlendAttachmentState att = {}; |
| 4767 | att.blendEnable = VK_FALSE; |
| 4768 | att.colorWriteMask = 0xf; |
| 4769 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4770 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4771 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4772 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4773 | cb_ci.attachmentCount = 1; |
| 4774 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | |
| 4776 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4777 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4778 | gp_ci.stageCount = 2; |
| 4779 | gp_ci.pStages = shaderStages; |
| 4780 | gp_ci.pVertexInputState = &vi_ci; |
| 4781 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4782 | gp_ci.pViewportState = &vp_state_ci; |
| 4783 | gp_ci.pRasterizationState = &rs_ci; |
| 4784 | gp_ci.pColorBlendState = &cb_ci; |
| 4785 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4786 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4787 | gp_ci.layout = pipeline_layout; |
| 4788 | gp_ci.renderPass = renderPass(); |
| 4789 | |
| 4790 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4791 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4792 | |
| 4793 | VkPipeline pipeline; |
| 4794 | VkPipelineCache pipelineCache; |
| 4795 | |
| 4796 | err = |
| 4797 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4798 | ASSERT_VK_SUCCESS(err); |
| 4799 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4800 | &gp_ci, NULL, &pipeline); |
| 4801 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4802 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4803 | |
| 4804 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4805 | // First need to successfully create the PSO from above by setting |
| 4806 | // pViewports |
| 4807 | m_errorMonitor->SetDesiredFailureMsg( |
| 4808 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4809 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4810 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4811 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4812 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4813 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4814 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4815 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4816 | ASSERT_VK_SUCCESS(err); |
| 4817 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4818 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4819 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4820 | VkViewport viewports[2] = {}; // don't care about data |
| 4821 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4822 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4823 | Draw(1, 0, 0, 0); |
| 4824 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4825 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4826 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4827 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4828 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4829 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4830 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4831 | } |
| 4832 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4833 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4834 | VkResult err; |
| 4835 | |
| 4836 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4837 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4838 | |
| 4839 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4840 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4841 | |
| 4842 | VkDescriptorPoolSize ds_type_count = {}; |
| 4843 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4844 | ds_type_count.descriptorCount = 1; |
| 4845 | |
| 4846 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4847 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4848 | ds_pool_ci.maxSets = 1; |
| 4849 | ds_pool_ci.poolSizeCount = 1; |
| 4850 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4851 | |
| 4852 | VkDescriptorPool ds_pool; |
| 4853 | err = |
| 4854 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4855 | ASSERT_VK_SUCCESS(err); |
| 4856 | |
| 4857 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4858 | dsl_binding.binding = 0; |
| 4859 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4860 | dsl_binding.descriptorCount = 1; |
| 4861 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4862 | |
| 4863 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4864 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4865 | ds_layout_ci.bindingCount = 1; |
| 4866 | ds_layout_ci.pBindings = &dsl_binding; |
| 4867 | |
| 4868 | VkDescriptorSetLayout ds_layout; |
| 4869 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4870 | &ds_layout); |
| 4871 | ASSERT_VK_SUCCESS(err); |
| 4872 | |
| 4873 | VkDescriptorSet descriptorSet; |
| 4874 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4875 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4876 | alloc_info.descriptorSetCount = 1; |
| 4877 | alloc_info.descriptorPool = ds_pool; |
| 4878 | alloc_info.pSetLayouts = &ds_layout; |
| 4879 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4880 | &descriptorSet); |
| 4881 | ASSERT_VK_SUCCESS(err); |
| 4882 | |
| 4883 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4884 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4885 | pipeline_layout_ci.setLayoutCount = 1; |
| 4886 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4887 | |
| 4888 | VkPipelineLayout pipeline_layout; |
| 4889 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4890 | &pipeline_layout); |
| 4891 | ASSERT_VK_SUCCESS(err); |
| 4892 | |
| 4893 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4894 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4895 | vp_state_ci.scissorCount = 1; |
| 4896 | vp_state_ci.pScissors = NULL; |
| 4897 | vp_state_ci.viewportCount = 1; |
| 4898 | vp_state_ci.pViewports = NULL; |
| 4899 | |
| 4900 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4901 | VK_DYNAMIC_STATE_SCISSOR, |
| 4902 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4903 | // Set scissor as dynamic to avoid that error |
| 4904 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4905 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4906 | dyn_state_ci.dynamicStateCount = 2; |
| 4907 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4908 | |
| 4909 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4910 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4911 | |
| 4912 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4913 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4914 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4915 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4916 | this); // TODO - We shouldn't need a fragment shader |
| 4917 | // but add it to be able to run on more devices |
| 4918 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4919 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4920 | |
| 4921 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4922 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4923 | vi_ci.pNext = nullptr; |
| 4924 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4925 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4926 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4927 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4928 | |
| 4929 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4930 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4931 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4932 | |
| 4933 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4934 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4935 | rs_ci.pNext = nullptr; |
| 4936 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4937 | // Check too low (line width of -1.0f). |
| 4938 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4939 | |
| 4940 | VkPipelineColorBlendAttachmentState att = {}; |
| 4941 | att.blendEnable = VK_FALSE; |
| 4942 | att.colorWriteMask = 0xf; |
| 4943 | |
| 4944 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4945 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4946 | cb_ci.pNext = nullptr; |
| 4947 | cb_ci.attachmentCount = 1; |
| 4948 | cb_ci.pAttachments = &att; |
| 4949 | |
| 4950 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4951 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4952 | gp_ci.stageCount = 2; |
| 4953 | gp_ci.pStages = shaderStages; |
| 4954 | gp_ci.pVertexInputState = &vi_ci; |
| 4955 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4956 | gp_ci.pViewportState = &vp_state_ci; |
| 4957 | gp_ci.pRasterizationState = &rs_ci; |
| 4958 | gp_ci.pColorBlendState = &cb_ci; |
| 4959 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4960 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4961 | gp_ci.layout = pipeline_layout; |
| 4962 | gp_ci.renderPass = renderPass(); |
| 4963 | |
| 4964 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4965 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4966 | |
| 4967 | VkPipeline pipeline; |
| 4968 | VkPipelineCache pipelineCache; |
| 4969 | |
| 4970 | err = |
| 4971 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4972 | ASSERT_VK_SUCCESS(err); |
| 4973 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4974 | &gp_ci, NULL, &pipeline); |
| 4975 | |
| 4976 | m_errorMonitor->VerifyFound(); |
| 4977 | |
| 4978 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4979 | "Attempt to set lineWidth to 65536"); |
| 4980 | |
| 4981 | // Check too high (line width of 65536.0f). |
| 4982 | rs_ci.lineWidth = 65536.0f; |
| 4983 | |
| 4984 | err = |
| 4985 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4986 | ASSERT_VK_SUCCESS(err); |
| 4987 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4988 | &gp_ci, NULL, &pipeline); |
| 4989 | |
| 4990 | m_errorMonitor->VerifyFound(); |
| 4991 | |
| 4992 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4993 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4994 | |
| 4995 | dyn_state_ci.dynamicStateCount = 3; |
| 4996 | |
| 4997 | rs_ci.lineWidth = 1.0f; |
| 4998 | |
| 4999 | err = |
| 5000 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5001 | ASSERT_VK_SUCCESS(err); |
| 5002 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5003 | &gp_ci, NULL, &pipeline); |
| 5004 | BeginCommandBuffer(); |
| 5005 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5006 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5007 | |
| 5008 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5009 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5010 | m_errorMonitor->VerifyFound(); |
| 5011 | |
| 5012 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5013 | "Attempt to set lineWidth to 65536"); |
| 5014 | |
| 5015 | // Check too high with dynamic setting. |
| 5016 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 5017 | m_errorMonitor->VerifyFound(); |
| 5018 | EndCommandBuffer(); |
| 5019 | |
| 5020 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5021 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5022 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5023 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5024 | } |
| 5025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5026 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5027 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5028 | m_errorMonitor->SetDesiredFailureMsg( |
| 5029 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5030 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5031 | |
| 5032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5033 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5034 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5035 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5036 | // Don't care about RenderPass handle b/c error should be flagged before |
| 5037 | // that |
| 5038 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 5039 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5040 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5041 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5042 | } |
| 5043 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5044 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5045 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5046 | m_errorMonitor->SetDesiredFailureMsg( |
| 5047 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5048 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5049 | |
| 5050 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5051 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5052 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5053 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5054 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 5055 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5056 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5057 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 5058 | rp_begin.pNext = NULL; |
| 5059 | rp_begin.renderPass = renderPass(); |
| 5060 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5062 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 5063 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5064 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5065 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5066 | } |
| 5067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5068 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5069 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5070 | m_errorMonitor->SetDesiredFailureMsg( |
| 5071 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5072 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5073 | |
| 5074 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5075 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5076 | |
| 5077 | // Renderpass is started here |
| 5078 | BeginCommandBuffer(); |
| 5079 | |
| 5080 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5081 | vk_testing::Buffer dstBuffer; |
| 5082 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5083 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5084 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5085 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5086 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5087 | } |
| 5088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5089 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5090 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5091 | m_errorMonitor->SetDesiredFailureMsg( |
| 5092 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5093 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5094 | |
| 5095 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5096 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5097 | |
| 5098 | // Renderpass is started here |
| 5099 | BeginCommandBuffer(); |
| 5100 | |
| 5101 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5102 | vk_testing::Buffer dstBuffer; |
| 5103 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5105 | VkDeviceSize dstOffset = 0; |
| 5106 | VkDeviceSize dataSize = 1024; |
| 5107 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5108 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5109 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5110 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5111 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5112 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5113 | } |
| 5114 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5115 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5116 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5117 | m_errorMonitor->SetDesiredFailureMsg( |
| 5118 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5119 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5120 | |
| 5121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5122 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5123 | |
| 5124 | // Renderpass is started here |
| 5125 | BeginCommandBuffer(); |
| 5126 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5127 | VkClearColorValue clear_color; |
| 5128 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5129 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5130 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5131 | const int32_t tex_width = 32; |
| 5132 | const int32_t tex_height = 32; |
| 5133 | VkImageCreateInfo image_create_info = {}; |
| 5134 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5135 | image_create_info.pNext = NULL; |
| 5136 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5137 | image_create_info.format = tex_format; |
| 5138 | image_create_info.extent.width = tex_width; |
| 5139 | image_create_info.extent.height = tex_height; |
| 5140 | image_create_info.extent.depth = 1; |
| 5141 | image_create_info.mipLevels = 1; |
| 5142 | image_create_info.arrayLayers = 1; |
| 5143 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5144 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5145 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5146 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5147 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5148 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5149 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5151 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5152 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5154 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5155 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5156 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5157 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5158 | } |
| 5159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5160 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5161 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | m_errorMonitor->SetDesiredFailureMsg( |
| 5163 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5164 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5165 | |
| 5166 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5167 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5168 | |
| 5169 | // Renderpass is started here |
| 5170 | BeginCommandBuffer(); |
| 5171 | |
| 5172 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5173 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5174 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5175 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5176 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5177 | image_create_info.extent.width = 64; |
| 5178 | image_create_info.extent.height = 64; |
| 5179 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5180 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5181 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5182 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5183 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5184 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5185 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5186 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5187 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5189 | vkCmdClearDepthStencilImage( |
| 5190 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5191 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5192 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5193 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5194 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5195 | } |
| 5196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5197 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5198 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5199 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5200 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5201 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5202 | "vkCmdClearAttachments: This call " |
| 5203 | "must be issued inside an active " |
| 5204 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5205 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5206 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5208 | |
| 5209 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5210 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5211 | ASSERT_VK_SUCCESS(err); |
| 5212 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5213 | VkClearAttachment color_attachment; |
| 5214 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5215 | color_attachment.clearValue.color.float32[0] = 0; |
| 5216 | color_attachment.clearValue.color.float32[1] = 0; |
| 5217 | color_attachment.clearValue.color.float32[2] = 0; |
| 5218 | color_attachment.clearValue.color.float32[3] = 0; |
| 5219 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5220 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5221 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5222 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5223 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5224 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5225 | } |
| 5226 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5227 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5228 | // Try to add a buffer memory barrier with no buffer. |
| 5229 | m_errorMonitor->SetDesiredFailureMsg( |
| 5230 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5231 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5232 | |
| 5233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5234 | BeginCommandBuffer(); |
| 5235 | |
| 5236 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5237 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5238 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5239 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5240 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5241 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5242 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5243 | buf_barrier.offset = 0; |
| 5244 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5245 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5246 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5247 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5248 | |
| 5249 | m_errorMonitor->VerifyFound(); |
| 5250 | } |
| 5251 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5252 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5253 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5254 | |
| 5255 | m_errorMonitor->SetDesiredFailureMsg( |
| 5256 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5257 | |
| 5258 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5259 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5260 | |
| 5261 | VkMemoryBarrier mem_barrier = {}; |
| 5262 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5263 | mem_barrier.pNext = NULL; |
| 5264 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5265 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5266 | BeginCommandBuffer(); |
| 5267 | // BeginCommandBuffer() starts a render pass |
| 5268 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5269 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5270 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5271 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5272 | m_errorMonitor->VerifyFound(); |
| 5273 | |
| 5274 | m_errorMonitor->SetDesiredFailureMsg( |
| 5275 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5276 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5277 | VkImageObj image(m_device); |
| 5278 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5279 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5280 | ASSERT_TRUE(image.initialized()); |
| 5281 | VkImageMemoryBarrier img_barrier = {}; |
| 5282 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5283 | img_barrier.pNext = NULL; |
| 5284 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5285 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5286 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5287 | // New layout can't be UNDEFINED |
| 5288 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5289 | img_barrier.image = image.handle(); |
| 5290 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5291 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5292 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5293 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5294 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5295 | img_barrier.subresourceRange.layerCount = 1; |
| 5296 | img_barrier.subresourceRange.levelCount = 1; |
| 5297 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5298 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5299 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5300 | nullptr, 1, &img_barrier); |
| 5301 | m_errorMonitor->VerifyFound(); |
| 5302 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5303 | |
| 5304 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5305 | "Subresource must have the sum of the " |
| 5306 | "baseArrayLayer"); |
| 5307 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5308 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5309 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5310 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5311 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5312 | nullptr, 1, &img_barrier); |
| 5313 | m_errorMonitor->VerifyFound(); |
| 5314 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5315 | |
| 5316 | m_errorMonitor->SetDesiredFailureMsg( |
| 5317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5318 | "Subresource must have the sum of the baseMipLevel"); |
| 5319 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5320 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5321 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5322 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5323 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5324 | nullptr, 1, &img_barrier); |
| 5325 | m_errorMonitor->VerifyFound(); |
| 5326 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5327 | |
| 5328 | m_errorMonitor->SetDesiredFailureMsg( |
| 5329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5330 | "Buffer Barriers cannot be used during a render pass"); |
| 5331 | vk_testing::Buffer buffer; |
| 5332 | buffer.init(*m_device, 256); |
| 5333 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5334 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5335 | buf_barrier.pNext = NULL; |
| 5336 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5337 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5338 | buf_barrier.buffer = buffer.handle(); |
| 5339 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5340 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5341 | buf_barrier.offset = 0; |
| 5342 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5343 | // Can't send buffer barrier during a render pass |
| 5344 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5345 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5346 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5347 | &buf_barrier, 0, nullptr); |
| 5348 | m_errorMonitor->VerifyFound(); |
| 5349 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5350 | |
| 5351 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5352 | "which is not less than total size"); |
| 5353 | buf_barrier.offset = 257; |
| 5354 | // Offset greater than total size |
| 5355 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5356 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5357 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5358 | &buf_barrier, 0, nullptr); |
| 5359 | m_errorMonitor->VerifyFound(); |
| 5360 | buf_barrier.offset = 0; |
| 5361 | |
| 5362 | m_errorMonitor->SetDesiredFailureMsg( |
| 5363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5364 | buf_barrier.size = 257; |
| 5365 | // Size greater than total size |
| 5366 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5367 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5368 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5369 | &buf_barrier, 0, nullptr); |
| 5370 | m_errorMonitor->VerifyFound(); |
| 5371 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5372 | |
| 5373 | m_errorMonitor->SetDesiredFailureMsg( |
| 5374 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5375 | "Image is a depth and stencil format and thus must " |
| 5376 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5377 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5378 | VkDepthStencilObj ds_image(m_device); |
| 5379 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5380 | ASSERT_TRUE(ds_image.initialized()); |
| 5381 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5382 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5383 | img_barrier.image = ds_image.handle(); |
| 5384 | // Leave aspectMask at COLOR on purpose |
| 5385 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5386 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5387 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5388 | nullptr, 1, &img_barrier); |
| 5389 | m_errorMonitor->VerifyFound(); |
| 5390 | } |
| 5391 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5392 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5393 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5394 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5396 | m_errorMonitor->SetDesiredFailureMsg( |
| 5397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5398 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5399 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5400 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5401 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5402 | uint32_t qfi = 0; |
| 5403 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5404 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5405 | buffCI.size = 1024; |
| 5406 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5407 | buffCI.queueFamilyIndexCount = 1; |
| 5408 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5409 | |
| 5410 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5411 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5412 | ASSERT_VK_SUCCESS(err); |
| 5413 | |
| 5414 | BeginCommandBuffer(); |
| 5415 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5416 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5417 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5418 | // 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] | 5419 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5420 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5422 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5424 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5425 | } |
| 5426 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5427 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5428 | // Create an out-of-range queueFamilyIndex |
| 5429 | m_errorMonitor->SetDesiredFailureMsg( |
| 5430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5431 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5432 | |
| 5433 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5434 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5435 | VkBufferCreateInfo buffCI = {}; |
| 5436 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5437 | buffCI.size = 1024; |
| 5438 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5439 | buffCI.queueFamilyIndexCount = 1; |
| 5440 | // Introduce failure by specifying invalid queue_family_index |
| 5441 | uint32_t qfi = 777; |
| 5442 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5443 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5444 | |
| 5445 | VkBuffer ib; |
| 5446 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5447 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5448 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5449 | } |
| 5450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5451 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5452 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5453 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5455 | m_errorMonitor->SetDesiredFailureMsg( |
| 5456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5457 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5458 | |
| 5459 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5460 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5461 | |
| 5462 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5463 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5464 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5465 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5466 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5467 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5468 | } |
| 5469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5471 | // 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] | 5472 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5473 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5474 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5475 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5476 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5477 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5478 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5479 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5480 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5481 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5482 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5483 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5484 | |
| 5485 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5486 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5487 | ds_pool_ci.pNext = NULL; |
| 5488 | ds_pool_ci.maxSets = 1; |
| 5489 | ds_pool_ci.poolSizeCount = 1; |
| 5490 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5491 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5492 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5493 | err = |
| 5494 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5495 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5496 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5497 | dsl_binding.binding = 0; |
| 5498 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5499 | dsl_binding.descriptorCount = 1; |
| 5500 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5501 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5502 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5503 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5504 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5505 | ds_layout_ci.pNext = NULL; |
| 5506 | ds_layout_ci.bindingCount = 1; |
| 5507 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5508 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5509 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5510 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5511 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5512 | ASSERT_VK_SUCCESS(err); |
| 5513 | |
| 5514 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5515 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5516 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5517 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5518 | alloc_info.descriptorPool = ds_pool; |
| 5519 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5520 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5521 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5522 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5523 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5524 | VkSamplerCreateInfo sampler_ci = {}; |
| 5525 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5526 | sampler_ci.pNext = NULL; |
| 5527 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5528 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5529 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5530 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5531 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5532 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5533 | sampler_ci.mipLodBias = 1.0; |
| 5534 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5535 | sampler_ci.maxAnisotropy = 1; |
| 5536 | sampler_ci.compareEnable = VK_FALSE; |
| 5537 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5538 | sampler_ci.minLod = 1.0; |
| 5539 | sampler_ci.maxLod = 1.0; |
| 5540 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5541 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5542 | VkSampler sampler; |
| 5543 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5544 | ASSERT_VK_SUCCESS(err); |
| 5545 | |
| 5546 | VkDescriptorImageInfo info = {}; |
| 5547 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5548 | |
| 5549 | VkWriteDescriptorSet descriptor_write; |
| 5550 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5551 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5552 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5553 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5554 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5555 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5556 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5557 | |
| 5558 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5559 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5560 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5561 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5562 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5563 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5564 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5565 | } |
| 5566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5567 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5568 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5569 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5571 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5572 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5573 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5574 | "starting at binding offset of 0 combined with update array element " |
| 5575 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5576 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5577 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5578 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5579 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5580 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5581 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5582 | |
| 5583 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5585 | ds_pool_ci.pNext = NULL; |
| 5586 | ds_pool_ci.maxSets = 1; |
| 5587 | ds_pool_ci.poolSizeCount = 1; |
| 5588 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5589 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5590 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5591 | err = |
| 5592 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5593 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5594 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5595 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | dsl_binding.binding = 0; |
| 5597 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5598 | dsl_binding.descriptorCount = 1; |
| 5599 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5600 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5601 | |
| 5602 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5603 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5604 | ds_layout_ci.pNext = NULL; |
| 5605 | ds_layout_ci.bindingCount = 1; |
| 5606 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5607 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5608 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5609 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5610 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5611 | ASSERT_VK_SUCCESS(err); |
| 5612 | |
| 5613 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5614 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5615 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5616 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5617 | alloc_info.descriptorPool = ds_pool; |
| 5618 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5619 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5620 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5621 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5622 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5623 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5624 | VkDescriptorBufferInfo buff_info = {}; |
| 5625 | buff_info.buffer = |
| 5626 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5627 | buff_info.offset = 0; |
| 5628 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5629 | |
| 5630 | VkWriteDescriptorSet descriptor_write; |
| 5631 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5632 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5633 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | descriptor_write.dstArrayElement = |
| 5635 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5636 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5637 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5638 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5639 | |
| 5640 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5641 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5642 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5643 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5644 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5645 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5646 | } |
| 5647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5648 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5649 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5650 | // index 2 |
| 5651 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5652 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5653 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5654 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5655 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5656 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5657 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5658 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5660 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5661 | |
| 5662 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5663 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5664 | ds_pool_ci.pNext = NULL; |
| 5665 | ds_pool_ci.maxSets = 1; |
| 5666 | ds_pool_ci.poolSizeCount = 1; |
| 5667 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5668 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5669 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | err = |
| 5671 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5672 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5673 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5674 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5675 | dsl_binding.binding = 0; |
| 5676 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5677 | dsl_binding.descriptorCount = 1; |
| 5678 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5679 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5680 | |
| 5681 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5682 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5683 | ds_layout_ci.pNext = NULL; |
| 5684 | ds_layout_ci.bindingCount = 1; |
| 5685 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5686 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5687 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5688 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5689 | ASSERT_VK_SUCCESS(err); |
| 5690 | |
| 5691 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5692 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5693 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5694 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5695 | alloc_info.descriptorPool = ds_pool; |
| 5696 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5697 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5698 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5699 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5700 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5701 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5702 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5703 | sampler_ci.pNext = NULL; |
| 5704 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5705 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5706 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5707 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5708 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5709 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5710 | sampler_ci.mipLodBias = 1.0; |
| 5711 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5712 | sampler_ci.maxAnisotropy = 1; |
| 5713 | sampler_ci.compareEnable = VK_FALSE; |
| 5714 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5715 | sampler_ci.minLod = 1.0; |
| 5716 | sampler_ci.maxLod = 1.0; |
| 5717 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5718 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5719 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5720 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5721 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5722 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5723 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5724 | VkDescriptorImageInfo info = {}; |
| 5725 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5726 | |
| 5727 | VkWriteDescriptorSet descriptor_write; |
| 5728 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5729 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5730 | descriptor_write.dstSet = descriptorSet; |
| 5731 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5732 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5733 | // 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] | 5734 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5735 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5736 | |
| 5737 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5738 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5739 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5740 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5741 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5742 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5743 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5744 | } |
| 5745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5746 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5747 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5748 | // types |
| 5749 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5750 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5751 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5752 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5753 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5754 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5755 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5756 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5757 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5758 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5759 | |
| 5760 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5761 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5762 | ds_pool_ci.pNext = NULL; |
| 5763 | ds_pool_ci.maxSets = 1; |
| 5764 | ds_pool_ci.poolSizeCount = 1; |
| 5765 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5766 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5767 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5768 | err = |
| 5769 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5770 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5771 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5772 | dsl_binding.binding = 0; |
| 5773 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5774 | dsl_binding.descriptorCount = 1; |
| 5775 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5776 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5777 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5778 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5779 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5780 | ds_layout_ci.pNext = NULL; |
| 5781 | ds_layout_ci.bindingCount = 1; |
| 5782 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5783 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5784 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5785 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5786 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5787 | ASSERT_VK_SUCCESS(err); |
| 5788 | |
| 5789 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5790 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5791 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5792 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5793 | alloc_info.descriptorPool = ds_pool; |
| 5794 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5795 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5796 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5797 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5798 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5799 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5800 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5801 | sampler_ci.pNext = NULL; |
| 5802 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5803 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5804 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5805 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5806 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5807 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5808 | sampler_ci.mipLodBias = 1.0; |
| 5809 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5810 | sampler_ci.maxAnisotropy = 1; |
| 5811 | sampler_ci.compareEnable = VK_FALSE; |
| 5812 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5813 | sampler_ci.minLod = 1.0; |
| 5814 | sampler_ci.maxLod = 1.0; |
| 5815 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5816 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5817 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5818 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5819 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5820 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5821 | VkDescriptorImageInfo info = {}; |
| 5822 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5823 | |
| 5824 | VkWriteDescriptorSet descriptor_write; |
| 5825 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5826 | descriptor_write.sType = |
| 5827 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5828 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5829 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5830 | // 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] | 5831 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5832 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5833 | |
| 5834 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5835 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5836 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5837 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5838 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5839 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5840 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5841 | } |
| 5842 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5843 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5844 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5845 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5846 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5847 | m_errorMonitor->SetDesiredFailureMsg( |
| 5848 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5849 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5850 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5851 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5853 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5854 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5855 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5856 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5857 | |
| 5858 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5860 | ds_pool_ci.pNext = NULL; |
| 5861 | ds_pool_ci.maxSets = 1; |
| 5862 | ds_pool_ci.poolSizeCount = 1; |
| 5863 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5864 | |
| 5865 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5866 | err = |
| 5867 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5868 | ASSERT_VK_SUCCESS(err); |
| 5869 | |
| 5870 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5871 | dsl_binding.binding = 0; |
| 5872 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5873 | dsl_binding.descriptorCount = 1; |
| 5874 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5875 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5876 | |
| 5877 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5878 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5879 | ds_layout_ci.pNext = NULL; |
| 5880 | ds_layout_ci.bindingCount = 1; |
| 5881 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5882 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5883 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5884 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5885 | ASSERT_VK_SUCCESS(err); |
| 5886 | |
| 5887 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5888 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5889 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5890 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5891 | alloc_info.descriptorPool = ds_pool; |
| 5892 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5893 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5894 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5895 | ASSERT_VK_SUCCESS(err); |
| 5896 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5897 | VkSampler sampler = |
| 5898 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5899 | |
| 5900 | VkDescriptorImageInfo descriptor_info; |
| 5901 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5902 | descriptor_info.sampler = sampler; |
| 5903 | |
| 5904 | VkWriteDescriptorSet descriptor_write; |
| 5905 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5906 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5907 | descriptor_write.dstSet = descriptorSet; |
| 5908 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5909 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5910 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5911 | descriptor_write.pImageInfo = &descriptor_info; |
| 5912 | |
| 5913 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5914 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5915 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5916 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5917 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5918 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5919 | } |
| 5920 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5921 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5922 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5923 | // imageView |
| 5924 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5925 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5926 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5927 | "Attempted write update to combined " |
| 5928 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 5929 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5930 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5931 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5932 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5933 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5934 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5935 | |
| 5936 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5938 | ds_pool_ci.pNext = NULL; |
| 5939 | ds_pool_ci.maxSets = 1; |
| 5940 | ds_pool_ci.poolSizeCount = 1; |
| 5941 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5942 | |
| 5943 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5944 | err = |
| 5945 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5946 | ASSERT_VK_SUCCESS(err); |
| 5947 | |
| 5948 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | dsl_binding.binding = 0; |
| 5950 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5951 | dsl_binding.descriptorCount = 1; |
| 5952 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5953 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5954 | |
| 5955 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5956 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5957 | ds_layout_ci.pNext = NULL; |
| 5958 | ds_layout_ci.bindingCount = 1; |
| 5959 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5960 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5961 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5962 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5963 | ASSERT_VK_SUCCESS(err); |
| 5964 | |
| 5965 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5966 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5967 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5968 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5969 | alloc_info.descriptorPool = ds_pool; |
| 5970 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5972 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5973 | ASSERT_VK_SUCCESS(err); |
| 5974 | |
| 5975 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5977 | sampler_ci.pNext = NULL; |
| 5978 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5979 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5980 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5981 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5982 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5983 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5984 | sampler_ci.mipLodBias = 1.0; |
| 5985 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5986 | sampler_ci.maxAnisotropy = 1; |
| 5987 | sampler_ci.compareEnable = VK_FALSE; |
| 5988 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5989 | sampler_ci.minLod = 1.0; |
| 5990 | sampler_ci.maxLod = 1.0; |
| 5991 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5992 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5993 | |
| 5994 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5995 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5996 | ASSERT_VK_SUCCESS(err); |
| 5997 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5998 | VkImageView view = |
| 5999 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6000 | |
| 6001 | VkDescriptorImageInfo descriptor_info; |
| 6002 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 6003 | descriptor_info.sampler = sampler; |
| 6004 | descriptor_info.imageView = view; |
| 6005 | |
| 6006 | VkWriteDescriptorSet descriptor_write; |
| 6007 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6008 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6009 | descriptor_write.dstSet = descriptorSet; |
| 6010 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6011 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6012 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6013 | descriptor_write.pImageInfo = &descriptor_info; |
| 6014 | |
| 6015 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6016 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6017 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6018 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6019 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6020 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6021 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6022 | } |
| 6023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6024 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 6025 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 6026 | // into the other |
| 6027 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6028 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6029 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6030 | " binding #1 with type " |
| 6031 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 6032 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6033 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6034 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6036 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6037 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6038 | ds_type_count[0].descriptorCount = 1; |
| 6039 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6040 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6041 | |
| 6042 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6043 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6044 | ds_pool_ci.pNext = NULL; |
| 6045 | ds_pool_ci.maxSets = 1; |
| 6046 | ds_pool_ci.poolSizeCount = 2; |
| 6047 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6048 | |
| 6049 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6050 | err = |
| 6051 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6052 | ASSERT_VK_SUCCESS(err); |
| 6053 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6054 | dsl_binding[0].binding = 0; |
| 6055 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6056 | dsl_binding[0].descriptorCount = 1; |
| 6057 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6058 | dsl_binding[0].pImmutableSamplers = NULL; |
| 6059 | dsl_binding[1].binding = 1; |
| 6060 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6061 | dsl_binding[1].descriptorCount = 1; |
| 6062 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6063 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6064 | |
| 6065 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6066 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6067 | ds_layout_ci.pNext = NULL; |
| 6068 | ds_layout_ci.bindingCount = 2; |
| 6069 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6070 | |
| 6071 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6072 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6073 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6074 | ASSERT_VK_SUCCESS(err); |
| 6075 | |
| 6076 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6077 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6078 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6079 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6080 | alloc_info.descriptorPool = ds_pool; |
| 6081 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6082 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6083 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6084 | ASSERT_VK_SUCCESS(err); |
| 6085 | |
| 6086 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6087 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6088 | sampler_ci.pNext = NULL; |
| 6089 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6090 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6091 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6092 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6093 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6094 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6095 | sampler_ci.mipLodBias = 1.0; |
| 6096 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6097 | sampler_ci.maxAnisotropy = 1; |
| 6098 | sampler_ci.compareEnable = VK_FALSE; |
| 6099 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6100 | sampler_ci.minLod = 1.0; |
| 6101 | sampler_ci.maxLod = 1.0; |
| 6102 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6103 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6104 | |
| 6105 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6106 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6107 | ASSERT_VK_SUCCESS(err); |
| 6108 | |
| 6109 | VkDescriptorImageInfo info = {}; |
| 6110 | info.sampler = sampler; |
| 6111 | |
| 6112 | VkWriteDescriptorSet descriptor_write; |
| 6113 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6114 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6115 | descriptor_write.dstSet = descriptorSet; |
| 6116 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6117 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6118 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6119 | descriptor_write.pImageInfo = &info; |
| 6120 | // This write update should succeed |
| 6121 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6122 | // Now perform a copy update that fails due to type mismatch |
| 6123 | VkCopyDescriptorSet copy_ds_update; |
| 6124 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6125 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6126 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6127 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6128 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6129 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6130 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6131 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6132 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6133 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6134 | // 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] | 6135 | m_errorMonitor->SetDesiredFailureMsg( |
| 6136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6137 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6138 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6139 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6140 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6141 | copy_ds_update.srcBinding = |
| 6142 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6143 | copy_ds_update.dstSet = descriptorSet; |
| 6144 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6145 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6146 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6147 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6148 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6149 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6150 | // 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] | 6151 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6153 | "update array offset of 0 and update of " |
| 6154 | "5 descriptors oversteps total number " |
| 6155 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6156 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6157 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6158 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6159 | copy_ds_update.srcSet = descriptorSet; |
| 6160 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6161 | copy_ds_update.dstSet = descriptorSet; |
| 6162 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6163 | copy_ds_update.descriptorCount = |
| 6164 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6165 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6166 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6167 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6168 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6169 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6170 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6171 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6172 | } |
| 6173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6174 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6175 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6176 | // sampleCount |
| 6177 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6178 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6179 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6180 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6181 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6182 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6183 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6184 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6185 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6186 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6187 | |
| 6188 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6190 | ds_pool_ci.pNext = NULL; |
| 6191 | ds_pool_ci.maxSets = 1; |
| 6192 | ds_pool_ci.poolSizeCount = 1; |
| 6193 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6194 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6195 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6196 | err = |
| 6197 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6198 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6199 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6200 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6201 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6202 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6203 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6204 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6205 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6206 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6207 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6208 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6209 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6210 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6211 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6212 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6213 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6214 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6215 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6216 | ASSERT_VK_SUCCESS(err); |
| 6217 | |
| 6218 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6219 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6220 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6221 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6222 | alloc_info.descriptorPool = ds_pool; |
| 6223 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6224 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6225 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6226 | ASSERT_VK_SUCCESS(err); |
| 6227 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6228 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6229 | pipe_ms_state_ci.sType = |
| 6230 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6231 | pipe_ms_state_ci.pNext = NULL; |
| 6232 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6233 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6234 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6235 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6236 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6237 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6238 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6239 | pipeline_layout_ci.pNext = NULL; |
| 6240 | pipeline_layout_ci.setLayoutCount = 1; |
| 6241 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6242 | |
| 6243 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6244 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6245 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6246 | ASSERT_VK_SUCCESS(err); |
| 6247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6248 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6249 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6250 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6251 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6252 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6253 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6254 | VkPipelineObj pipe(m_device); |
| 6255 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6256 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6257 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6258 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6259 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6260 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6261 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6262 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6263 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6264 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6265 | // Render triangle (the error should trigger on the attempt to draw). |
| 6266 | Draw(3, 1, 0, 0); |
| 6267 | |
| 6268 | // Finalize recording of the command buffer |
| 6269 | EndCommandBuffer(); |
| 6270 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6271 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6272 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6273 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6274 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6275 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6276 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6277 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6278 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6279 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6280 | // number of color attachments. In this case, we don't add any color |
| 6281 | // blend attachments even though we have a color attachment. |
| 6282 | VkResult err; |
| 6283 | |
| 6284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6285 | "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] | 6286 | |
| 6287 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6288 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6289 | VkDescriptorPoolSize ds_type_count = {}; |
| 6290 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6291 | ds_type_count.descriptorCount = 1; |
| 6292 | |
| 6293 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6294 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6295 | ds_pool_ci.pNext = NULL; |
| 6296 | ds_pool_ci.maxSets = 1; |
| 6297 | ds_pool_ci.poolSizeCount = 1; |
| 6298 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6299 | |
| 6300 | VkDescriptorPool ds_pool; |
| 6301 | err = |
| 6302 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6303 | ASSERT_VK_SUCCESS(err); |
| 6304 | |
| 6305 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6306 | dsl_binding.binding = 0; |
| 6307 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6308 | dsl_binding.descriptorCount = 1; |
| 6309 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6310 | dsl_binding.pImmutableSamplers = NULL; |
| 6311 | |
| 6312 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6313 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6314 | ds_layout_ci.pNext = NULL; |
| 6315 | ds_layout_ci.bindingCount = 1; |
| 6316 | ds_layout_ci.pBindings = &dsl_binding; |
| 6317 | |
| 6318 | VkDescriptorSetLayout ds_layout; |
| 6319 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6320 | &ds_layout); |
| 6321 | ASSERT_VK_SUCCESS(err); |
| 6322 | |
| 6323 | VkDescriptorSet descriptorSet; |
| 6324 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6325 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6326 | alloc_info.descriptorSetCount = 1; |
| 6327 | alloc_info.descriptorPool = ds_pool; |
| 6328 | alloc_info.pSetLayouts = &ds_layout; |
| 6329 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6330 | &descriptorSet); |
| 6331 | ASSERT_VK_SUCCESS(err); |
| 6332 | |
| 6333 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6334 | pipe_ms_state_ci.sType = |
| 6335 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6336 | pipe_ms_state_ci.pNext = NULL; |
| 6337 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6338 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6339 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6340 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6341 | |
| 6342 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6343 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6344 | pipeline_layout_ci.pNext = NULL; |
| 6345 | pipeline_layout_ci.setLayoutCount = 1; |
| 6346 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6347 | |
| 6348 | VkPipelineLayout pipeline_layout; |
| 6349 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6350 | &pipeline_layout); |
| 6351 | ASSERT_VK_SUCCESS(err); |
| 6352 | |
| 6353 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6354 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6355 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6356 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6357 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6358 | // but add it to be able to run on more devices |
| 6359 | VkPipelineObj pipe(m_device); |
| 6360 | pipe.AddShader(&vs); |
| 6361 | pipe.AddShader(&fs); |
| 6362 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6363 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6364 | |
| 6365 | BeginCommandBuffer(); |
| 6366 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6367 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6368 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6369 | // Render triangle (the error should trigger on the attempt to draw). |
| 6370 | Draw(3, 1, 0, 0); |
| 6371 | |
| 6372 | // Finalize recording of the command buffer |
| 6373 | EndCommandBuffer(); |
| 6374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6375 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6376 | |
| 6377 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6378 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6379 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6380 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6382 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6383 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6384 | // to issuing a Draw |
| 6385 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6387 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6388 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6389 | "vkCmdClearAttachments() issued on CB object "); |
| 6390 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6393 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6394 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6395 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6396 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6397 | |
| 6398 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6399 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6400 | ds_pool_ci.pNext = NULL; |
| 6401 | ds_pool_ci.maxSets = 1; |
| 6402 | ds_pool_ci.poolSizeCount = 1; |
| 6403 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6404 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6405 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6406 | err = |
| 6407 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6408 | ASSERT_VK_SUCCESS(err); |
| 6409 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6410 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | dsl_binding.binding = 0; |
| 6412 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6413 | dsl_binding.descriptorCount = 1; |
| 6414 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6415 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6416 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6417 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6418 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6419 | ds_layout_ci.pNext = NULL; |
| 6420 | ds_layout_ci.bindingCount = 1; |
| 6421 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6422 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6423 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6425 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6426 | ASSERT_VK_SUCCESS(err); |
| 6427 | |
| 6428 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6429 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6430 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6431 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6432 | alloc_info.descriptorPool = ds_pool; |
| 6433 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6434 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6435 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6436 | ASSERT_VK_SUCCESS(err); |
| 6437 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6438 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6439 | pipe_ms_state_ci.sType = |
| 6440 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6441 | pipe_ms_state_ci.pNext = NULL; |
| 6442 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6443 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6444 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6445 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6446 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6447 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6448 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6449 | pipeline_layout_ci.pNext = NULL; |
| 6450 | pipeline_layout_ci.setLayoutCount = 1; |
| 6451 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6452 | |
| 6453 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6454 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6455 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6456 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6458 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6459 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6460 | // 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] | 6461 | // on more devices |
| 6462 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6463 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6464 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6465 | VkPipelineObj pipe(m_device); |
| 6466 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6467 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6468 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6469 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6470 | |
| 6471 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6472 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6473 | // Main thing we care about for this test is that the VkImage obj we're |
| 6474 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6475 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6476 | VkClearAttachment color_attachment; |
| 6477 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6478 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6479 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6480 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6481 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6482 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6483 | VkClearRect clear_rect = { |
| 6484 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6486 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6487 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6488 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6489 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6490 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6491 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6492 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6493 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6494 | } |
| 6495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6496 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6497 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6499 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6500 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6501 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6502 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6503 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6504 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6505 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6506 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6507 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6509 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6510 | |
| 6511 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6513 | ds_pool_ci.pNext = NULL; |
| 6514 | ds_pool_ci.maxSets = 1; |
| 6515 | ds_pool_ci.poolSizeCount = 1; |
| 6516 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6517 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6518 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6519 | err = |
| 6520 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6521 | ASSERT_VK_SUCCESS(err); |
| 6522 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6523 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6524 | dsl_binding.binding = 0; |
| 6525 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6526 | dsl_binding.descriptorCount = 1; |
| 6527 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6528 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6529 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6530 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6531 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6532 | ds_layout_ci.pNext = NULL; |
| 6533 | ds_layout_ci.bindingCount = 1; |
| 6534 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6535 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6536 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6537 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6538 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6539 | ASSERT_VK_SUCCESS(err); |
| 6540 | |
| 6541 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6542 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6543 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6544 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6545 | alloc_info.descriptorPool = ds_pool; |
| 6546 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6547 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6548 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6549 | ASSERT_VK_SUCCESS(err); |
| 6550 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6551 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6552 | pipe_ms_state_ci.sType = |
| 6553 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6554 | pipe_ms_state_ci.pNext = NULL; |
| 6555 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6556 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6557 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6558 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6559 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6560 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6561 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6562 | pipeline_layout_ci.pNext = NULL; |
| 6563 | pipeline_layout_ci.setLayoutCount = 1; |
| 6564 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6565 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6567 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6568 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6569 | ASSERT_VK_SUCCESS(err); |
| 6570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6571 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6572 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6573 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6574 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6575 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6576 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6577 | VkPipelineObj pipe(m_device); |
| 6578 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6579 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6580 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6581 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6582 | pipe.SetViewport(m_viewports); |
| 6583 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6584 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6585 | |
| 6586 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6587 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6588 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6589 | // Don't care about actual data, just need to get to draw to flag error |
| 6590 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6591 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6592 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6593 | 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] | 6594 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6595 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6596 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6597 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6598 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6599 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6600 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6601 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6602 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 6603 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 6604 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 6605 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 6606 | "images in the wrong layout when they're copied or transitioned."); |
| 6607 | // 3 in ValidateCmdBufImageLayouts |
| 6608 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 6609 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 6610 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 6611 | m_errorMonitor->SetDesiredFailureMsg( |
| 6612 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6613 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 6614 | |
| 6615 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6616 | // Create src & dst images to use for copy operations |
| 6617 | VkImage src_image; |
| 6618 | VkImage dst_image; |
| 6619 | |
| 6620 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6621 | const int32_t tex_width = 32; |
| 6622 | const int32_t tex_height = 32; |
| 6623 | |
| 6624 | VkImageCreateInfo image_create_info = {}; |
| 6625 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6626 | image_create_info.pNext = NULL; |
| 6627 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6628 | image_create_info.format = tex_format; |
| 6629 | image_create_info.extent.width = tex_width; |
| 6630 | image_create_info.extent.height = tex_height; |
| 6631 | image_create_info.extent.depth = 1; |
| 6632 | image_create_info.mipLevels = 1; |
| 6633 | image_create_info.arrayLayers = 4; |
| 6634 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6635 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6636 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6637 | image_create_info.flags = 0; |
| 6638 | |
| 6639 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 6640 | ASSERT_VK_SUCCESS(err); |
| 6641 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 6642 | ASSERT_VK_SUCCESS(err); |
| 6643 | |
| 6644 | BeginCommandBuffer(); |
| 6645 | VkImageCopy copyRegion; |
| 6646 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6647 | copyRegion.srcSubresource.mipLevel = 0; |
| 6648 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6649 | copyRegion.srcSubresource.layerCount = 1; |
| 6650 | copyRegion.srcOffset.x = 0; |
| 6651 | copyRegion.srcOffset.y = 0; |
| 6652 | copyRegion.srcOffset.z = 0; |
| 6653 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6654 | copyRegion.dstSubresource.mipLevel = 0; |
| 6655 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6656 | copyRegion.dstSubresource.layerCount = 1; |
| 6657 | copyRegion.dstOffset.x = 0; |
| 6658 | copyRegion.dstOffset.y = 0; |
| 6659 | copyRegion.dstOffset.z = 0; |
| 6660 | copyRegion.extent.width = 1; |
| 6661 | copyRegion.extent.height = 1; |
| 6662 | copyRegion.extent.depth = 1; |
| 6663 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6664 | m_errorMonitor->VerifyFound(); |
| 6665 | // Now cause error due to src image layout changing |
| 6666 | m_errorMonitor->SetDesiredFailureMsg( |
| 6667 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6668 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6669 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6670 | m_errorMonitor->VerifyFound(); |
| 6671 | // Final src error is due to bad layout type |
| 6672 | m_errorMonitor->SetDesiredFailureMsg( |
| 6673 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6674 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 6675 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6676 | m_errorMonitor->VerifyFound(); |
| 6677 | // Now verify same checks for dst |
| 6678 | m_errorMonitor->SetDesiredFailureMsg( |
| 6679 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6680 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 6681 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6682 | m_errorMonitor->VerifyFound(); |
| 6683 | // Now cause error due to src image layout changing |
| 6684 | m_errorMonitor->SetDesiredFailureMsg( |
| 6685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6686 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6687 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6688 | m_errorMonitor->VerifyFound(); |
| 6689 | m_errorMonitor->SetDesiredFailureMsg( |
| 6690 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6691 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 6692 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6693 | m_errorMonitor->VerifyFound(); |
| 6694 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 6695 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 6696 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6697 | image_barrier[0].image = src_image; |
| 6698 | image_barrier[0].subresourceRange.layerCount = 2; |
| 6699 | image_barrier[0].subresourceRange.levelCount = 2; |
| 6700 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6701 | m_errorMonitor->SetDesiredFailureMsg( |
| 6702 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6703 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 6704 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 6705 | m_errorMonitor->VerifyFound(); |
| 6706 | |
| 6707 | // Finally some layout errors at RenderPass create time |
| 6708 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 6709 | VkAttachmentReference attach = {}; |
| 6710 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 6711 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6712 | VkSubpassDescription subpass = {}; |
| 6713 | subpass.inputAttachmentCount = 1; |
| 6714 | subpass.pInputAttachments = &attach; |
| 6715 | VkRenderPassCreateInfo rpci = {}; |
| 6716 | rpci.subpassCount = 1; |
| 6717 | rpci.pSubpasses = &subpass; |
| 6718 | rpci.attachmentCount = 1; |
| 6719 | VkAttachmentDescription attach_desc = {}; |
| 6720 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6721 | rpci.pAttachments = &attach_desc; |
| 6722 | VkRenderPass rp; |
| 6723 | m_errorMonitor->SetDesiredFailureMsg( |
| 6724 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6725 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 6726 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6727 | m_errorMonitor->VerifyFound(); |
| 6728 | // error w/ non-general layout |
| 6729 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6730 | |
| 6731 | m_errorMonitor->SetDesiredFailureMsg( |
| 6732 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6733 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 6734 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6735 | m_errorMonitor->VerifyFound(); |
| 6736 | subpass.inputAttachmentCount = 0; |
| 6737 | subpass.colorAttachmentCount = 1; |
| 6738 | subpass.pColorAttachments = &attach; |
| 6739 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6740 | // perf warning for GENERAL layout on color attachment |
| 6741 | m_errorMonitor->SetDesiredFailureMsg( |
| 6742 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6743 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 6744 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6745 | m_errorMonitor->VerifyFound(); |
| 6746 | // error w/ non-color opt or GENERAL layout for color attachment |
| 6747 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6748 | m_errorMonitor->SetDesiredFailureMsg( |
| 6749 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6750 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6751 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6752 | m_errorMonitor->VerifyFound(); |
| 6753 | subpass.colorAttachmentCount = 0; |
| 6754 | subpass.pDepthStencilAttachment = &attach; |
| 6755 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6756 | // perf warning for GENERAL layout on DS attachment |
| 6757 | m_errorMonitor->SetDesiredFailureMsg( |
| 6758 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6759 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 6760 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6761 | m_errorMonitor->VerifyFound(); |
| 6762 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 6763 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6764 | m_errorMonitor->SetDesiredFailureMsg( |
| 6765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6766 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6767 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6768 | m_errorMonitor->VerifyFound(); |
| 6769 | |
| 6770 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 6771 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 6772 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6773 | #endif // DRAW_STATE_TESTS |
| 6774 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6775 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6776 | #if GTEST_IS_THREADSAFE |
| 6777 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6778 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6779 | VkEvent event; |
| 6780 | bool bailout; |
| 6781 | }; |
| 6782 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6783 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6784 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6785 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6786 | for (int i = 0; i < 10000; i++) { |
| 6787 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6788 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6789 | if (data->bailout) { |
| 6790 | break; |
| 6791 | } |
| 6792 | } |
| 6793 | return NULL; |
| 6794 | } |
| 6795 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6796 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6797 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6798 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6799 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6800 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6801 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6803 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6804 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6805 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6806 | // Calls AllocateCommandBuffers |
| 6807 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6808 | |
| 6809 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6810 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6811 | |
| 6812 | VkEventCreateInfo event_info; |
| 6813 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6814 | VkResult err; |
| 6815 | |
| 6816 | memset(&event_info, 0, sizeof(event_info)); |
| 6817 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6818 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6819 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6820 | ASSERT_VK_SUCCESS(err); |
| 6821 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6822 | err = vkResetEvent(device(), event); |
| 6823 | ASSERT_VK_SUCCESS(err); |
| 6824 | |
| 6825 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6826 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6827 | data.event = event; |
| 6828 | data.bailout = false; |
| 6829 | m_errorMonitor->SetBailout(&data.bailout); |
| 6830 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6831 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6832 | // Add many entries to command buffer from this thread at the same time. |
| 6833 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6834 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6835 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6836 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6837 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6838 | m_errorMonitor->SetBailout(NULL); |
| 6839 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6840 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6841 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6842 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6843 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6844 | #endif // GTEST_IS_THREADSAFE |
| 6845 | #endif // THREADING_TESTS |
| 6846 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6847 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6848 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6849 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6850 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6851 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6853 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6854 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6855 | VkShaderModule module; |
| 6856 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6857 | struct icd_spv_header spv; |
| 6858 | |
| 6859 | spv.magic = ICD_SPV_MAGIC; |
| 6860 | spv.version = ICD_SPV_VERSION; |
| 6861 | spv.gen_magic = 0; |
| 6862 | |
| 6863 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6864 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6865 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6866 | moduleCreateInfo.codeSize = 4; |
| 6867 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6868 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6869 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6870 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6871 | } |
| 6872 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6873 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6875 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6876 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6877 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6878 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6879 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6880 | VkShaderModule module; |
| 6881 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6882 | struct icd_spv_header spv; |
| 6883 | |
| 6884 | spv.magic = ~ICD_SPV_MAGIC; |
| 6885 | spv.version = ICD_SPV_VERSION; |
| 6886 | spv.gen_magic = 0; |
| 6887 | |
| 6888 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6889 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6890 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6891 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6892 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6893 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6894 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6895 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6896 | } |
| 6897 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6898 | #if 0 |
| 6899 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6900 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6901 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6902 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6903 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6905 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6906 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6907 | VkShaderModule module; |
| 6908 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6909 | struct icd_spv_header spv; |
| 6910 | |
| 6911 | spv.magic = ICD_SPV_MAGIC; |
| 6912 | spv.version = ~ICD_SPV_VERSION; |
| 6913 | spv.gen_magic = 0; |
| 6914 | |
| 6915 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6916 | moduleCreateInfo.pNext = NULL; |
| 6917 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6918 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6919 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6920 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6921 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6922 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6923 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6924 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6925 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6927 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6928 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6929 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6930 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6931 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6932 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6933 | |
| 6934 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6935 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6936 | "\n" |
| 6937 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6938 | "out gl_PerVertex {\n" |
| 6939 | " vec4 gl_Position;\n" |
| 6940 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6941 | "void main(){\n" |
| 6942 | " gl_Position = vec4(1);\n" |
| 6943 | " x = 0;\n" |
| 6944 | "}\n"; |
| 6945 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6946 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6947 | "\n" |
| 6948 | "layout(location=0) out vec4 color;\n" |
| 6949 | "void main(){\n" |
| 6950 | " color = vec4(1);\n" |
| 6951 | "}\n"; |
| 6952 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6953 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6954 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6955 | |
| 6956 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6957 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6958 | pipe.AddShader(&vs); |
| 6959 | pipe.AddShader(&fs); |
| 6960 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6961 | VkDescriptorSetObj descriptorSet(m_device); |
| 6962 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6963 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6964 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6965 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6966 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6967 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6968 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6970 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6972 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6973 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6974 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6975 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6976 | |
| 6977 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6978 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6979 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6980 | "out gl_PerVertex {\n" |
| 6981 | " vec4 gl_Position;\n" |
| 6982 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6983 | "void main(){\n" |
| 6984 | " gl_Position = vec4(1);\n" |
| 6985 | "}\n"; |
| 6986 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6987 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6988 | "\n" |
| 6989 | "layout(location=0) in float x;\n" |
| 6990 | "layout(location=0) out vec4 color;\n" |
| 6991 | "void main(){\n" |
| 6992 | " color = vec4(x);\n" |
| 6993 | "}\n"; |
| 6994 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6995 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6996 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6997 | |
| 6998 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6999 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7000 | pipe.AddShader(&vs); |
| 7001 | pipe.AddShader(&fs); |
| 7002 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7003 | VkDescriptorSetObj descriptorSet(m_device); |
| 7004 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7005 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7006 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7007 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7008 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7009 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7010 | } |
| 7011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7012 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7013 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7014 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7015 | |
| 7016 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7017 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7018 | |
| 7019 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7020 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7021 | "\n" |
| 7022 | "out gl_PerVertex {\n" |
| 7023 | " vec4 gl_Position;\n" |
| 7024 | "};\n" |
| 7025 | "void main(){\n" |
| 7026 | " gl_Position = vec4(1);\n" |
| 7027 | "}\n"; |
| 7028 | char const *fsSource = |
| 7029 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7030 | "\n" |
| 7031 | "in block { layout(location=0) float x; } ins;\n" |
| 7032 | "layout(location=0) out vec4 color;\n" |
| 7033 | "void main(){\n" |
| 7034 | " color = vec4(ins.x);\n" |
| 7035 | "}\n"; |
| 7036 | |
| 7037 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7038 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7039 | |
| 7040 | VkPipelineObj pipe(m_device); |
| 7041 | pipe.AddColorAttachment(); |
| 7042 | pipe.AddShader(&vs); |
| 7043 | pipe.AddShader(&fs); |
| 7044 | |
| 7045 | VkDescriptorSetObj descriptorSet(m_device); |
| 7046 | descriptorSet.AppendDummy(); |
| 7047 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7048 | |
| 7049 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7050 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7051 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7052 | } |
| 7053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7054 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7055 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7056 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | "output arr[2] of float32' vs 'ptr to " |
| 7058 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7059 | |
| 7060 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7061 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7062 | |
| 7063 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7064 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7065 | "\n" |
| 7066 | "layout(location=0) out float x[2];\n" |
| 7067 | "out gl_PerVertex {\n" |
| 7068 | " vec4 gl_Position;\n" |
| 7069 | "};\n" |
| 7070 | "void main(){\n" |
| 7071 | " x[0] = 0; x[1] = 0;\n" |
| 7072 | " gl_Position = vec4(1);\n" |
| 7073 | "}\n"; |
| 7074 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7075 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7076 | "\n" |
| 7077 | "layout(location=0) in float x[3];\n" |
| 7078 | "layout(location=0) out vec4 color;\n" |
| 7079 | "void main(){\n" |
| 7080 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 7081 | "}\n"; |
| 7082 | |
| 7083 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7084 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7085 | |
| 7086 | VkPipelineObj pipe(m_device); |
| 7087 | pipe.AddColorAttachment(); |
| 7088 | pipe.AddShader(&vs); |
| 7089 | pipe.AddShader(&fs); |
| 7090 | |
| 7091 | VkDescriptorSetObj descriptorSet(m_device); |
| 7092 | descriptorSet.AppendDummy(); |
| 7093 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7094 | |
| 7095 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7096 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7097 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7098 | } |
| 7099 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7100 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7101 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7102 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7103 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7106 | |
| 7107 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7108 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7109 | "\n" |
| 7110 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7111 | "out gl_PerVertex {\n" |
| 7112 | " vec4 gl_Position;\n" |
| 7113 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7114 | "void main(){\n" |
| 7115 | " x = 0;\n" |
| 7116 | " gl_Position = vec4(1);\n" |
| 7117 | "}\n"; |
| 7118 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7119 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7120 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7121 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7122 | "layout(location=0) out vec4 color;\n" |
| 7123 | "void main(){\n" |
| 7124 | " color = vec4(x);\n" |
| 7125 | "}\n"; |
| 7126 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7127 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7128 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7129 | |
| 7130 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7131 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7132 | pipe.AddShader(&vs); |
| 7133 | pipe.AddShader(&fs); |
| 7134 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7135 | VkDescriptorSetObj descriptorSet(m_device); |
| 7136 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7137 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7138 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7139 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7140 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7141 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7142 | } |
| 7143 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7144 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7145 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7146 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7147 | |
| 7148 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7149 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7150 | |
| 7151 | char const *vsSource = |
| 7152 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7153 | "\n" |
| 7154 | "out block { layout(location=0) int x; } outs;\n" |
| 7155 | "out gl_PerVertex {\n" |
| 7156 | " vec4 gl_Position;\n" |
| 7157 | "};\n" |
| 7158 | "void main(){\n" |
| 7159 | " outs.x = 0;\n" |
| 7160 | " gl_Position = vec4(1);\n" |
| 7161 | "}\n"; |
| 7162 | char const *fsSource = |
| 7163 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7164 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7165 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7166 | "layout(location=0) out vec4 color;\n" |
| 7167 | "void main(){\n" |
| 7168 | " color = vec4(ins.x);\n" |
| 7169 | "}\n"; |
| 7170 | |
| 7171 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7172 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7173 | |
| 7174 | VkPipelineObj pipe(m_device); |
| 7175 | pipe.AddColorAttachment(); |
| 7176 | pipe.AddShader(&vs); |
| 7177 | pipe.AddShader(&fs); |
| 7178 | |
| 7179 | VkDescriptorSetObj descriptorSet(m_device); |
| 7180 | descriptorSet.AppendDummy(); |
| 7181 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7182 | |
| 7183 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7184 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7185 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7186 | } |
| 7187 | |
| 7188 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 7189 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7190 | "location 0.0 which is not written by vertex shader"); |
| 7191 | |
| 7192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7193 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7194 | |
| 7195 | char const *vsSource = |
| 7196 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7197 | "\n" |
| 7198 | "out block { layout(location=1) float x; } outs;\n" |
| 7199 | "out gl_PerVertex {\n" |
| 7200 | " vec4 gl_Position;\n" |
| 7201 | "};\n" |
| 7202 | "void main(){\n" |
| 7203 | " outs.x = 0;\n" |
| 7204 | " gl_Position = vec4(1);\n" |
| 7205 | "}\n"; |
| 7206 | char const *fsSource = |
| 7207 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7208 | "\n" |
| 7209 | "in block { layout(location=0) float x; } ins;\n" |
| 7210 | "layout(location=0) out vec4 color;\n" |
| 7211 | "void main(){\n" |
| 7212 | " color = vec4(ins.x);\n" |
| 7213 | "}\n"; |
| 7214 | |
| 7215 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7216 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7217 | |
| 7218 | VkPipelineObj pipe(m_device); |
| 7219 | pipe.AddColorAttachment(); |
| 7220 | pipe.AddShader(&vs); |
| 7221 | pipe.AddShader(&fs); |
| 7222 | |
| 7223 | VkDescriptorSetObj descriptorSet(m_device); |
| 7224 | descriptorSet.AppendDummy(); |
| 7225 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7226 | |
| 7227 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7228 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7229 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7230 | } |
| 7231 | |
| 7232 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 7233 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7234 | "location 0.1 which is not written by vertex shader"); |
| 7235 | |
| 7236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7237 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7238 | |
| 7239 | char const *vsSource = |
| 7240 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7241 | "\n" |
| 7242 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 7243 | "out gl_PerVertex {\n" |
| 7244 | " vec4 gl_Position;\n" |
| 7245 | "};\n" |
| 7246 | "void main(){\n" |
| 7247 | " outs.x = 0;\n" |
| 7248 | " gl_Position = vec4(1);\n" |
| 7249 | "}\n"; |
| 7250 | char const *fsSource = |
| 7251 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7252 | "\n" |
| 7253 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 7254 | "layout(location=0) out vec4 color;\n" |
| 7255 | "void main(){\n" |
| 7256 | " color = vec4(ins.x);\n" |
| 7257 | "}\n"; |
| 7258 | |
| 7259 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7260 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7261 | |
| 7262 | VkPipelineObj pipe(m_device); |
| 7263 | pipe.AddColorAttachment(); |
| 7264 | pipe.AddShader(&vs); |
| 7265 | pipe.AddShader(&fs); |
| 7266 | |
| 7267 | VkDescriptorSetObj descriptorSet(m_device); |
| 7268 | descriptorSet.AppendDummy(); |
| 7269 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7270 | |
| 7271 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7272 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7273 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7274 | } |
| 7275 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7276 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7277 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7278 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7279 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7280 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7281 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7282 | |
| 7283 | VkVertexInputBindingDescription input_binding; |
| 7284 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7285 | |
| 7286 | VkVertexInputAttributeDescription input_attrib; |
| 7287 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7288 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7289 | |
| 7290 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7291 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7292 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7293 | "out gl_PerVertex {\n" |
| 7294 | " vec4 gl_Position;\n" |
| 7295 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7296 | "void main(){\n" |
| 7297 | " gl_Position = vec4(1);\n" |
| 7298 | "}\n"; |
| 7299 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7300 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7301 | "\n" |
| 7302 | "layout(location=0) out vec4 color;\n" |
| 7303 | "void main(){\n" |
| 7304 | " color = vec4(1);\n" |
| 7305 | "}\n"; |
| 7306 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7307 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7308 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7309 | |
| 7310 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7311 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7312 | pipe.AddShader(&vs); |
| 7313 | pipe.AddShader(&fs); |
| 7314 | |
| 7315 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7316 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7317 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7318 | VkDescriptorSetObj descriptorSet(m_device); |
| 7319 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7320 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7321 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7322 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7324 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7325 | } |
| 7326 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7327 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7329 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7330 | |
| 7331 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7332 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7333 | |
| 7334 | VkVertexInputBindingDescription input_binding; |
| 7335 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7336 | |
| 7337 | VkVertexInputAttributeDescription input_attrib; |
| 7338 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7339 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7340 | |
| 7341 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7342 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7343 | "\n" |
| 7344 | "layout(location=1) in float x;\n" |
| 7345 | "out gl_PerVertex {\n" |
| 7346 | " vec4 gl_Position;\n" |
| 7347 | "};\n" |
| 7348 | "void main(){\n" |
| 7349 | " gl_Position = vec4(x);\n" |
| 7350 | "}\n"; |
| 7351 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7352 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7353 | "\n" |
| 7354 | "layout(location=0) out vec4 color;\n" |
| 7355 | "void main(){\n" |
| 7356 | " color = vec4(1);\n" |
| 7357 | "}\n"; |
| 7358 | |
| 7359 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7360 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7361 | |
| 7362 | VkPipelineObj pipe(m_device); |
| 7363 | pipe.AddColorAttachment(); |
| 7364 | pipe.AddShader(&vs); |
| 7365 | pipe.AddShader(&fs); |
| 7366 | |
| 7367 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7368 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7369 | |
| 7370 | VkDescriptorSetObj descriptorSet(m_device); |
| 7371 | descriptorSet.AppendDummy(); |
| 7372 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7373 | |
| 7374 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7375 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7376 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7377 | } |
| 7378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7379 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7380 | m_errorMonitor->SetDesiredFailureMsg( |
| 7381 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7382 | "VS consumes input at location 0 but not provided"); |
| 7383 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7385 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7386 | |
| 7387 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7388 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7389 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7390 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7391 | "out gl_PerVertex {\n" |
| 7392 | " vec4 gl_Position;\n" |
| 7393 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7394 | "void main(){\n" |
| 7395 | " gl_Position = x;\n" |
| 7396 | "}\n"; |
| 7397 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7398 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7399 | "\n" |
| 7400 | "layout(location=0) out vec4 color;\n" |
| 7401 | "void main(){\n" |
| 7402 | " color = vec4(1);\n" |
| 7403 | "}\n"; |
| 7404 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7405 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7406 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7407 | |
| 7408 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7409 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7410 | pipe.AddShader(&vs); |
| 7411 | pipe.AddShader(&fs); |
| 7412 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7413 | VkDescriptorSetObj descriptorSet(m_device); |
| 7414 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7415 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7416 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7417 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7418 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7419 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7420 | } |
| 7421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7422 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7423 | m_errorMonitor->SetDesiredFailureMsg( |
| 7424 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7425 | "location 0 does not match VS input type"); |
| 7426 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7427 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7428 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7429 | |
| 7430 | VkVertexInputBindingDescription input_binding; |
| 7431 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7432 | |
| 7433 | VkVertexInputAttributeDescription input_attrib; |
| 7434 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7435 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7436 | |
| 7437 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7438 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7439 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7440 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7441 | "out gl_PerVertex {\n" |
| 7442 | " vec4 gl_Position;\n" |
| 7443 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7444 | "void main(){\n" |
| 7445 | " gl_Position = vec4(x);\n" |
| 7446 | "}\n"; |
| 7447 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7448 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7449 | "\n" |
| 7450 | "layout(location=0) out vec4 color;\n" |
| 7451 | "void main(){\n" |
| 7452 | " color = vec4(1);\n" |
| 7453 | "}\n"; |
| 7454 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7455 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7456 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7457 | |
| 7458 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7459 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7460 | pipe.AddShader(&vs); |
| 7461 | pipe.AddShader(&fs); |
| 7462 | |
| 7463 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7464 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7465 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7466 | VkDescriptorSetObj descriptorSet(m_device); |
| 7467 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7468 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7469 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7470 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7471 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7472 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7473 | } |
| 7474 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7475 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7476 | m_errorMonitor->SetDesiredFailureMsg( |
| 7477 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7478 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7479 | |
| 7480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7482 | |
| 7483 | char const *vsSource = |
| 7484 | "#version 450\n" |
| 7485 | "\n" |
| 7486 | "out gl_PerVertex {\n" |
| 7487 | " vec4 gl_Position;\n" |
| 7488 | "};\n" |
| 7489 | "void main(){\n" |
| 7490 | " gl_Position = vec4(1);\n" |
| 7491 | "}\n"; |
| 7492 | char const *fsSource = |
| 7493 | "#version 450\n" |
| 7494 | "\n" |
| 7495 | "layout(location=0) out vec4 color;\n" |
| 7496 | "void main(){\n" |
| 7497 | " color = vec4(1);\n" |
| 7498 | "}\n"; |
| 7499 | |
| 7500 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7501 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7502 | |
| 7503 | VkPipelineObj pipe(m_device); |
| 7504 | pipe.AddColorAttachment(); |
| 7505 | pipe.AddShader(&vs); |
| 7506 | pipe.AddShader(&vs); |
| 7507 | pipe.AddShader(&fs); |
| 7508 | |
| 7509 | VkDescriptorSetObj descriptorSet(m_device); |
| 7510 | descriptorSet.AppendDummy(); |
| 7511 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7512 | |
| 7513 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7514 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7515 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7516 | } |
| 7517 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7518 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7519 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7520 | |
| 7521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7522 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7523 | |
| 7524 | VkVertexInputBindingDescription input_binding; |
| 7525 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7526 | |
| 7527 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7528 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7529 | |
| 7530 | for (int i = 0; i < 2; i++) { |
| 7531 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7532 | input_attribs[i].location = i; |
| 7533 | } |
| 7534 | |
| 7535 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7536 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7537 | "\n" |
| 7538 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7539 | "out gl_PerVertex {\n" |
| 7540 | " vec4 gl_Position;\n" |
| 7541 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7542 | "void main(){\n" |
| 7543 | " gl_Position = x[0] + x[1];\n" |
| 7544 | "}\n"; |
| 7545 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7546 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7547 | "\n" |
| 7548 | "layout(location=0) out vec4 color;\n" |
| 7549 | "void main(){\n" |
| 7550 | " color = vec4(1);\n" |
| 7551 | "}\n"; |
| 7552 | |
| 7553 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7554 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7555 | |
| 7556 | VkPipelineObj pipe(m_device); |
| 7557 | pipe.AddColorAttachment(); |
| 7558 | pipe.AddShader(&vs); |
| 7559 | pipe.AddShader(&fs); |
| 7560 | |
| 7561 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7562 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7563 | |
| 7564 | VkDescriptorSetObj descriptorSet(m_device); |
| 7565 | descriptorSet.AppendDummy(); |
| 7566 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7567 | |
| 7568 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7569 | |
| 7570 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7571 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7572 | } |
| 7573 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7574 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7575 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7576 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7577 | |
| 7578 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7579 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7580 | |
| 7581 | VkVertexInputBindingDescription input_binding; |
| 7582 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7583 | |
| 7584 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7585 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7586 | |
| 7587 | for (int i = 0; i < 2; i++) { |
| 7588 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7589 | input_attribs[i].location = i; |
| 7590 | } |
| 7591 | |
| 7592 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7593 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7594 | "\n" |
| 7595 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7596 | "out gl_PerVertex {\n" |
| 7597 | " vec4 gl_Position;\n" |
| 7598 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7599 | "void main(){\n" |
| 7600 | " gl_Position = x[0] + x[1];\n" |
| 7601 | "}\n"; |
| 7602 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7603 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7604 | "\n" |
| 7605 | "layout(location=0) out vec4 color;\n" |
| 7606 | "void main(){\n" |
| 7607 | " color = vec4(1);\n" |
| 7608 | "}\n"; |
| 7609 | |
| 7610 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7611 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7612 | |
| 7613 | VkPipelineObj pipe(m_device); |
| 7614 | pipe.AddColorAttachment(); |
| 7615 | pipe.AddShader(&vs); |
| 7616 | pipe.AddShader(&fs); |
| 7617 | |
| 7618 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7619 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7620 | |
| 7621 | VkDescriptorSetObj descriptorSet(m_device); |
| 7622 | descriptorSet.AppendDummy(); |
| 7623 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7624 | |
| 7625 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7626 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7627 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7628 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7629 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7630 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7631 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7632 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7633 | |
| 7634 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7635 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7636 | |
| 7637 | char const *vsSource = |
| 7638 | "#version 450\n" |
| 7639 | "out gl_PerVertex {\n" |
| 7640 | " vec4 gl_Position;\n" |
| 7641 | "};\n" |
| 7642 | "void main(){\n" |
| 7643 | " gl_Position = vec4(0);\n" |
| 7644 | "}\n"; |
| 7645 | char const *fsSource = |
| 7646 | "#version 450\n" |
| 7647 | "\n" |
| 7648 | "layout(location=0) out vec4 color;\n" |
| 7649 | "void main(){\n" |
| 7650 | " color = vec4(1);\n" |
| 7651 | "}\n"; |
| 7652 | |
| 7653 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7654 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7655 | |
| 7656 | VkPipelineObj pipe(m_device); |
| 7657 | pipe.AddColorAttachment(); |
| 7658 | pipe.AddShader(&vs); |
| 7659 | pipe.AddShader(&fs); |
| 7660 | |
| 7661 | VkDescriptorSetObj descriptorSet(m_device); |
| 7662 | descriptorSet.AppendDummy(); |
| 7663 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7664 | |
| 7665 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7666 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7667 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7668 | } |
| 7669 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7670 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7671 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7672 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7673 | |
| 7674 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7675 | |
| 7676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7677 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7678 | |
| 7679 | char const *vsSource = |
| 7680 | "#version 450\n" |
| 7681 | "out gl_PerVertex {\n" |
| 7682 | " vec4 gl_Position;\n" |
| 7683 | "};\n" |
| 7684 | "layout(location=0) out vec3 x;\n" |
| 7685 | "layout(location=1) out ivec3 y;\n" |
| 7686 | "layout(location=2) out vec3 z;\n" |
| 7687 | "void main(){\n" |
| 7688 | " gl_Position = vec4(0);\n" |
| 7689 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7690 | "}\n"; |
| 7691 | char const *fsSource = |
| 7692 | "#version 450\n" |
| 7693 | "\n" |
| 7694 | "layout(location=0) out vec4 color;\n" |
| 7695 | "layout(location=0) in float x;\n" |
| 7696 | "layout(location=1) flat in int y;\n" |
| 7697 | "layout(location=2) in vec2 z;\n" |
| 7698 | "void main(){\n" |
| 7699 | " color = vec4(1 + x + y + z.x);\n" |
| 7700 | "}\n"; |
| 7701 | |
| 7702 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7703 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7704 | |
| 7705 | VkPipelineObj pipe(m_device); |
| 7706 | pipe.AddColorAttachment(); |
| 7707 | pipe.AddShader(&vs); |
| 7708 | pipe.AddShader(&fs); |
| 7709 | |
| 7710 | VkDescriptorSetObj descriptorSet(m_device); |
| 7711 | descriptorSet.AppendDummy(); |
| 7712 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7713 | |
| 7714 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7715 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7716 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7717 | } |
| 7718 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7719 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7720 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7721 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7722 | |
| 7723 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7724 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7725 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7726 | if (!m_device->phy().features().tessellationShader) { |
| 7727 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7728 | return; |
| 7729 | } |
| 7730 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7731 | char const *vsSource = |
| 7732 | "#version 450\n" |
| 7733 | "void main(){}\n"; |
| 7734 | char const *tcsSource = |
| 7735 | "#version 450\n" |
| 7736 | "layout(location=0) out int x[];\n" |
| 7737 | "layout(vertices=3) out;\n" |
| 7738 | "void main(){\n" |
| 7739 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7740 | " gl_TessLevelInner[0] = 1;\n" |
| 7741 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7742 | "}\n"; |
| 7743 | char const *tesSource = |
| 7744 | "#version 450\n" |
| 7745 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7746 | "layout(location=0) in int x[];\n" |
| 7747 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7748 | "void main(){\n" |
| 7749 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7750 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7751 | "}\n"; |
| 7752 | char const *fsSource = |
| 7753 | "#version 450\n" |
| 7754 | "layout(location=0) out vec4 color;\n" |
| 7755 | "void main(){\n" |
| 7756 | " color = vec4(1);\n" |
| 7757 | "}\n"; |
| 7758 | |
| 7759 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7760 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7761 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7762 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7763 | |
| 7764 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7765 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7766 | nullptr, |
| 7767 | 0, |
| 7768 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7769 | VK_FALSE}; |
| 7770 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7771 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7772 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7773 | nullptr, |
| 7774 | 0, |
| 7775 | 3}; |
| 7776 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7777 | VkPipelineObj pipe(m_device); |
| 7778 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7779 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7780 | pipe.AddColorAttachment(); |
| 7781 | pipe.AddShader(&vs); |
| 7782 | pipe.AddShader(&tcs); |
| 7783 | pipe.AddShader(&tes); |
| 7784 | pipe.AddShader(&fs); |
| 7785 | |
| 7786 | VkDescriptorSetObj descriptorSet(m_device); |
| 7787 | descriptorSet.AppendDummy(); |
| 7788 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7789 | |
| 7790 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7791 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7792 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7793 | } |
| 7794 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7795 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7796 | { |
| 7797 | m_errorMonitor->ExpectSuccess(); |
| 7798 | |
| 7799 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7800 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7801 | |
| 7802 | if (!m_device->phy().features().geometryShader) { |
| 7803 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7804 | return; |
| 7805 | } |
| 7806 | |
| 7807 | char const *vsSource = |
| 7808 | "#version 450\n" |
| 7809 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7810 | "void main(){\n" |
| 7811 | " vs_out.x = vec4(1);\n" |
| 7812 | "}\n"; |
| 7813 | char const *gsSource = |
| 7814 | "#version 450\n" |
| 7815 | "layout(triangles) in;\n" |
| 7816 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7817 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7818 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7819 | "void main() {\n" |
| 7820 | " gl_Position = gs_in[0].x;\n" |
| 7821 | " EmitVertex();\n" |
| 7822 | "}\n"; |
| 7823 | char const *fsSource = |
| 7824 | "#version 450\n" |
| 7825 | "layout(location=0) out vec4 color;\n" |
| 7826 | "void main(){\n" |
| 7827 | " color = vec4(1);\n" |
| 7828 | "}\n"; |
| 7829 | |
| 7830 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7831 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7832 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7833 | |
| 7834 | VkPipelineObj pipe(m_device); |
| 7835 | pipe.AddColorAttachment(); |
| 7836 | pipe.AddShader(&vs); |
| 7837 | pipe.AddShader(&gs); |
| 7838 | pipe.AddShader(&fs); |
| 7839 | |
| 7840 | VkDescriptorSetObj descriptorSet(m_device); |
| 7841 | descriptorSet.AppendDummy(); |
| 7842 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7843 | |
| 7844 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7845 | |
| 7846 | m_errorMonitor->VerifyNotFound(); |
| 7847 | } |
| 7848 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7849 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7850 | { |
| 7851 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7852 | "is per-vertex in tessellation control shader stage " |
| 7853 | "but per-patch in tessellation evaluation shader stage"); |
| 7854 | |
| 7855 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7856 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7857 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7858 | if (!m_device->phy().features().tessellationShader) { |
| 7859 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7860 | return; |
| 7861 | } |
| 7862 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7863 | char const *vsSource = |
| 7864 | "#version 450\n" |
| 7865 | "void main(){}\n"; |
| 7866 | char const *tcsSource = |
| 7867 | "#version 450\n" |
| 7868 | "layout(location=0) out int x[];\n" |
| 7869 | "layout(vertices=3) out;\n" |
| 7870 | "void main(){\n" |
| 7871 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7872 | " gl_TessLevelInner[0] = 1;\n" |
| 7873 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7874 | "}\n"; |
| 7875 | char const *tesSource = |
| 7876 | "#version 450\n" |
| 7877 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7878 | "layout(location=0) patch in int x;\n" |
| 7879 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7880 | "void main(){\n" |
| 7881 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7882 | " gl_Position.w = x;\n" |
| 7883 | "}\n"; |
| 7884 | char const *fsSource = |
| 7885 | "#version 450\n" |
| 7886 | "layout(location=0) out vec4 color;\n" |
| 7887 | "void main(){\n" |
| 7888 | " color = vec4(1);\n" |
| 7889 | "}\n"; |
| 7890 | |
| 7891 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7892 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7893 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7894 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7895 | |
| 7896 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7897 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7898 | nullptr, |
| 7899 | 0, |
| 7900 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7901 | VK_FALSE}; |
| 7902 | |
| 7903 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7904 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7905 | nullptr, |
| 7906 | 0, |
| 7907 | 3}; |
| 7908 | |
| 7909 | VkPipelineObj pipe(m_device); |
| 7910 | pipe.SetInputAssembly(&iasci); |
| 7911 | pipe.SetTessellation(&tsci); |
| 7912 | pipe.AddColorAttachment(); |
| 7913 | pipe.AddShader(&vs); |
| 7914 | pipe.AddShader(&tcs); |
| 7915 | pipe.AddShader(&tes); |
| 7916 | pipe.AddShader(&fs); |
| 7917 | |
| 7918 | VkDescriptorSetObj descriptorSet(m_device); |
| 7919 | descriptorSet.AppendDummy(); |
| 7920 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7921 | |
| 7922 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7923 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7924 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7925 | } |
| 7926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7927 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7928 | m_errorMonitor->SetDesiredFailureMsg( |
| 7929 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7930 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7931 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7932 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7933 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7934 | |
| 7935 | /* Two binding descriptions for binding 0 */ |
| 7936 | VkVertexInputBindingDescription input_bindings[2]; |
| 7937 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7938 | |
| 7939 | VkVertexInputAttributeDescription input_attrib; |
| 7940 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7941 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7942 | |
| 7943 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7944 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7945 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7946 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7947 | "out gl_PerVertex {\n" |
| 7948 | " vec4 gl_Position;\n" |
| 7949 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7950 | "void main(){\n" |
| 7951 | " gl_Position = vec4(x);\n" |
| 7952 | "}\n"; |
| 7953 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7954 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7955 | "\n" |
| 7956 | "layout(location=0) out vec4 color;\n" |
| 7957 | "void main(){\n" |
| 7958 | " color = vec4(1);\n" |
| 7959 | "}\n"; |
| 7960 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7961 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7962 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7963 | |
| 7964 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7965 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7966 | pipe.AddShader(&vs); |
| 7967 | pipe.AddShader(&fs); |
| 7968 | |
| 7969 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7970 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7971 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7972 | VkDescriptorSetObj descriptorSet(m_device); |
| 7973 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7974 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7975 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7976 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7977 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7978 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7979 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7980 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7981 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7982 | m_errorMonitor->ExpectSuccess(); |
| 7983 | |
| 7984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7985 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7986 | |
| 7987 | if (!m_device->phy().features().tessellationShader) { |
| 7988 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7989 | return; |
| 7990 | } |
| 7991 | |
| 7992 | VkVertexInputBindingDescription input_bindings[1]; |
| 7993 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7994 | |
| 7995 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7996 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7997 | input_attribs[0].location = 0; |
| 7998 | input_attribs[0].offset = 0; |
| 7999 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8000 | input_attribs[1].location = 2; |
| 8001 | input_attribs[1].offset = 32; |
| 8002 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8003 | input_attribs[2].location = 4; |
| 8004 | input_attribs[2].offset = 64; |
| 8005 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8006 | input_attribs[3].location = 6; |
| 8007 | input_attribs[3].offset = 96; |
| 8008 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8009 | |
| 8010 | char const *vsSource = |
| 8011 | "#version 450\n" |
| 8012 | "\n" |
| 8013 | "layout(location=0) in dmat4 x;\n" |
| 8014 | "out gl_PerVertex {\n" |
| 8015 | " vec4 gl_Position;\n" |
| 8016 | "};\n" |
| 8017 | "void main(){\n" |
| 8018 | " gl_Position = vec4(x[0][0]);\n" |
| 8019 | "}\n"; |
| 8020 | char const *fsSource = |
| 8021 | "#version 450\n" |
| 8022 | "\n" |
| 8023 | "layout(location=0) out vec4 color;\n" |
| 8024 | "void main(){\n" |
| 8025 | " color = vec4(1);\n" |
| 8026 | "}\n"; |
| 8027 | |
| 8028 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8029 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8030 | |
| 8031 | VkPipelineObj pipe(m_device); |
| 8032 | pipe.AddColorAttachment(); |
| 8033 | pipe.AddShader(&vs); |
| 8034 | pipe.AddShader(&fs); |
| 8035 | |
| 8036 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 8037 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 8038 | |
| 8039 | VkDescriptorSetObj descriptorSet(m_device); |
| 8040 | descriptorSet.AppendDummy(); |
| 8041 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8042 | |
| 8043 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8044 | |
| 8045 | m_errorMonitor->VerifyNotFound(); |
| 8046 | } |
| 8047 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8048 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8049 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8050 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8051 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8052 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8053 | |
| 8054 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8055 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8056 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8057 | "out gl_PerVertex {\n" |
| 8058 | " vec4 gl_Position;\n" |
| 8059 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8060 | "void main(){\n" |
| 8061 | " gl_Position = vec4(1);\n" |
| 8062 | "}\n"; |
| 8063 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8064 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8065 | "\n" |
| 8066 | "void main(){\n" |
| 8067 | "}\n"; |
| 8068 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8069 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8070 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8071 | |
| 8072 | VkPipelineObj pipe(m_device); |
| 8073 | pipe.AddShader(&vs); |
| 8074 | pipe.AddShader(&fs); |
| 8075 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8076 | /* set up CB 0, not written */ |
| 8077 | pipe.AddColorAttachment(); |
| 8078 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8079 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8080 | VkDescriptorSetObj descriptorSet(m_device); |
| 8081 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8082 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8083 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8084 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8085 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8086 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8087 | } |
| 8088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8089 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8090 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8091 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8092 | "FS writes to output location 1 with no matching attachment"); |
| 8093 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8094 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8095 | |
| 8096 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8097 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8098 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8099 | "out gl_PerVertex {\n" |
| 8100 | " vec4 gl_Position;\n" |
| 8101 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8102 | "void main(){\n" |
| 8103 | " gl_Position = vec4(1);\n" |
| 8104 | "}\n"; |
| 8105 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8106 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8107 | "\n" |
| 8108 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8109 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8110 | "void main(){\n" |
| 8111 | " x = vec4(1);\n" |
| 8112 | " y = vec4(1);\n" |
| 8113 | "}\n"; |
| 8114 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8115 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8116 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8117 | |
| 8118 | VkPipelineObj pipe(m_device); |
| 8119 | pipe.AddShader(&vs); |
| 8120 | pipe.AddShader(&fs); |
| 8121 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8122 | /* set up CB 0, not written */ |
| 8123 | pipe.AddColorAttachment(); |
| 8124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8125 | /* FS writes CB 1, but we don't configure it */ |
| 8126 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8127 | VkDescriptorSetObj descriptorSet(m_device); |
| 8128 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8129 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8130 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8131 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8132 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8133 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8134 | } |
| 8135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8136 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8137 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8138 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8139 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8141 | |
| 8142 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8143 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8144 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8145 | "out gl_PerVertex {\n" |
| 8146 | " vec4 gl_Position;\n" |
| 8147 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8148 | "void main(){\n" |
| 8149 | " gl_Position = vec4(1);\n" |
| 8150 | "}\n"; |
| 8151 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8152 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8153 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8154 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8155 | "void main(){\n" |
| 8156 | " x = ivec4(1);\n" |
| 8157 | "}\n"; |
| 8158 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8159 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8160 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8161 | |
| 8162 | VkPipelineObj pipe(m_device); |
| 8163 | pipe.AddShader(&vs); |
| 8164 | pipe.AddShader(&fs); |
| 8165 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8166 | /* set up CB 0; type is UNORM by default */ |
| 8167 | pipe.AddColorAttachment(); |
| 8168 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8169 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8170 | VkDescriptorSetObj descriptorSet(m_device); |
| 8171 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8172 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8173 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8174 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8175 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8176 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8177 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 8178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8179 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8180 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8181 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8182 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8183 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8184 | |
| 8185 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8186 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8187 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8188 | "out gl_PerVertex {\n" |
| 8189 | " vec4 gl_Position;\n" |
| 8190 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8191 | "void main(){\n" |
| 8192 | " gl_Position = vec4(1);\n" |
| 8193 | "}\n"; |
| 8194 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8195 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8196 | "\n" |
| 8197 | "layout(location=0) out vec4 x;\n" |
| 8198 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 8199 | "void main(){\n" |
| 8200 | " x = vec4(bar.y);\n" |
| 8201 | "}\n"; |
| 8202 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8203 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8204 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8205 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8206 | VkPipelineObj pipe(m_device); |
| 8207 | pipe.AddShader(&vs); |
| 8208 | pipe.AddShader(&fs); |
| 8209 | |
| 8210 | /* set up CB 0; type is UNORM by default */ |
| 8211 | pipe.AddColorAttachment(); |
| 8212 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8213 | |
| 8214 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8215 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8216 | |
| 8217 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8218 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8219 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8220 | } |
| 8221 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8222 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 8223 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8224 | "not declared in layout"); |
| 8225 | |
| 8226 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8227 | |
| 8228 | char const *vsSource = |
| 8229 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8230 | "\n" |
| 8231 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 8232 | "out gl_PerVertex {\n" |
| 8233 | " vec4 gl_Position;\n" |
| 8234 | "};\n" |
| 8235 | "void main(){\n" |
| 8236 | " gl_Position = vec4(consts.x);\n" |
| 8237 | "}\n"; |
| 8238 | char const *fsSource = |
| 8239 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8240 | "\n" |
| 8241 | "layout(location=0) out vec4 x;\n" |
| 8242 | "void main(){\n" |
| 8243 | " x = vec4(1);\n" |
| 8244 | "}\n"; |
| 8245 | |
| 8246 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8247 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8248 | |
| 8249 | VkPipelineObj pipe(m_device); |
| 8250 | pipe.AddShader(&vs); |
| 8251 | pipe.AddShader(&fs); |
| 8252 | |
| 8253 | /* set up CB 0; type is UNORM by default */ |
| 8254 | pipe.AddColorAttachment(); |
| 8255 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8256 | |
| 8257 | VkDescriptorSetObj descriptorSet(m_device); |
| 8258 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8259 | |
| 8260 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8261 | |
| 8262 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8263 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8264 | } |
| 8265 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8266 | #endif // SHADER_CHECKER_TESTS |
| 8267 | |
| 8268 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8269 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8270 | m_errorMonitor->SetDesiredFailureMsg( |
| 8271 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8272 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8273 | |
| 8274 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8275 | |
| 8276 | // Create an image |
| 8277 | VkImage image; |
| 8278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8279 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8280 | const int32_t tex_width = 32; |
| 8281 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8282 | |
| 8283 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8284 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8285 | image_create_info.pNext = NULL; |
| 8286 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8287 | image_create_info.format = tex_format; |
| 8288 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8289 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8290 | image_create_info.extent.depth = 1; |
| 8291 | image_create_info.mipLevels = 1; |
| 8292 | image_create_info.arrayLayers = 1; |
| 8293 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8294 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8295 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8296 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8297 | |
| 8298 | // Introduce error by sending down a bogus width extent |
| 8299 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8300 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8301 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8302 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8303 | } |
| 8304 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8305 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8306 | m_errorMonitor->SetDesiredFailureMsg( |
| 8307 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8308 | "CreateImage extents is 0 for at least one required dimension"); |
| 8309 | |
| 8310 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8311 | |
| 8312 | // Create an image |
| 8313 | VkImage image; |
| 8314 | |
| 8315 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8316 | const int32_t tex_width = 32; |
| 8317 | const int32_t tex_height = 32; |
| 8318 | |
| 8319 | VkImageCreateInfo image_create_info = {}; |
| 8320 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8321 | image_create_info.pNext = NULL; |
| 8322 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8323 | image_create_info.format = tex_format; |
| 8324 | image_create_info.extent.width = tex_width; |
| 8325 | image_create_info.extent.height = tex_height; |
| 8326 | image_create_info.extent.depth = 1; |
| 8327 | image_create_info.mipLevels = 1; |
| 8328 | image_create_info.arrayLayers = 1; |
| 8329 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8330 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8331 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8332 | image_create_info.flags = 0; |
| 8333 | |
| 8334 | // Introduce error by sending down a bogus width extent |
| 8335 | image_create_info.extent.width = 0; |
| 8336 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8337 | |
| 8338 | m_errorMonitor->VerifyFound(); |
| 8339 | } |
| 8340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8341 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8342 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8343 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8344 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8346 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8348 | |
| 8349 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8350 | vk_testing::Buffer buffer; |
| 8351 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8352 | |
| 8353 | BeginCommandBuffer(); |
| 8354 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8355 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8356 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8357 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8358 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8359 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8360 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8361 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8362 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8363 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8364 | EndCommandBuffer(); |
| 8365 | } |
| 8366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8367 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8368 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8369 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8370 | |
| 8371 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8372 | |
| 8373 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8374 | vk_testing::Buffer buffer; |
| 8375 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8376 | |
| 8377 | BeginCommandBuffer(); |
| 8378 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8379 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8380 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8381 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8382 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8383 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8384 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8385 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8386 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8387 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8388 | m_errorMonitor->VerifyFound(); |
| 8389 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8390 | EndCommandBuffer(); |
| 8391 | } |
| 8392 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8393 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8394 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8395 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8396 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8397 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8398 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8399 | m_errorMonitor->SetDesiredFailureMsg( |
| 8400 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8401 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8402 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8404 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8405 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8406 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8407 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8408 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8409 | const int32_t tex_width = 32; |
| 8410 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8411 | |
| 8412 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8413 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8414 | image_create_info.pNext = NULL; |
| 8415 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8416 | image_create_info.format = tex_format; |
| 8417 | image_create_info.extent.width = tex_width; |
| 8418 | image_create_info.extent.height = tex_height; |
| 8419 | image_create_info.extent.depth = 1; |
| 8420 | image_create_info.mipLevels = 1; |
| 8421 | image_create_info.arrayLayers = 1; |
| 8422 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8423 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8424 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8425 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8426 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8427 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8428 | ASSERT_VK_SUCCESS(err); |
| 8429 | |
| 8430 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8431 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8432 | image_view_create_info.image = image; |
| 8433 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8434 | image_view_create_info.format = tex_format; |
| 8435 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8436 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8437 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8438 | image_view_create_info.subresourceRange.aspectMask = |
| 8439 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8440 | |
| 8441 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8442 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8443 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8444 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8445 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8446 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8447 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8448 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8449 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8450 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8451 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8452 | "vkCreateImageView: Color image " |
| 8453 | "formats must have ONLY the " |
| 8454 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8455 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8456 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8457 | |
| 8458 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8459 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8460 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8461 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8462 | const int32_t tex_width = 32; |
| 8463 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8464 | |
| 8465 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8466 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8467 | image_create_info.pNext = NULL; |
| 8468 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8469 | image_create_info.format = tex_format; |
| 8470 | image_create_info.extent.width = tex_width; |
| 8471 | image_create_info.extent.height = tex_height; |
| 8472 | image_create_info.extent.depth = 1; |
| 8473 | image_create_info.mipLevels = 1; |
| 8474 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8475 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8476 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8477 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8478 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8479 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8480 | ASSERT_VK_SUCCESS(err); |
| 8481 | |
| 8482 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8483 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8484 | image_view_create_info.image = image; |
| 8485 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8486 | image_view_create_info.format = tex_format; |
| 8487 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8488 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8489 | // Cause an error by setting an invalid image aspect |
| 8490 | image_view_create_info.subresourceRange.aspectMask = |
| 8491 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8492 | |
| 8493 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8494 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8495 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8496 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8497 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8498 | } |
| 8499 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8500 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8501 | VkResult err; |
| 8502 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8503 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8504 | m_errorMonitor->SetDesiredFailureMsg( |
| 8505 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8506 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8507 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8509 | |
| 8510 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8511 | VkImage srcImage; |
| 8512 | VkImage dstImage; |
| 8513 | VkDeviceMemory srcMem; |
| 8514 | VkDeviceMemory destMem; |
| 8515 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8516 | |
| 8517 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8518 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8519 | image_create_info.pNext = NULL; |
| 8520 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8521 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8522 | image_create_info.extent.width = 32; |
| 8523 | image_create_info.extent.height = 32; |
| 8524 | image_create_info.extent.depth = 1; |
| 8525 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8526 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8527 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8528 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8529 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8530 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8532 | err = |
| 8533 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8534 | ASSERT_VK_SUCCESS(err); |
| 8535 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8536 | err = |
| 8537 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8538 | ASSERT_VK_SUCCESS(err); |
| 8539 | |
| 8540 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8541 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8542 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8543 | memAlloc.pNext = NULL; |
| 8544 | memAlloc.allocationSize = 0; |
| 8545 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8546 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8547 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8548 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8549 | pass = |
| 8550 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8551 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8552 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8553 | ASSERT_VK_SUCCESS(err); |
| 8554 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8555 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8556 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8557 | pass = |
| 8558 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8559 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8560 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8561 | ASSERT_VK_SUCCESS(err); |
| 8562 | |
| 8563 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8564 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8565 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8566 | ASSERT_VK_SUCCESS(err); |
| 8567 | |
| 8568 | BeginCommandBuffer(); |
| 8569 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8570 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8571 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8572 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8573 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8574 | copyRegion.srcOffset.x = 0; |
| 8575 | copyRegion.srcOffset.y = 0; |
| 8576 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8577 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8578 | copyRegion.dstSubresource.mipLevel = 0; |
| 8579 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8580 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8581 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8582 | copyRegion.dstOffset.x = 0; |
| 8583 | copyRegion.dstOffset.y = 0; |
| 8584 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8585 | copyRegion.extent.width = 1; |
| 8586 | copyRegion.extent.height = 1; |
| 8587 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8588 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8589 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8590 | EndCommandBuffer(); |
| 8591 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8592 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8593 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8594 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8595 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8596 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8597 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8598 | } |
| 8599 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 8600 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 8601 | |
| 8602 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 8603 | |
| 8604 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8605 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8606 | VkImageObj image(m_device); |
| 8607 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8608 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8609 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8610 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8611 | ASSERT_TRUE(image.initialized()); |
| 8612 | |
| 8613 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 8614 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 8615 | VkFormat format = static_cast<VkFormat>(f); |
| 8616 | VkFormatProperties fProps = m_device->format_properties(format); |
| 8617 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 8618 | fProps.optimalTilingFeatures == 0) { |
| 8619 | unsupported = format; |
| 8620 | break; |
| 8621 | } |
| 8622 | } |
| 8623 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 8624 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8625 | "vkCreateImage parameter, " |
| 8626 | "VkFormat pCreateInfo->format, " |
| 8627 | "contains unsupported format"); |
| 8628 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8629 | VkImageCreateInfo image_create_info; |
| 8630 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8631 | image_create_info.pNext = NULL; |
| 8632 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8633 | image_create_info.format = unsupported; |
| 8634 | image_create_info.extent.width = 32; |
| 8635 | image_create_info.extent.height = 32; |
| 8636 | image_create_info.extent.depth = 1; |
| 8637 | image_create_info.mipLevels = 1; |
| 8638 | image_create_info.arrayLayers = 1; |
| 8639 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8640 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8641 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8642 | image_create_info.flags = 0; |
| 8643 | |
| 8644 | VkImage localImage; |
| 8645 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 8646 | m_errorMonitor->VerifyFound(); |
| 8647 | |
| 8648 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8649 | "vkCreateRenderPass parameter, " |
| 8650 | "VkFormat in " |
| 8651 | "pCreateInfo->pAttachments"); |
| 8652 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8653 | VkAttachmentDescription att; |
| 8654 | att.format = unsupported; |
| 8655 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8656 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 8657 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8658 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8659 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8660 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8661 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8662 | |
| 8663 | VkRenderPassCreateInfo rp_info = {}; |
| 8664 | VkRenderPass rp; |
| 8665 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8666 | rp_info.attachmentCount = 1; |
| 8667 | rp_info.pAttachments = &att; |
| 8668 | rp_info.subpassCount = 0; |
| 8669 | rp_info.pSubpasses = NULL; |
| 8670 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 8671 | m_errorMonitor->VerifyFound(); |
| 8672 | } |
| 8673 | } |
| 8674 | |
| 8675 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 8676 | VkResult ret; |
| 8677 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 8678 | |
| 8679 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8680 | |
| 8681 | VkImageObj image(m_device); |
| 8682 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8683 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8684 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8685 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8686 | ASSERT_TRUE(image.initialized()); |
| 8687 | |
| 8688 | VkImageView imgView; |
| 8689 | VkImageViewCreateInfo imgViewInfo = {}; |
| 8690 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8691 | imgViewInfo.image = image.handle(); |
| 8692 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8693 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8694 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8695 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8696 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8697 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8698 | |
| 8699 | m_errorMonitor->SetDesiredFailureMsg( |
| 8700 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8701 | "vkCreateImageView called with baseMipLevel"); |
| 8702 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 8703 | // VIEW_CREATE_ERROR |
| 8704 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 8705 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8706 | m_errorMonitor->VerifyFound(); |
| 8707 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8708 | |
| 8709 | m_errorMonitor->SetDesiredFailureMsg( |
| 8710 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8711 | "vkCreateImageView called with baseArrayLayer"); |
| 8712 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 8713 | // VIEW_CREATE_ERROR |
| 8714 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 8715 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8716 | m_errorMonitor->VerifyFound(); |
| 8717 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 8718 | |
| 8719 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8720 | "vkCreateImageView called with 0 in " |
| 8721 | "pCreateInfo->subresourceRange." |
| 8722 | "levelCount"); |
| 8723 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8724 | imgViewInfo.subresourceRange.levelCount = 0; |
| 8725 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8726 | m_errorMonitor->VerifyFound(); |
| 8727 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8728 | |
| 8729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8730 | "vkCreateImageView called with 0 in " |
| 8731 | "pCreateInfo->subresourceRange." |
| 8732 | "layerCount"); |
| 8733 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8734 | imgViewInfo.subresourceRange.layerCount = 0; |
| 8735 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8736 | m_errorMonitor->VerifyFound(); |
| 8737 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8738 | |
| 8739 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8740 | "but both must be color formats"); |
| 8741 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 8742 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8743 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8744 | m_errorMonitor->VerifyFound(); |
| 8745 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8746 | |
| 8747 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8748 | "Formats MUST be IDENTICAL unless " |
| 8749 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 8750 | "was set on image creation."); |
| 8751 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 8752 | // VIEW_CREATE_ERROR |
| 8753 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 8754 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8755 | m_errorMonitor->VerifyFound(); |
| 8756 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8757 | |
| 8758 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8759 | "can support ImageViews with " |
| 8760 | "differing formats but they must be " |
| 8761 | "in the same compatibility class."); |
| 8762 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 8763 | // VIEW_CREATE_ERROR |
| 8764 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 8765 | VkImage mutImage; |
| 8766 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 8767 | assert( |
| 8768 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 8769 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 8770 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 8771 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8772 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 8773 | ASSERT_VK_SUCCESS(ret); |
| 8774 | imgViewInfo.image = mutImage; |
| 8775 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8776 | m_errorMonitor->VerifyFound(); |
| 8777 | imgViewInfo.image = image.handle(); |
| 8778 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 8779 | } |
| 8780 | |
| 8781 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 8782 | |
| 8783 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 8784 | |
| 8785 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8786 | |
| 8787 | VkImageObj image(m_device); |
| 8788 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8789 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8790 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8791 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8792 | ASSERT_TRUE(image.initialized()); |
| 8793 | |
| 8794 | m_errorMonitor->SetDesiredFailureMsg( |
| 8795 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8796 | "number of layers in image subresource is zero"); |
| 8797 | vk_testing::Buffer buffer; |
| 8798 | VkMemoryPropertyFlags reqs = 0; |
| 8799 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 8800 | VkBufferImageCopy region = {}; |
| 8801 | region.bufferRowLength = 128; |
| 8802 | region.bufferImageHeight = 128; |
| 8803 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8804 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 8805 | region.imageSubresource.layerCount = 0; |
| 8806 | region.imageExtent.height = 4; |
| 8807 | region.imageExtent.width = 4; |
| 8808 | region.imageExtent.depth = 1; |
| 8809 | m_commandBuffer->BeginCommandBuffer(); |
| 8810 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8811 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8812 | 1, ®ion); |
| 8813 | m_errorMonitor->VerifyFound(); |
| 8814 | region.imageSubresource.layerCount = 1; |
| 8815 | |
| 8816 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8817 | "aspectMasks for each region must " |
| 8818 | "specify only COLOR or DEPTH or " |
| 8819 | "STENCIL"); |
| 8820 | // Expect MISMATCHED_IMAGE_ASPECT |
| 8821 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 8822 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8823 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8824 | 1, ®ion); |
| 8825 | m_errorMonitor->VerifyFound(); |
| 8826 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8827 | |
| 8828 | m_errorMonitor->SetDesiredFailureMsg( |
| 8829 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8830 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 8831 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 8832 | // Expect INVALID_FILTER |
| 8833 | VkImageObj intImage1(m_device); |
| 8834 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 8835 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8836 | 0); |
| 8837 | VkImageObj intImage2(m_device); |
| 8838 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 8839 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8840 | 0); |
| 8841 | VkImageBlit blitRegion = {}; |
| 8842 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8843 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 8844 | blitRegion.srcSubresource.layerCount = 1; |
| 8845 | blitRegion.srcSubresource.mipLevel = 0; |
| 8846 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8847 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 8848 | blitRegion.dstSubresource.layerCount = 1; |
| 8849 | blitRegion.dstSubresource.mipLevel = 0; |
| 8850 | |
| 8851 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 8852 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 8853 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 8854 | m_errorMonitor->VerifyFound(); |
| 8855 | |
| 8856 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8857 | "called with 0 in ppMemoryBarriers"); |
| 8858 | VkImageMemoryBarrier img_barrier; |
| 8859 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 8860 | img_barrier.pNext = NULL; |
| 8861 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8862 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8863 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8864 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8865 | img_barrier.image = image.handle(); |
| 8866 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8867 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8868 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8869 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8870 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8871 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 8872 | img_barrier.subresourceRange.layerCount = 0; |
| 8873 | img_barrier.subresourceRange.levelCount = 1; |
| 8874 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8875 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8876 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8877 | nullptr, 1, &img_barrier); |
| 8878 | m_errorMonitor->VerifyFound(); |
| 8879 | img_barrier.subresourceRange.layerCount = 1; |
| 8880 | } |
| 8881 | |
| 8882 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 8883 | |
| 8884 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 8885 | |
| 8886 | m_errorMonitor->SetDesiredFailureMsg( |
| 8887 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8888 | "CreateImage extents exceed allowable limits for format"); |
| 8889 | VkImageCreateInfo image_create_info = {}; |
| 8890 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8891 | image_create_info.pNext = NULL; |
| 8892 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8893 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8894 | image_create_info.extent.width = 32; |
| 8895 | image_create_info.extent.height = 32; |
| 8896 | image_create_info.extent.depth = 1; |
| 8897 | image_create_info.mipLevels = 1; |
| 8898 | image_create_info.arrayLayers = 1; |
| 8899 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8900 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8901 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8902 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8903 | image_create_info.flags = 0; |
| 8904 | |
| 8905 | VkImage nullImg; |
| 8906 | VkImageFormatProperties imgFmtProps; |
| 8907 | vkGetPhysicalDeviceImageFormatProperties( |
| 8908 | gpu(), image_create_info.format, image_create_info.imageType, |
| 8909 | image_create_info.tiling, image_create_info.usage, |
| 8910 | image_create_info.flags, &imgFmtProps); |
| 8911 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 8912 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8913 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8914 | m_errorMonitor->VerifyFound(); |
| 8915 | image_create_info.extent.depth = 1; |
| 8916 | |
| 8917 | m_errorMonitor->SetDesiredFailureMsg( |
| 8918 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8919 | "exceeds allowable maximum supported by format of"); |
| 8920 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 8921 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8922 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8923 | m_errorMonitor->VerifyFound(); |
| 8924 | image_create_info.mipLevels = 1; |
| 8925 | |
| 8926 | m_errorMonitor->SetDesiredFailureMsg( |
| 8927 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8928 | "exceeds allowable maximum supported by format of"); |
| 8929 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 8930 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8931 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8932 | m_errorMonitor->VerifyFound(); |
| 8933 | image_create_info.arrayLayers = 1; |
| 8934 | |
| 8935 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8936 | "is not supported by format"); |
| 8937 | int samples = imgFmtProps.sampleCounts >> 1; |
| 8938 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 8939 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8940 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8941 | m_errorMonitor->VerifyFound(); |
| 8942 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8943 | |
| 8944 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8945 | "pCreateInfo->initialLayout, must be " |
| 8946 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 8947 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 8948 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8949 | // Expect INVALID_LAYOUT |
| 8950 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8951 | m_errorMonitor->VerifyFound(); |
| 8952 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8953 | } |
| 8954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8955 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8956 | VkResult err; |
| 8957 | bool pass; |
| 8958 | |
| 8959 | // Create color images with different format sizes and try to copy between them |
| 8960 | m_errorMonitor->SetDesiredFailureMsg( |
| 8961 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8962 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8963 | |
| 8964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8965 | |
| 8966 | // Create two images of different types and try to copy between them |
| 8967 | VkImage srcImage; |
| 8968 | VkImage dstImage; |
| 8969 | VkDeviceMemory srcMem; |
| 8970 | VkDeviceMemory destMem; |
| 8971 | VkMemoryRequirements memReqs; |
| 8972 | |
| 8973 | VkImageCreateInfo image_create_info = {}; |
| 8974 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8975 | image_create_info.pNext = NULL; |
| 8976 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8977 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8978 | image_create_info.extent.width = 32; |
| 8979 | image_create_info.extent.height = 32; |
| 8980 | image_create_info.extent.depth = 1; |
| 8981 | image_create_info.mipLevels = 1; |
| 8982 | image_create_info.arrayLayers = 1; |
| 8983 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8984 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8985 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8986 | image_create_info.flags = 0; |
| 8987 | |
| 8988 | err = |
| 8989 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8990 | ASSERT_VK_SUCCESS(err); |
| 8991 | |
| 8992 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8993 | // Introduce failure by creating second image with a different-sized format. |
| 8994 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8995 | |
| 8996 | err = |
| 8997 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8998 | ASSERT_VK_SUCCESS(err); |
| 8999 | |
| 9000 | // Allocate memory |
| 9001 | VkMemoryAllocateInfo memAlloc = {}; |
| 9002 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9003 | memAlloc.pNext = NULL; |
| 9004 | memAlloc.allocationSize = 0; |
| 9005 | memAlloc.memoryTypeIndex = 0; |
| 9006 | |
| 9007 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 9008 | memAlloc.allocationSize = memReqs.size; |
| 9009 | pass = |
| 9010 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9011 | ASSERT_TRUE(pass); |
| 9012 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 9013 | ASSERT_VK_SUCCESS(err); |
| 9014 | |
| 9015 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 9016 | memAlloc.allocationSize = memReqs.size; |
| 9017 | pass = |
| 9018 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9019 | ASSERT_TRUE(pass); |
| 9020 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 9021 | ASSERT_VK_SUCCESS(err); |
| 9022 | |
| 9023 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9024 | ASSERT_VK_SUCCESS(err); |
| 9025 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 9026 | ASSERT_VK_SUCCESS(err); |
| 9027 | |
| 9028 | BeginCommandBuffer(); |
| 9029 | VkImageCopy copyRegion; |
| 9030 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9031 | copyRegion.srcSubresource.mipLevel = 0; |
| 9032 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 9033 | copyRegion.srcSubresource.layerCount = 0; |
| 9034 | copyRegion.srcOffset.x = 0; |
| 9035 | copyRegion.srcOffset.y = 0; |
| 9036 | copyRegion.srcOffset.z = 0; |
| 9037 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9038 | copyRegion.dstSubresource.mipLevel = 0; |
| 9039 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9040 | copyRegion.dstSubresource.layerCount = 0; |
| 9041 | copyRegion.dstOffset.x = 0; |
| 9042 | copyRegion.dstOffset.y = 0; |
| 9043 | copyRegion.dstOffset.z = 0; |
| 9044 | copyRegion.extent.width = 1; |
| 9045 | copyRegion.extent.height = 1; |
| 9046 | copyRegion.extent.depth = 1; |
| 9047 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9048 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9049 | EndCommandBuffer(); |
| 9050 | |
| 9051 | m_errorMonitor->VerifyFound(); |
| 9052 | |
| 9053 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 9054 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 9055 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9056 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9057 | } |
| 9058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9059 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 9060 | VkResult err; |
| 9061 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9062 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9063 | // 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] | 9064 | m_errorMonitor->SetDesiredFailureMsg( |
| 9065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9066 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9067 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9068 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9069 | |
| 9070 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9071 | VkImage srcImage; |
| 9072 | VkImage dstImage; |
| 9073 | VkDeviceMemory srcMem; |
| 9074 | VkDeviceMemory destMem; |
| 9075 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9076 | |
| 9077 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9078 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9079 | image_create_info.pNext = NULL; |
| 9080 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9081 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9082 | image_create_info.extent.width = 32; |
| 9083 | image_create_info.extent.height = 32; |
| 9084 | image_create_info.extent.depth = 1; |
| 9085 | image_create_info.mipLevels = 1; |
| 9086 | image_create_info.arrayLayers = 1; |
| 9087 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9088 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9089 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9090 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9091 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9092 | err = |
| 9093 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9094 | ASSERT_VK_SUCCESS(err); |
| 9095 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9096 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9097 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9098 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9099 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9100 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9101 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9103 | err = |
| 9104 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9105 | ASSERT_VK_SUCCESS(err); |
| 9106 | |
| 9107 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9108 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9109 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9110 | memAlloc.pNext = NULL; |
| 9111 | memAlloc.allocationSize = 0; |
| 9112 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9113 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9114 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9115 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9116 | pass = |
| 9117 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9118 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9119 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9120 | ASSERT_VK_SUCCESS(err); |
| 9121 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9122 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9123 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9124 | pass = |
| 9125 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9126 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9127 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9128 | ASSERT_VK_SUCCESS(err); |
| 9129 | |
| 9130 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9131 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9132 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9133 | ASSERT_VK_SUCCESS(err); |
| 9134 | |
| 9135 | BeginCommandBuffer(); |
| 9136 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9137 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9138 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9139 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9140 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9141 | copyRegion.srcOffset.x = 0; |
| 9142 | copyRegion.srcOffset.y = 0; |
| 9143 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9144 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9145 | copyRegion.dstSubresource.mipLevel = 0; |
| 9146 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9147 | copyRegion.dstSubresource.layerCount = 0; |
| 9148 | copyRegion.dstOffset.x = 0; |
| 9149 | copyRegion.dstOffset.y = 0; |
| 9150 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9151 | copyRegion.extent.width = 1; |
| 9152 | copyRegion.extent.height = 1; |
| 9153 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9154 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9155 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9156 | EndCommandBuffer(); |
| 9157 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9158 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9159 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9160 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9161 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9162 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9163 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9164 | } |
| 9165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9166 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 9167 | VkResult err; |
| 9168 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9169 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9170 | m_errorMonitor->SetDesiredFailureMsg( |
| 9171 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9172 | "vkCmdResolveImage called with source sample count less than 2."); |
| 9173 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9174 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9175 | |
| 9176 | // 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] | 9177 | VkImage srcImage; |
| 9178 | VkImage dstImage; |
| 9179 | VkDeviceMemory srcMem; |
| 9180 | VkDeviceMemory destMem; |
| 9181 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9182 | |
| 9183 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9184 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9185 | image_create_info.pNext = NULL; |
| 9186 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9187 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9188 | image_create_info.extent.width = 32; |
| 9189 | image_create_info.extent.height = 1; |
| 9190 | image_create_info.extent.depth = 1; |
| 9191 | image_create_info.mipLevels = 1; |
| 9192 | image_create_info.arrayLayers = 1; |
| 9193 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9194 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9195 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9196 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9198 | err = |
| 9199 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9200 | ASSERT_VK_SUCCESS(err); |
| 9201 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9202 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9203 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9204 | err = |
| 9205 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9206 | ASSERT_VK_SUCCESS(err); |
| 9207 | |
| 9208 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9209 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9210 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9211 | memAlloc.pNext = NULL; |
| 9212 | memAlloc.allocationSize = 0; |
| 9213 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9214 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9215 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9216 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9217 | pass = |
| 9218 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9219 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9220 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9221 | ASSERT_VK_SUCCESS(err); |
| 9222 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9223 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9224 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9225 | pass = |
| 9226 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9227 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9228 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9229 | ASSERT_VK_SUCCESS(err); |
| 9230 | |
| 9231 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9232 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9233 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9234 | ASSERT_VK_SUCCESS(err); |
| 9235 | |
| 9236 | BeginCommandBuffer(); |
| 9237 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9238 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9239 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9240 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9241 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9242 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9243 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9244 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9245 | resolveRegion.srcOffset.x = 0; |
| 9246 | resolveRegion.srcOffset.y = 0; |
| 9247 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9248 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9249 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9250 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9251 | resolveRegion.dstSubresource.layerCount = 0; |
| 9252 | resolveRegion.dstOffset.x = 0; |
| 9253 | resolveRegion.dstOffset.y = 0; |
| 9254 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9255 | resolveRegion.extent.width = 1; |
| 9256 | resolveRegion.extent.height = 1; |
| 9257 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9258 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9259 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9260 | EndCommandBuffer(); |
| 9261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9262 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9263 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9264 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9265 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9266 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9267 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9268 | } |
| 9269 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9270 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 9271 | VkResult err; |
| 9272 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9273 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9274 | m_errorMonitor->SetDesiredFailureMsg( |
| 9275 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9276 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 9277 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9278 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9279 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9280 | // 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] | 9281 | VkImage srcImage; |
| 9282 | VkImage dstImage; |
| 9283 | VkDeviceMemory srcMem; |
| 9284 | VkDeviceMemory destMem; |
| 9285 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9286 | |
| 9287 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9288 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9289 | image_create_info.pNext = NULL; |
| 9290 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9291 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9292 | image_create_info.extent.width = 32; |
| 9293 | image_create_info.extent.height = 1; |
| 9294 | image_create_info.extent.depth = 1; |
| 9295 | image_create_info.mipLevels = 1; |
| 9296 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9297 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9298 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9299 | // Note: Some implementations expect color attachment usage for any |
| 9300 | // multisample surface |
| 9301 | image_create_info.usage = |
| 9302 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9303 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9304 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9305 | err = |
| 9306 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9307 | ASSERT_VK_SUCCESS(err); |
| 9308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9309 | // Note: Some implementations expect color attachment usage for any |
| 9310 | // multisample surface |
| 9311 | image_create_info.usage = |
| 9312 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9314 | err = |
| 9315 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9316 | ASSERT_VK_SUCCESS(err); |
| 9317 | |
| 9318 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9319 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9320 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9321 | memAlloc.pNext = NULL; |
| 9322 | memAlloc.allocationSize = 0; |
| 9323 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9324 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9325 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9326 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9327 | pass = |
| 9328 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9329 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9330 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9331 | ASSERT_VK_SUCCESS(err); |
| 9332 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9333 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9334 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9335 | pass = |
| 9336 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9337 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9338 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9339 | ASSERT_VK_SUCCESS(err); |
| 9340 | |
| 9341 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9342 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9343 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9344 | ASSERT_VK_SUCCESS(err); |
| 9345 | |
| 9346 | BeginCommandBuffer(); |
| 9347 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9348 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9349 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9350 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9351 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9352 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9353 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9354 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9355 | resolveRegion.srcOffset.x = 0; |
| 9356 | resolveRegion.srcOffset.y = 0; |
| 9357 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9358 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9359 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9360 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9361 | resolveRegion.dstSubresource.layerCount = 0; |
| 9362 | resolveRegion.dstOffset.x = 0; |
| 9363 | resolveRegion.dstOffset.y = 0; |
| 9364 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9365 | resolveRegion.extent.width = 1; |
| 9366 | resolveRegion.extent.height = 1; |
| 9367 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9368 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9369 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9370 | EndCommandBuffer(); |
| 9371 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9372 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9373 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9374 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9375 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9376 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9377 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9378 | } |
| 9379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9380 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 9381 | VkResult err; |
| 9382 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9383 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9384 | m_errorMonitor->SetDesiredFailureMsg( |
| 9385 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9386 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 9387 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9389 | |
| 9390 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9391 | VkImage srcImage; |
| 9392 | VkImage dstImage; |
| 9393 | VkDeviceMemory srcMem; |
| 9394 | VkDeviceMemory destMem; |
| 9395 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9396 | |
| 9397 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9398 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9399 | image_create_info.pNext = NULL; |
| 9400 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9401 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9402 | image_create_info.extent.width = 32; |
| 9403 | image_create_info.extent.height = 1; |
| 9404 | image_create_info.extent.depth = 1; |
| 9405 | image_create_info.mipLevels = 1; |
| 9406 | image_create_info.arrayLayers = 1; |
| 9407 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9408 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9409 | // Note: Some implementations expect color attachment usage for any |
| 9410 | // multisample surface |
| 9411 | image_create_info.usage = |
| 9412 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9413 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9415 | err = |
| 9416 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9417 | ASSERT_VK_SUCCESS(err); |
| 9418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9419 | // Set format to something other than source image |
| 9420 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 9421 | // Note: Some implementations expect color attachment usage for any |
| 9422 | // multisample surface |
| 9423 | image_create_info.usage = |
| 9424 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9425 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9426 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9427 | err = |
| 9428 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9429 | ASSERT_VK_SUCCESS(err); |
| 9430 | |
| 9431 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9432 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9433 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9434 | memAlloc.pNext = NULL; |
| 9435 | memAlloc.allocationSize = 0; |
| 9436 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9437 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9438 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9439 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9440 | pass = |
| 9441 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9442 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9443 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9444 | ASSERT_VK_SUCCESS(err); |
| 9445 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9446 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9447 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9448 | pass = |
| 9449 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9450 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9451 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9452 | ASSERT_VK_SUCCESS(err); |
| 9453 | |
| 9454 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9455 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9456 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9457 | ASSERT_VK_SUCCESS(err); |
| 9458 | |
| 9459 | BeginCommandBuffer(); |
| 9460 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9461 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9462 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9463 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9464 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9465 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9466 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9467 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9468 | resolveRegion.srcOffset.x = 0; |
| 9469 | resolveRegion.srcOffset.y = 0; |
| 9470 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9471 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9472 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9473 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9474 | resolveRegion.dstSubresource.layerCount = 0; |
| 9475 | resolveRegion.dstOffset.x = 0; |
| 9476 | resolveRegion.dstOffset.y = 0; |
| 9477 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9478 | resolveRegion.extent.width = 1; |
| 9479 | resolveRegion.extent.height = 1; |
| 9480 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9481 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9482 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9483 | EndCommandBuffer(); |
| 9484 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9485 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9486 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9487 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9488 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9489 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9490 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9491 | } |
| 9492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9493 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 9494 | VkResult err; |
| 9495 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9497 | m_errorMonitor->SetDesiredFailureMsg( |
| 9498 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9499 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 9500 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9501 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9502 | |
| 9503 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9504 | VkImage srcImage; |
| 9505 | VkImage dstImage; |
| 9506 | VkDeviceMemory srcMem; |
| 9507 | VkDeviceMemory destMem; |
| 9508 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9509 | |
| 9510 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9511 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9512 | image_create_info.pNext = NULL; |
| 9513 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9514 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9515 | image_create_info.extent.width = 32; |
| 9516 | image_create_info.extent.height = 1; |
| 9517 | image_create_info.extent.depth = 1; |
| 9518 | image_create_info.mipLevels = 1; |
| 9519 | image_create_info.arrayLayers = 1; |
| 9520 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9521 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9522 | // Note: Some implementations expect color attachment usage for any |
| 9523 | // multisample surface |
| 9524 | image_create_info.usage = |
| 9525 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9526 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9528 | err = |
| 9529 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9530 | ASSERT_VK_SUCCESS(err); |
| 9531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9532 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 9533 | // Note: Some implementations expect color attachment usage for any |
| 9534 | // multisample surface |
| 9535 | image_create_info.usage = |
| 9536 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9537 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9539 | err = |
| 9540 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9541 | ASSERT_VK_SUCCESS(err); |
| 9542 | |
| 9543 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9544 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9545 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9546 | memAlloc.pNext = NULL; |
| 9547 | memAlloc.allocationSize = 0; |
| 9548 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9549 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9550 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9551 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9552 | pass = |
| 9553 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9554 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9555 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9556 | ASSERT_VK_SUCCESS(err); |
| 9557 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9558 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9559 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9560 | pass = |
| 9561 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9562 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9563 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9564 | ASSERT_VK_SUCCESS(err); |
| 9565 | |
| 9566 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9567 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9568 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9569 | ASSERT_VK_SUCCESS(err); |
| 9570 | |
| 9571 | BeginCommandBuffer(); |
| 9572 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9573 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9574 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9575 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9576 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9577 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9578 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9579 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9580 | resolveRegion.srcOffset.x = 0; |
| 9581 | resolveRegion.srcOffset.y = 0; |
| 9582 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9583 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9584 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9585 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9586 | resolveRegion.dstSubresource.layerCount = 0; |
| 9587 | resolveRegion.dstOffset.x = 0; |
| 9588 | resolveRegion.dstOffset.y = 0; |
| 9589 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9590 | resolveRegion.extent.width = 1; |
| 9591 | resolveRegion.extent.height = 1; |
| 9592 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9593 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9594 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9595 | EndCommandBuffer(); |
| 9596 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9597 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9598 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9599 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9600 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9601 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9602 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9603 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9604 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9605 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9606 | // 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] | 9607 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 9608 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9609 | // The image format check comes 2nd in validation so we trigger it first, |
| 9610 | // 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] | 9611 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9612 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9613 | m_errorMonitor->SetDesiredFailureMsg( |
| 9614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9615 | "Combination depth/stencil image formats can have only the "); |
| 9616 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9617 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9618 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9619 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9620 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9621 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9622 | |
| 9623 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9624 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9625 | ds_pool_ci.pNext = NULL; |
| 9626 | ds_pool_ci.maxSets = 1; |
| 9627 | ds_pool_ci.poolSizeCount = 1; |
| 9628 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9629 | |
| 9630 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9631 | err = |
| 9632 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9633 | ASSERT_VK_SUCCESS(err); |
| 9634 | |
| 9635 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9636 | dsl_binding.binding = 0; |
| 9637 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9638 | dsl_binding.descriptorCount = 1; |
| 9639 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9640 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9641 | |
| 9642 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9643 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9644 | ds_layout_ci.pNext = NULL; |
| 9645 | ds_layout_ci.bindingCount = 1; |
| 9646 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9647 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9648 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9649 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9650 | ASSERT_VK_SUCCESS(err); |
| 9651 | |
| 9652 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9653 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9654 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9655 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9656 | alloc_info.descriptorPool = ds_pool; |
| 9657 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9658 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9659 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9660 | ASSERT_VK_SUCCESS(err); |
| 9661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9662 | VkImage image_bad; |
| 9663 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9664 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9665 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9666 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9667 | const int32_t tex_width = 32; |
| 9668 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9669 | |
| 9670 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9671 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9672 | image_create_info.pNext = NULL; |
| 9673 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9674 | image_create_info.format = tex_format_bad; |
| 9675 | image_create_info.extent.width = tex_width; |
| 9676 | image_create_info.extent.height = tex_height; |
| 9677 | image_create_info.extent.depth = 1; |
| 9678 | image_create_info.mipLevels = 1; |
| 9679 | image_create_info.arrayLayers = 1; |
| 9680 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9681 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9682 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9683 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9684 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9685 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9686 | err = |
| 9687 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9688 | ASSERT_VK_SUCCESS(err); |
| 9689 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9690 | image_create_info.usage = |
| 9691 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9692 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9693 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9694 | ASSERT_VK_SUCCESS(err); |
| 9695 | |
| 9696 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9697 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9698 | image_view_create_info.image = image_bad; |
| 9699 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9700 | image_view_create_info.format = tex_format_bad; |
| 9701 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9702 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9703 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9704 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9705 | image_view_create_info.subresourceRange.aspectMask = |
| 9706 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9707 | |
| 9708 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9709 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9710 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9711 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9712 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9713 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9714 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9715 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9716 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9717 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9718 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9719 | #endif // IMAGE_TESTS |
| 9720 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9721 | int main(int argc, char **argv) { |
| 9722 | int result; |
| 9723 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9724 | #ifdef ANDROID |
| 9725 | int vulkanSupport = InitVulkan(); |
| 9726 | if (vulkanSupport == 0) |
| 9727 | return 1; |
| 9728 | #endif |
| 9729 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9730 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9731 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9732 | |
| 9733 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9734 | |
| 9735 | result = RUN_ALL_TESTS(); |
| 9736 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9737 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9738 | return result; |
| 9739 | } |