Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 268 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | |
| 270 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_layer_names; |
| 272 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_extension_names; |
| 274 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 275 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 276 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Since CreateDbgMsgCallback is an instance level extension call |
| 279 | * any extension / layer that utilizes that feature also needs |
| 280 | * to be enabled at create instance time. |
| 281 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 282 | // Use Threading layer first to protect others from |
| 283 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
| 303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 308 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 309 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 311 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 317 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 319 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 323 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 324 | } |
| 325 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
| 329 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
| 331 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
| 336 | instance_extension_names, device_extension_names, |
| 337 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void TearDown() { |
| 341 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
| 346 | VkLayerTest() { |
| 347 | m_enableWSI = false; |
| 348 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * For render test all drawing happens in a single render pass |
| 358 | * on a single command buffer. |
| 359 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
| 376 | return result; |
| 377 | } |
| 378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 380 | const char *fragShaderText, |
| 381 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
| 383 | int i; |
| 384 | struct vktriangle_vs_uniform data; |
| 385 | |
| 386 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
| 388 | glm::mat4 Model = glm::mat4(1.0f); |
| 389 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
| 396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
| 403 | data.position[i][1] = tri_data[i].posY; |
| 404 | data.position[i][2] = tri_data[i].posZ; |
| 405 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
| 407 | data.color[i][1] = tri_data[i].g; |
| 408 | data.color[i][2] = tri_data[i].b; |
| 409 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 416 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 420 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
| 422 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
| 425 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 429 | ia_state.sType = |
| 430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 432 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
| 434 | if (failMask & BsoFailDepthBias) { |
| 435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 437 | rs_state.sType = |
| 438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 439 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
| 444 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
| 446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
| 448 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
| 450 | if (failMask & BsoFailScissor) { |
| 451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
| 453 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
| 455 | if (failMask & BsoFailBlend) { |
| 456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 459 | att_state.blendEnable = VK_TRUE; |
| 460 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
| 462 | if (failMask & BsoFailDepthBounds) { |
| 463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 464 | } |
| 465 | if (failMask & BsoFailStencilReadMask) { |
| 466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 467 | } |
| 468 | if (failMask & BsoFailStencilWriteMask) { |
| 469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 470 | } |
| 471 | if (failMask & BsoFailStencilReference) { |
| 472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 473 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
| 475 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 477 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
| 479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
| 484 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
| 487 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 493 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 494 | VkPipelineObj &pipelineobj, |
| 495 | VkDescriptorSetObj &descriptorSet, |
| 496 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 498 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 499 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 501 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 502 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 505 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 506 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 507 | // correctly |
| 508 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 509 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 510 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 511 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 512 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 513 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 514 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 515 | |
| 516 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 517 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 518 | ds_ci.pNext = NULL; |
| 519 | ds_ci.depthTestEnable = VK_FALSE; |
| 520 | ds_ci.depthWriteEnable = VK_TRUE; |
| 521 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 522 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 523 | if (failMask & BsoFailDepthBounds) { |
| 524 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 525 | ds_ci.maxDepthBounds = 0.0f; |
| 526 | ds_ci.minDepthBounds = 0.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 527 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 528 | ds_ci.stencilTestEnable = VK_TRUE; |
| 529 | ds_ci.front = stencil; |
| 530 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 531 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 532 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 533 | pipelineobj.SetViewport(m_viewports); |
| 534 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 535 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 536 | VkResult err = pipelineobj.CreateVKPipeline( |
| 537 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 538 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 539 | commandBuffer->BindPipeline(pipelineobj); |
| 540 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 541 | } |
| 542 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 543 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 544 | public: |
| 545 | protected: |
| 546 | VkWsiEnabledLayerTest() { |
| 547 | m_enableWSI = true; |
| 548 | } |
| 549 | }; |
| 550 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
| 553 | // ******************************************************************************************************************** |
| 554 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 555 | #if PARAMETER_VALIDATION_TESTS |
| 556 | TEST_F(VkLayerTest, RequiredParameter) { |
| 557 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 558 | "pointer, array, and array count parameters"); |
| 559 | |
| 560 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 561 | |
| 562 | m_errorMonitor->SetDesiredFailureMsg( |
| 563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 564 | "required parameter pFeatures specified as NULL"); |
| 565 | // Specify NULL for a pointer to a handle |
| 566 | // Expected to trigger an error with |
| 567 | // parameter_validation::validate_required_pointer |
| 568 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 569 | m_errorMonitor->VerifyFound(); |
| 570 | |
| 571 | m_errorMonitor->SetDesiredFailureMsg( |
| 572 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 573 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 574 | // Specify NULL for pointer to array count |
| 575 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 576 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 577 | m_errorMonitor->VerifyFound(); |
| 578 | |
| 579 | m_errorMonitor->SetDesiredFailureMsg( |
| 580 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 581 | "parameter viewportCount must be greater than 0"); |
| 582 | // Specify 0 for a required array count |
| 583 | // Expected to trigger an error with parameter_validation::validate_array |
| 584 | VkViewport view_port = {}; |
| 585 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 586 | m_errorMonitor->VerifyFound(); |
| 587 | |
| 588 | m_errorMonitor->SetDesiredFailureMsg( |
| 589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 590 | "required parameter pViewports specified as NULL"); |
| 591 | // Specify NULL for a required array |
| 592 | // Expected to trigger an error with parameter_validation::validate_array |
| 593 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 594 | m_errorMonitor->VerifyFound(); |
| 595 | |
| 596 | m_errorMonitor->SetDesiredFailureMsg( |
| 597 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 598 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 599 | // Specify VK_NULL_HANDLE for a required handle |
| 600 | // Expected to trigger an error with |
| 601 | // parameter_validation::validate_required_handle |
| 602 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 603 | m_errorMonitor->VerifyFound(); |
| 604 | |
| 605 | m_errorMonitor->SetDesiredFailureMsg( |
| 606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 607 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 608 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 609 | // Expected to trigger an error with |
| 610 | // parameter_validation::validate_required_handle_array |
| 611 | VkFence fence = VK_NULL_HANDLE; |
| 612 | vkResetFences(device(), 1, &fence); |
| 613 | m_errorMonitor->VerifyFound(); |
| 614 | |
| 615 | m_errorMonitor->SetDesiredFailureMsg( |
| 616 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 617 | "required parameter pAllocateInfo specified as NULL"); |
| 618 | // Specify NULL for a required struct pointer |
| 619 | // Expected to trigger an error with |
| 620 | // parameter_validation::validate_struct_type |
| 621 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 622 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 623 | m_errorMonitor->VerifyFound(); |
| 624 | |
| 625 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 626 | "value of faceMask must not be 0"); |
| 627 | // Specify 0 for a required VkFlags parameter |
| 628 | // Expected to trigger an error with parameter_validation::validate_flags |
| 629 | m_commandBuffer->SetStencilReference(0, 0); |
| 630 | m_errorMonitor->VerifyFound(); |
| 631 | |
| 632 | m_errorMonitor->SetDesiredFailureMsg( |
| 633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 634 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 635 | // Specify 0 for a required VkFlags array entry |
| 636 | // Expected to trigger an error with |
| 637 | // parameter_validation::validate_flags_array |
| 638 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 639 | VkPipelineStageFlags stageFlags = 0; |
| 640 | VkSubmitInfo submitInfo = {}; |
| 641 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 642 | submitInfo.waitSemaphoreCount = 1; |
| 643 | submitInfo.pWaitSemaphores = &semaphore; |
| 644 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 645 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 646 | m_errorMonitor->VerifyFound(); |
| 647 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 648 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 649 | TEST_F(VkLayerTest, ReservedParameter) { |
| 650 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 651 | |
| 652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 653 | |
| 654 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 655 | " must be 0"); |
| 656 | // Specify 0 for a reserved VkFlags parameter |
| 657 | // Expected to trigger an error with |
| 658 | // parameter_validation::validate_reserved_flags |
| 659 | VkEvent event_handle = VK_NULL_HANDLE; |
| 660 | VkEventCreateInfo event_info = {}; |
| 661 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 662 | event_info.flags = 1; |
| 663 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 664 | m_errorMonitor->VerifyFound(); |
| 665 | } |
| 666 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 667 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 668 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 669 | "structure's sType field"); |
| 670 | |
| 671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 672 | |
| 673 | m_errorMonitor->SetDesiredFailureMsg( |
| 674 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 675 | "parameter pAllocateInfo->sType must be"); |
| 676 | // Zero struct memory, effectively setting sType to |
| 677 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 678 | // Expected to trigger an error with |
| 679 | // parameter_validation::validate_struct_type |
| 680 | VkMemoryAllocateInfo alloc_info = {}; |
| 681 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 682 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 683 | m_errorMonitor->VerifyFound(); |
| 684 | |
| 685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "parameter pSubmits[0].sType must be"); |
| 687 | // Zero struct memory, effectively setting sType to |
| 688 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 689 | // Expected to trigger an error with |
| 690 | // parameter_validation::validate_struct_type_array |
| 691 | VkSubmitInfo submit_info = {}; |
| 692 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 693 | m_errorMonitor->VerifyFound(); |
| 694 | } |
| 695 | |
| 696 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 697 | TEST_DESCRIPTION( |
| 698 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 699 | |
| 700 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 701 | |
| 702 | m_errorMonitor->SetDesiredFailureMsg( |
| 703 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 704 | "value of pAllocateInfo->pNext must be NULL"); |
| 705 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 706 | // NULL |
| 707 | // Expected to trigger an error with |
| 708 | // parameter_validation::validate_struct_pnext |
| 709 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 710 | // Zero-initialization will provide the correct sType |
| 711 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 712 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 713 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 714 | memory_alloc_info.pNext = &app_info; |
| 715 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 716 | m_errorMonitor->VerifyFound(); |
| 717 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 718 | m_errorMonitor->SetDesiredFailureMsg( |
| 719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 720 | " chain includes a structure with unexpected VkStructureType "); |
| 721 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 722 | // Expected to trigger an error with |
| 723 | // parameter_validation::validate_struct_pnext |
| 724 | VkDescriptorPoolSize ds_type_count = {}; |
| 725 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 726 | ds_type_count.descriptorCount = 1; |
| 727 | |
| 728 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 729 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 730 | ds_pool_ci.pNext = NULL; |
| 731 | ds_pool_ci.maxSets = 1; |
| 732 | ds_pool_ci.poolSizeCount = 1; |
| 733 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 734 | |
| 735 | VkDescriptorPool ds_pool; |
| 736 | VkResult err = |
| 737 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 738 | ASSERT_VK_SUCCESS(err); |
| 739 | |
| 740 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 741 | dsl_binding.binding = 0; |
| 742 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 743 | dsl_binding.descriptorCount = 1; |
| 744 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 745 | dsl_binding.pImmutableSamplers = NULL; |
| 746 | |
| 747 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 748 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 749 | ds_layout_ci.pNext = NULL; |
| 750 | ds_layout_ci.bindingCount = 1; |
| 751 | ds_layout_ci.pBindings = &dsl_binding; |
| 752 | |
| 753 | VkDescriptorSetLayout ds_layout; |
| 754 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 755 | &ds_layout); |
| 756 | ASSERT_VK_SUCCESS(err); |
| 757 | |
| 758 | VkDescriptorSet descriptorSet; |
| 759 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 760 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 761 | ds_alloc_info.descriptorSetCount = 1; |
| 762 | ds_alloc_info.descriptorPool = ds_pool; |
| 763 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 764 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 765 | &descriptorSet); |
| 766 | ASSERT_VK_SUCCESS(err); |
| 767 | |
| 768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 769 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 770 | pipeline_layout_ci.setLayoutCount = 1; |
| 771 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 772 | |
| 773 | VkPipelineLayout pipeline_layout; |
| 774 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 775 | &pipeline_layout); |
| 776 | ASSERT_VK_SUCCESS(err); |
| 777 | |
| 778 | VkViewport vp = {}; // Just need dummy vp to point to |
| 779 | VkRect2D sc = {}; // dummy scissor to point to |
| 780 | |
| 781 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 782 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 783 | vp_state_ci.scissorCount = 1; |
| 784 | vp_state_ci.pScissors = ≻ |
| 785 | vp_state_ci.viewportCount = 1; |
| 786 | vp_state_ci.pViewports = &vp; |
| 787 | |
| 788 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 789 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 790 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 791 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 792 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 793 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 794 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 795 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 796 | |
| 797 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 798 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 799 | gp_ci.pViewportState = &vp_state_ci; |
| 800 | gp_ci.pRasterizationState = &rs_state_ci; |
| 801 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 802 | gp_ci.layout = pipeline_layout; |
| 803 | gp_ci.renderPass = renderPass(); |
| 804 | |
| 805 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 806 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 807 | pc_ci.initialDataSize = 0; |
| 808 | pc_ci.pInitialData = 0; |
| 809 | |
| 810 | VkPipeline pipeline; |
| 811 | VkPipelineCache pipelineCache; |
| 812 | |
| 813 | err = |
| 814 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 815 | ASSERT_VK_SUCCESS(err); |
| 816 | |
| 817 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 818 | VkApplicationInfo invalid_pnext_struct = {}; |
| 819 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 820 | |
| 821 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 822 | &gp_ci, NULL, &pipeline); |
| 823 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 824 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 825 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 826 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 827 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 828 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 829 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 830 | |
| 831 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 832 | TEST_DESCRIPTION( |
| 833 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 834 | |
| 835 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 836 | |
| 837 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 838 | "does not fall within the begin..end " |
| 839 | "range of the core VkFormat " |
| 840 | "enumeration tokens"); |
| 841 | // Specify an invalid VkFormat value |
| 842 | // Expected to trigger an error with |
| 843 | // parameter_validation::validate_ranged_enum |
| 844 | VkFormatProperties format_properties; |
| 845 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 846 | &format_properties); |
| 847 | m_errorMonitor->VerifyFound(); |
| 848 | |
| 849 | m_errorMonitor->SetDesiredFailureMsg( |
| 850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 851 | "contains flag bits that are not recognized members of"); |
| 852 | // Specify an invalid VkFlags bitmask value |
| 853 | // Expected to trigger an error with parameter_validation::validate_flags |
| 854 | VkImageFormatProperties image_format_properties; |
| 855 | vkGetPhysicalDeviceImageFormatProperties( |
| 856 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 857 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 858 | &image_format_properties); |
| 859 | m_errorMonitor->VerifyFound(); |
| 860 | |
| 861 | m_errorMonitor->SetDesiredFailureMsg( |
| 862 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 863 | "contains flag bits that are not recognized members of"); |
| 864 | // Specify an invalid VkFlags array entry |
| 865 | // Expected to trigger an error with |
| 866 | // parameter_validation::validate_flags_array |
| 867 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 868 | VkPipelineStageFlags stage_flags = |
| 869 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 870 | VkSubmitInfo submit_info = {}; |
| 871 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 872 | submit_info.waitSemaphoreCount = 1; |
| 873 | submit_info.pWaitSemaphores = &semaphore; |
| 874 | submit_info.pWaitDstStageMask = &stage_flags; |
| 875 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 876 | m_errorMonitor->VerifyFound(); |
| 877 | |
| 878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 879 | "is neither VK_TRUE nor VK_FALSE"); |
| 880 | // Specify an invalid VkBool32 value |
| 881 | // Expected to trigger a warning with |
| 882 | // parameter_validation::validate_bool32 |
| 883 | VkSampler sampler = VK_NULL_HANDLE; |
| 884 | VkSamplerCreateInfo sampler_info = {}; |
| 885 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 886 | sampler_info.pNext = NULL; |
| 887 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 888 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 889 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 890 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 891 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 892 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 893 | sampler_info.mipLodBias = 1.0; |
| 894 | sampler_info.maxAnisotropy = 1; |
| 895 | sampler_info.compareEnable = VK_FALSE; |
| 896 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 897 | sampler_info.minLod = 1.0; |
| 898 | sampler_info.maxLod = 1.0; |
| 899 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 900 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 901 | // Not VK_TRUE or VK_FALSE |
| 902 | sampler_info.anisotropyEnable = 3; |
| 903 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 904 | m_errorMonitor->VerifyFound(); |
| 905 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 906 | |
| 907 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 908 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 909 | |
| 910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 911 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 912 | // Find an unsupported image format |
| 913 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 914 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 915 | VkFormat format = static_cast<VkFormat>(f); |
| 916 | VkFormatProperties fProps = m_device->format_properties(format); |
| 917 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 918 | fProps.optimalTilingFeatures == 0) { |
| 919 | unsupported = format; |
| 920 | break; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 925 | m_errorMonitor->SetDesiredFailureMsg( |
| 926 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 927 | "the requested format is not supported on this device"); |
| 928 | // Specify an unsupported VkFormat value to generate a |
| 929 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 930 | // Expected to trigger a warning from |
| 931 | // parameter_validation::validate_result |
| 932 | VkImageFormatProperties image_format_properties; |
| 933 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 934 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 935 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 936 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 937 | m_errorMonitor->VerifyFound(); |
| 938 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 939 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 940 | #endif // PARAMETER_VALIDATION_TESTS |
| 941 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 942 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 943 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 944 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 945 | { |
| 946 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 947 | VkFenceCreateInfo fenceInfo = {}; |
| 948 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 949 | fenceInfo.pNext = NULL; |
| 950 | fenceInfo.flags = 0; |
| 951 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 952 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 953 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 955 | |
| 956 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 957 | vk_testing::Buffer buffer; |
| 958 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 959 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 960 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 961 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 962 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 963 | |
| 964 | testFence.init(*m_device, fenceInfo); |
| 965 | |
| 966 | // Bypass framework since it does the waits automatically |
| 967 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 968 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 969 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 970 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 971 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 972 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 973 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 974 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 975 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 976 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 977 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 978 | |
| 979 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 980 | ASSERT_VK_SUCCESS( err ); |
| 981 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 982 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 983 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 985 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 986 | } |
| 987 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 988 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 989 | { |
| 990 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 991 | VkFenceCreateInfo fenceInfo = {}; |
| 992 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 993 | fenceInfo.pNext = NULL; |
| 994 | fenceInfo.flags = 0; |
| 995 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 996 | 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] | 997 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 998 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 999 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1000 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1001 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1002 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1003 | 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] | 1004 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1005 | |
| 1006 | testFence.init(*m_device, fenceInfo); |
| 1007 | |
| 1008 | // Bypass framework since it does the waits automatically |
| 1009 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1010 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1011 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1012 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1013 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1014 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1015 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1016 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1017 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1018 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1019 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1020 | |
| 1021 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1022 | ASSERT_VK_SUCCESS( err ); |
| 1023 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1024 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1025 | VkCommandBufferBeginInfo info = {}; |
| 1026 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1027 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1028 | info.renderPass = VK_NULL_HANDLE; |
| 1029 | info.subpass = 0; |
| 1030 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1031 | info.occlusionQueryEnable = VK_FALSE; |
| 1032 | info.queryFlags = 0; |
| 1033 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1034 | |
| 1035 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1036 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1037 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1038 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1039 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1040 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1041 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1042 | // This is a positive test. No failures are expected. |
| 1043 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1044 | VkResult err; |
| 1045 | bool pass; |
| 1046 | |
| 1047 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1048 | "the buffer, create an image, and bind the same memory to " |
| 1049 | "it"); |
| 1050 | |
| 1051 | m_errorMonitor->ExpectSuccess(); |
| 1052 | |
| 1053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1054 | |
| 1055 | VkBuffer buffer; |
| 1056 | VkImage image; |
| 1057 | VkDeviceMemory mem; |
| 1058 | VkMemoryRequirements mem_reqs; |
| 1059 | |
| 1060 | VkBufferCreateInfo buf_info = {}; |
| 1061 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1062 | buf_info.pNext = NULL; |
| 1063 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1064 | buf_info.size = 256; |
| 1065 | buf_info.queueFamilyIndexCount = 0; |
| 1066 | buf_info.pQueueFamilyIndices = NULL; |
| 1067 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1068 | buf_info.flags = 0; |
| 1069 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1070 | ASSERT_VK_SUCCESS(err); |
| 1071 | |
| 1072 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1073 | |
| 1074 | VkMemoryAllocateInfo alloc_info = {}; |
| 1075 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1076 | alloc_info.pNext = NULL; |
| 1077 | alloc_info.memoryTypeIndex = 0; |
| 1078 | |
| 1079 | // Ensure memory is big enough for both bindings |
| 1080 | alloc_info.allocationSize = 0x10000; |
| 1081 | |
| 1082 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1083 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1084 | if (!pass) { |
| 1085 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1086 | return; |
| 1087 | } |
| 1088 | |
| 1089 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1090 | ASSERT_VK_SUCCESS(err); |
| 1091 | |
| 1092 | uint8_t *pData; |
| 1093 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1094 | (void **)&pData); |
| 1095 | ASSERT_VK_SUCCESS(err); |
| 1096 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1097 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1098 | |
| 1099 | vkUnmapMemory(m_device->device(), mem); |
| 1100 | |
| 1101 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1102 | ASSERT_VK_SUCCESS(err); |
| 1103 | |
| 1104 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1105 | // memory. In fact, it was never used by the GPU. |
| 1106 | // Just be be sure, wait for idle. |
| 1107 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1108 | vkDeviceWaitIdle(m_device->device()); |
| 1109 | |
| 1110 | VkImageCreateInfo image_create_info = {}; |
| 1111 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1112 | image_create_info.pNext = NULL; |
| 1113 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1114 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1115 | image_create_info.extent.width = 64; |
| 1116 | image_create_info.extent.height = 64; |
| 1117 | image_create_info.extent.depth = 1; |
| 1118 | image_create_info.mipLevels = 1; |
| 1119 | image_create_info.arrayLayers = 1; |
| 1120 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1121 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1122 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1123 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1124 | image_create_info.queueFamilyIndexCount = 0; |
| 1125 | image_create_info.pQueueFamilyIndices = NULL; |
| 1126 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1127 | image_create_info.flags = 0; |
| 1128 | |
| 1129 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1130 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1131 | mem_alloc.pNext = NULL; |
| 1132 | mem_alloc.allocationSize = 0; |
| 1133 | mem_alloc.memoryTypeIndex = 0; |
| 1134 | |
| 1135 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1136 | * to be textures or it will be the staging image if they are not. |
| 1137 | */ |
| 1138 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1139 | ASSERT_VK_SUCCESS(err); |
| 1140 | |
| 1141 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1142 | |
| 1143 | mem_alloc.allocationSize = mem_reqs.size; |
| 1144 | |
| 1145 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1146 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1147 | if (!pass) { |
| 1148 | vkDestroyImage(m_device->device(), image, NULL); |
| 1149 | return; |
| 1150 | } |
| 1151 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1152 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1153 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1154 | ASSERT_VK_SUCCESS(err); |
| 1155 | |
| 1156 | m_errorMonitor->VerifyNotFound(); |
| 1157 | |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1158 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1159 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1160 | vkDestroyImage(m_device->device(), image, NULL); |
| 1161 | } |
| 1162 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1163 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1164 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1165 | "buffer and image to memory such that they will alias."); |
| 1166 | VkResult err; |
| 1167 | bool pass; |
| 1168 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1169 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1170 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1171 | VkImage image; |
| 1172 | VkDeviceMemory mem; // buffer will be bound first |
| 1173 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1174 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1175 | |
| 1176 | VkBufferCreateInfo buf_info = {}; |
| 1177 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1178 | buf_info.pNext = NULL; |
| 1179 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1180 | buf_info.size = 256; |
| 1181 | buf_info.queueFamilyIndexCount = 0; |
| 1182 | buf_info.pQueueFamilyIndices = NULL; |
| 1183 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1184 | buf_info.flags = 0; |
| 1185 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1186 | ASSERT_VK_SUCCESS(err); |
| 1187 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1188 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1189 | |
| 1190 | VkImageCreateInfo image_create_info = {}; |
| 1191 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1192 | image_create_info.pNext = NULL; |
| 1193 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1194 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1195 | image_create_info.extent.width = 64; |
| 1196 | image_create_info.extent.height = 64; |
| 1197 | image_create_info.extent.depth = 1; |
| 1198 | image_create_info.mipLevels = 1; |
| 1199 | image_create_info.arrayLayers = 1; |
| 1200 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1201 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1202 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1203 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1204 | image_create_info.queueFamilyIndexCount = 0; |
| 1205 | image_create_info.pQueueFamilyIndices = NULL; |
| 1206 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1207 | image_create_info.flags = 0; |
| 1208 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1209 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1210 | ASSERT_VK_SUCCESS(err); |
| 1211 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1212 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1213 | |
| 1214 | VkMemoryAllocateInfo alloc_info = {}; |
| 1215 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1216 | alloc_info.pNext = NULL; |
| 1217 | alloc_info.memoryTypeIndex = 0; |
| 1218 | // Ensure memory is big enough for both bindings |
| 1219 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1220 | pass = m_device->phy().set_memory_type( |
| 1221 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1222 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1223 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1224 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1225 | vkDestroyImage(m_device->device(), image, NULL); |
| 1226 | return; |
| 1227 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1228 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1229 | ASSERT_VK_SUCCESS(err); |
| 1230 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1231 | ASSERT_VK_SUCCESS(err); |
| 1232 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1233 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1234 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1235 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1236 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1237 | m_errorMonitor->VerifyFound(); |
| 1238 | |
| 1239 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1240 | // aliasing buffer2 |
| 1241 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1242 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1243 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1244 | ASSERT_VK_SUCCESS(err); |
| 1245 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1246 | ASSERT_VK_SUCCESS(err); |
| 1247 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1248 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1249 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1250 | m_errorMonitor->VerifyFound(); |
| 1251 | |
| 1252 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1253 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1254 | vkDestroyImage(m_device->device(), image, NULL); |
| 1255 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1256 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1257 | } |
| 1258 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1259 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1260 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1261 | VkResult err; |
| 1262 | bool pass; |
| 1263 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1264 | |
| 1265 | VkBuffer buffer; |
| 1266 | VkDeviceMemory mem; |
| 1267 | VkMemoryRequirements mem_reqs; |
| 1268 | |
| 1269 | VkBufferCreateInfo buf_info = {}; |
| 1270 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1271 | buf_info.pNext = NULL; |
| 1272 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1273 | buf_info.size = 256; |
| 1274 | buf_info.queueFamilyIndexCount = 0; |
| 1275 | buf_info.pQueueFamilyIndices = NULL; |
| 1276 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1277 | buf_info.flags = 0; |
| 1278 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1279 | ASSERT_VK_SUCCESS(err); |
| 1280 | |
| 1281 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1282 | VkMemoryAllocateInfo alloc_info = {}; |
| 1283 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1284 | alloc_info.pNext = NULL; |
| 1285 | alloc_info.memoryTypeIndex = 0; |
| 1286 | |
| 1287 | // Ensure memory is big enough for both bindings |
| 1288 | static const VkDeviceSize allocation_size = 0x10000; |
| 1289 | alloc_info.allocationSize = allocation_size; |
| 1290 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1291 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1292 | if (!pass) { |
| 1293 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1294 | return; |
| 1295 | } |
| 1296 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1297 | ASSERT_VK_SUCCESS(err); |
| 1298 | |
| 1299 | uint8_t *pData; |
| 1300 | // Attempt to map memory size 0 is invalid |
| 1301 | m_errorMonitor->SetDesiredFailureMsg( |
| 1302 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1303 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1304 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1305 | m_errorMonitor->VerifyFound(); |
| 1306 | // Map memory twice |
| 1307 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1308 | (void **)&pData); |
| 1309 | ASSERT_VK_SUCCESS(err); |
| 1310 | m_errorMonitor->SetDesiredFailureMsg( |
| 1311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1312 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1313 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1314 | (void **)&pData); |
| 1315 | m_errorMonitor->VerifyFound(); |
| 1316 | |
| 1317 | // Unmap the memory to avoid re-map error |
| 1318 | vkUnmapMemory(m_device->device(), mem); |
| 1319 | // overstep allocation with VK_WHOLE_SIZE |
| 1320 | m_errorMonitor->SetDesiredFailureMsg( |
| 1321 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1322 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1323 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1324 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1325 | m_errorMonitor->VerifyFound(); |
| 1326 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1327 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1328 | " oversteps total array size 0x"); |
| 1329 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1330 | (void **)&pData); |
| 1331 | m_errorMonitor->VerifyFound(); |
| 1332 | // Now error due to unmapping memory that's not mapped |
| 1333 | m_errorMonitor->SetDesiredFailureMsg( |
| 1334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1335 | "Unmapping Memory without memory being mapped: "); |
| 1336 | vkUnmapMemory(m_device->device(), mem); |
| 1337 | m_errorMonitor->VerifyFound(); |
| 1338 | // Now map memory and cause errors due to flushing invalid ranges |
| 1339 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1340 | (void **)&pData); |
| 1341 | ASSERT_VK_SUCCESS(err); |
| 1342 | VkMappedMemoryRange mmr = {}; |
| 1343 | mmr.memory = mem; |
| 1344 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1345 | m_errorMonitor->SetDesiredFailureMsg( |
| 1346 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1347 | ") is less than Memory Object's offset ("); |
| 1348 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1349 | m_errorMonitor->VerifyFound(); |
| 1350 | // Now flush range that oversteps mapped range |
| 1351 | vkUnmapMemory(m_device->device(), mem); |
| 1352 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1353 | ASSERT_VK_SUCCESS(err); |
| 1354 | mmr.offset = 16; |
| 1355 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1356 | m_errorMonitor->SetDesiredFailureMsg( |
| 1357 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1358 | ") exceeds the Memory Object's upper-bound ("); |
| 1359 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1360 | m_errorMonitor->VerifyFound(); |
| 1361 | |
| 1362 | pass = |
| 1363 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1364 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1365 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1366 | if (!pass) { |
| 1367 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1368 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1369 | return; |
| 1370 | } |
| 1371 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1372 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1373 | |
| 1374 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1375 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1376 | } |
| 1377 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1378 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1379 | VkResult err; |
| 1380 | bool pass; |
| 1381 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1382 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1383 | // following declaration (which is temporarily being moved below): |
| 1384 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1385 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1386 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1387 | uint32_t swapchain_image_count = 0; |
| 1388 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1389 | uint32_t image_index = 0; |
| 1390 | // VkPresentInfoKHR present_info = {}; |
| 1391 | |
| 1392 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1393 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1394 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1395 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1396 | // Use the functions from the VK_KHR_android_surface extension without |
| 1397 | // enabling that extension: |
| 1398 | |
| 1399 | // Create a surface: |
| 1400 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1401 | m_errorMonitor->SetDesiredFailureMsg( |
| 1402 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1403 | "extension was not enabled for this"); |
| 1404 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1405 | &surface); |
| 1406 | pass = (err != VK_SUCCESS); |
| 1407 | ASSERT_TRUE(pass); |
| 1408 | m_errorMonitor->VerifyFound(); |
| 1409 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1410 | |
| 1411 | |
| 1412 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1413 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1414 | // that extension: |
| 1415 | |
| 1416 | // Create a surface: |
| 1417 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1418 | m_errorMonitor->SetDesiredFailureMsg( |
| 1419 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1420 | "extension was not enabled for this"); |
| 1421 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1422 | pass = (err != VK_SUCCESS); |
| 1423 | ASSERT_TRUE(pass); |
| 1424 | m_errorMonitor->VerifyFound(); |
| 1425 | |
| 1426 | // Tell whether an mir_connection supports presentation: |
| 1427 | MirConnection *mir_connection = NULL; |
| 1428 | m_errorMonitor->SetDesiredFailureMsg( |
| 1429 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1430 | "extension was not enabled for this"); |
| 1431 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1432 | visual_id); |
| 1433 | m_errorMonitor->VerifyFound(); |
| 1434 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1435 | |
| 1436 | |
| 1437 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1438 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1439 | // enabling that extension: |
| 1440 | |
| 1441 | // Create a surface: |
| 1442 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1443 | m_errorMonitor->SetDesiredFailureMsg( |
| 1444 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1445 | "extension was not enabled for this"); |
| 1446 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1447 | &surface); |
| 1448 | pass = (err != VK_SUCCESS); |
| 1449 | ASSERT_TRUE(pass); |
| 1450 | m_errorMonitor->VerifyFound(); |
| 1451 | |
| 1452 | // Tell whether an wayland_display supports presentation: |
| 1453 | struct wl_display wayland_display = {}; |
| 1454 | m_errorMonitor->SetDesiredFailureMsg( |
| 1455 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1456 | "extension was not enabled for this"); |
| 1457 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1458 | &wayland_display); |
| 1459 | m_errorMonitor->VerifyFound(); |
| 1460 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1461 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1462 | |
| 1463 | |
| 1464 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1465 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1466 | // TO NON-LINUX PLATFORMS: |
| 1467 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1468 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1469 | // enabling that extension: |
| 1470 | |
| 1471 | // Create a surface: |
| 1472 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1473 | m_errorMonitor->SetDesiredFailureMsg( |
| 1474 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1475 | "extension was not enabled for this"); |
| 1476 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1477 | &surface); |
| 1478 | pass = (err != VK_SUCCESS); |
| 1479 | ASSERT_TRUE(pass); |
| 1480 | m_errorMonitor->VerifyFound(); |
| 1481 | |
| 1482 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1483 | m_errorMonitor->SetDesiredFailureMsg( |
| 1484 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1485 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1486 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1487 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1488 | // Set this (for now, until all platforms are supported and tested): |
| 1489 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1490 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1491 | |
| 1492 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1493 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1494 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1495 | // TO NON-LINUX PLATFORMS: |
| 1496 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1497 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1498 | // that extension: |
| 1499 | |
| 1500 | // Create a surface: |
| 1501 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1502 | m_errorMonitor->SetDesiredFailureMsg( |
| 1503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1504 | "extension was not enabled for this"); |
| 1505 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1506 | pass = (err != VK_SUCCESS); |
| 1507 | ASSERT_TRUE(pass); |
| 1508 | m_errorMonitor->VerifyFound(); |
| 1509 | |
| 1510 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1511 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1512 | xcb_visualid_t visual_id = 0; |
| 1513 | m_errorMonitor->SetDesiredFailureMsg( |
| 1514 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1515 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1516 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1517 | visual_id); |
| 1518 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1519 | // Set this (for now, until all platforms are supported and tested): |
| 1520 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1521 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1522 | |
| 1523 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1524 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1525 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1526 | // that extension: |
| 1527 | |
| 1528 | // Create a surface: |
| 1529 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1530 | m_errorMonitor->SetDesiredFailureMsg( |
| 1531 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1532 | "extension was not enabled for this"); |
| 1533 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1534 | pass = (err != VK_SUCCESS); |
| 1535 | ASSERT_TRUE(pass); |
| 1536 | m_errorMonitor->VerifyFound(); |
| 1537 | |
| 1538 | // Tell whether an Xlib VisualID supports presentation: |
| 1539 | Display *dpy = NULL; |
| 1540 | VisualID visual = 0; |
| 1541 | m_errorMonitor->SetDesiredFailureMsg( |
| 1542 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1543 | "extension was not enabled for this"); |
| 1544 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1545 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1546 | // Set this (for now, until all platforms are supported and tested): |
| 1547 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1548 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1549 | |
| 1550 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1551 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1552 | // that extension: |
| 1553 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1554 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1555 | // Destroy a surface: |
| 1556 | m_errorMonitor->SetDesiredFailureMsg( |
| 1557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1558 | "extension was not enabled for this"); |
| 1559 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1560 | m_errorMonitor->VerifyFound(); |
| 1561 | |
| 1562 | // Check if surface supports presentation: |
| 1563 | VkBool32 supported = false; |
| 1564 | m_errorMonitor->SetDesiredFailureMsg( |
| 1565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1566 | "extension was not enabled for this"); |
| 1567 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1568 | pass = (err != VK_SUCCESS); |
| 1569 | ASSERT_TRUE(pass); |
| 1570 | m_errorMonitor->VerifyFound(); |
| 1571 | |
| 1572 | // Check surface capabilities: |
| 1573 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1574 | m_errorMonitor->SetDesiredFailureMsg( |
| 1575 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1576 | "extension was not enabled for this"); |
| 1577 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1578 | &capabilities); |
| 1579 | pass = (err != VK_SUCCESS); |
| 1580 | ASSERT_TRUE(pass); |
| 1581 | m_errorMonitor->VerifyFound(); |
| 1582 | |
| 1583 | // Check surface formats: |
| 1584 | uint32_t format_count = 0; |
| 1585 | VkSurfaceFormatKHR *formats = NULL; |
| 1586 | m_errorMonitor->SetDesiredFailureMsg( |
| 1587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1588 | "extension was not enabled for this"); |
| 1589 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1590 | &format_count, formats); |
| 1591 | pass = (err != VK_SUCCESS); |
| 1592 | ASSERT_TRUE(pass); |
| 1593 | m_errorMonitor->VerifyFound(); |
| 1594 | |
| 1595 | // Check surface present modes: |
| 1596 | uint32_t present_mode_count = 0; |
| 1597 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1598 | m_errorMonitor->SetDesiredFailureMsg( |
| 1599 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1600 | "extension was not enabled for this"); |
| 1601 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1602 | &present_mode_count, present_modes); |
| 1603 | pass = (err != VK_SUCCESS); |
| 1604 | ASSERT_TRUE(pass); |
| 1605 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1606 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1607 | |
| 1608 | |
| 1609 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1610 | // that extension: |
| 1611 | |
| 1612 | // Create a swapchain: |
| 1613 | m_errorMonitor->SetDesiredFailureMsg( |
| 1614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1615 | "extension was not enabled for this"); |
| 1616 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1617 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1618 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1619 | NULL, &swapchain); |
| 1620 | pass = (err != VK_SUCCESS); |
| 1621 | ASSERT_TRUE(pass); |
| 1622 | m_errorMonitor->VerifyFound(); |
| 1623 | |
| 1624 | // Get the images from the swapchain: |
| 1625 | m_errorMonitor->SetDesiredFailureMsg( |
| 1626 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1627 | "extension was not enabled for this"); |
| 1628 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1629 | &swapchain_image_count, NULL); |
| 1630 | pass = (err != VK_SUCCESS); |
| 1631 | ASSERT_TRUE(pass); |
| 1632 | m_errorMonitor->VerifyFound(); |
| 1633 | |
| 1634 | // Try to acquire an image: |
| 1635 | m_errorMonitor->SetDesiredFailureMsg( |
| 1636 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1637 | "extension was not enabled for this"); |
| 1638 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1639 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1640 | pass = (err != VK_SUCCESS); |
| 1641 | ASSERT_TRUE(pass); |
| 1642 | m_errorMonitor->VerifyFound(); |
| 1643 | |
| 1644 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1645 | // |
| 1646 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1647 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1648 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1649 | |
| 1650 | // Destroy the swapchain: |
| 1651 | m_errorMonitor->SetDesiredFailureMsg( |
| 1652 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1653 | "extension was not enabled for this"); |
| 1654 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1655 | m_errorMonitor->VerifyFound(); |
| 1656 | } |
| 1657 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1658 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1659 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1660 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1661 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1662 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1663 | VkResult err; |
| 1664 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1665 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1666 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1667 | // uint32_t swapchain_image_count = 0; |
| 1668 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1669 | // uint32_t image_index = 0; |
| 1670 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1671 | |
| 1672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1673 | |
| 1674 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1675 | // order to create a surface, testing all known errors in the process, |
| 1676 | // before successfully creating a surface: |
| 1677 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1678 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1679 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1680 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1681 | pass = (err != VK_SUCCESS); |
| 1682 | ASSERT_TRUE(pass); |
| 1683 | m_errorMonitor->VerifyFound(); |
| 1684 | |
| 1685 | // Next, try to create a surface with the wrong |
| 1686 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1687 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1688 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1689 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1690 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1691 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1692 | pass = (err != VK_SUCCESS); |
| 1693 | ASSERT_TRUE(pass); |
| 1694 | m_errorMonitor->VerifyFound(); |
| 1695 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1696 | // Create a native window, and then correctly create a surface: |
| 1697 | xcb_connection_t *connection; |
| 1698 | xcb_screen_t *screen; |
| 1699 | xcb_window_t xcb_window; |
| 1700 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1701 | |
| 1702 | const xcb_setup_t *setup; |
| 1703 | xcb_screen_iterator_t iter; |
| 1704 | int scr; |
| 1705 | uint32_t value_mask, value_list[32]; |
| 1706 | int width = 1; |
| 1707 | int height = 1; |
| 1708 | |
| 1709 | connection = xcb_connect(NULL, &scr); |
| 1710 | ASSERT_TRUE(connection != NULL); |
| 1711 | setup = xcb_get_setup(connection); |
| 1712 | iter = xcb_setup_roots_iterator(setup); |
| 1713 | while (scr-- > 0) |
| 1714 | xcb_screen_next(&iter); |
| 1715 | screen = iter.data; |
| 1716 | |
| 1717 | xcb_window = xcb_generate_id(connection); |
| 1718 | |
| 1719 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1720 | value_list[0] = screen->black_pixel; |
| 1721 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1722 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1723 | |
| 1724 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1725 | screen->root, 0, 0, width, height, 0, |
| 1726 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1727 | value_mask, value_list); |
| 1728 | |
| 1729 | /* Magic code that will send notification when window is destroyed */ |
| 1730 | xcb_intern_atom_cookie_t cookie = |
| 1731 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1732 | xcb_intern_atom_reply_t *reply = |
| 1733 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1734 | |
| 1735 | xcb_intern_atom_cookie_t cookie2 = |
| 1736 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1737 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1738 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1739 | (*reply).atom, 4, 32, 1, |
| 1740 | &(*atom_wm_delete_window).atom); |
| 1741 | free(reply); |
| 1742 | |
| 1743 | xcb_map_window(connection, xcb_window); |
| 1744 | |
| 1745 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1746 | // runs |
| 1747 | const uint32_t coords[] = {100, 100}; |
| 1748 | xcb_configure_window(connection, xcb_window, |
| 1749 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1750 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1751 | // Finally, try to correctly create a surface: |
| 1752 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1753 | xcb_create_info.pNext = NULL; |
| 1754 | xcb_create_info.flags = 0; |
| 1755 | xcb_create_info.connection = connection; |
| 1756 | xcb_create_info.window = xcb_window; |
| 1757 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1758 | pass = (err == VK_SUCCESS); |
| 1759 | ASSERT_TRUE(pass); |
| 1760 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1761 | // Check if surface supports presentation: |
| 1762 | |
| 1763 | // 1st, do so without having queried the queue families: |
| 1764 | VkBool32 supported = false; |
| 1765 | // TODO: Get the following error to come out: |
| 1766 | m_errorMonitor->SetDesiredFailureMsg( |
| 1767 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1768 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1769 | "function"); |
| 1770 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1771 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1772 | // ASSERT_TRUE(pass); |
| 1773 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1774 | |
| 1775 | // Next, query a queue family index that's too large: |
| 1776 | m_errorMonitor->SetDesiredFailureMsg( |
| 1777 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1778 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1779 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1780 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1781 | pass = (err != VK_SUCCESS); |
| 1782 | ASSERT_TRUE(pass); |
| 1783 | m_errorMonitor->VerifyFound(); |
| 1784 | |
| 1785 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1786 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1787 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1788 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1789 | pass = (err == VK_SUCCESS); |
| 1790 | ASSERT_TRUE(pass); |
| 1791 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1792 | // Before proceeding, try to create a swapchain without having called |
| 1793 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1794 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1795 | swapchain_create_info.pNext = NULL; |
| 1796 | swapchain_create_info.flags = 0; |
| 1797 | m_errorMonitor->SetDesiredFailureMsg( |
| 1798 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1799 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1800 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1801 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1802 | pass = (err != VK_SUCCESS); |
| 1803 | ASSERT_TRUE(pass); |
| 1804 | m_errorMonitor->VerifyFound(); |
| 1805 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1806 | // Get the surface capabilities: |
| 1807 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1808 | |
| 1809 | // Do so correctly (only error logged by this entrypoint is if the |
| 1810 | // extension isn't enabled): |
| 1811 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1812 | &surface_capabilities); |
| 1813 | pass = (err == VK_SUCCESS); |
| 1814 | ASSERT_TRUE(pass); |
| 1815 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1816 | // Get the surface formats: |
| 1817 | uint32_t surface_format_count; |
| 1818 | |
| 1819 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1820 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1821 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1822 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1823 | pass = (err == VK_SUCCESS); |
| 1824 | ASSERT_TRUE(pass); |
| 1825 | m_errorMonitor->VerifyFound(); |
| 1826 | |
| 1827 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1828 | // correctly done a 1st try (to get the count): |
| 1829 | m_errorMonitor->SetDesiredFailureMsg( |
| 1830 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1831 | "but no prior positive value has been seen for"); |
| 1832 | surface_format_count = 0; |
| 1833 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1834 | gpu(), surface, &surface_format_count, |
| 1835 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1836 | pass = (err == VK_SUCCESS); |
| 1837 | ASSERT_TRUE(pass); |
| 1838 | m_errorMonitor->VerifyFound(); |
| 1839 | |
| 1840 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1841 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1842 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1843 | pass = (err == VK_SUCCESS); |
| 1844 | ASSERT_TRUE(pass); |
| 1845 | |
| 1846 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1847 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1848 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1849 | |
| 1850 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1851 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1852 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1853 | "that is greater than the value"); |
| 1854 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1855 | surface_formats); |
| 1856 | pass = (err == VK_SUCCESS); |
| 1857 | ASSERT_TRUE(pass); |
| 1858 | m_errorMonitor->VerifyFound(); |
| 1859 | |
| 1860 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1861 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1862 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1863 | pass = (err == VK_SUCCESS); |
| 1864 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1865 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1866 | surface_formats); |
| 1867 | pass = (err == VK_SUCCESS); |
| 1868 | ASSERT_TRUE(pass); |
| 1869 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1870 | // Get the surface present modes: |
| 1871 | uint32_t surface_present_mode_count; |
| 1872 | |
| 1873 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1875 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1876 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1877 | pass = (err == VK_SUCCESS); |
| 1878 | ASSERT_TRUE(pass); |
| 1879 | m_errorMonitor->VerifyFound(); |
| 1880 | |
| 1881 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1882 | // correctly done a 1st try (to get the count): |
| 1883 | m_errorMonitor->SetDesiredFailureMsg( |
| 1884 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1885 | "but no prior positive value has been seen for"); |
| 1886 | surface_present_mode_count = 0; |
| 1887 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1888 | gpu(), surface, &surface_present_mode_count, |
| 1889 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1890 | pass = (err == VK_SUCCESS); |
| 1891 | ASSERT_TRUE(pass); |
| 1892 | m_errorMonitor->VerifyFound(); |
| 1893 | |
| 1894 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1895 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1896 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1897 | pass = (err == VK_SUCCESS); |
| 1898 | ASSERT_TRUE(pass); |
| 1899 | |
| 1900 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1901 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1902 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1903 | |
| 1904 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1905 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1906 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1907 | "that is greater than the value"); |
| 1908 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1909 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1910 | pass = (err == VK_SUCCESS); |
| 1911 | ASSERT_TRUE(pass); |
| 1912 | m_errorMonitor->VerifyFound(); |
| 1913 | |
| 1914 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1915 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1916 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1917 | pass = (err == VK_SUCCESS); |
| 1918 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1919 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1920 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1921 | pass = (err == VK_SUCCESS); |
| 1922 | ASSERT_TRUE(pass); |
| 1923 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1924 | // Create a swapchain: |
| 1925 | |
| 1926 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1927 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1928 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1929 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1930 | pass = (err != VK_SUCCESS); |
| 1931 | ASSERT_TRUE(pass); |
| 1932 | m_errorMonitor->VerifyFound(); |
| 1933 | |
| 1934 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1935 | // sType: |
| 1936 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1937 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1938 | "called with the wrong value for"); |
| 1939 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1940 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1941 | pass = (err != VK_SUCCESS); |
| 1942 | ASSERT_TRUE(pass); |
| 1943 | m_errorMonitor->VerifyFound(); |
| 1944 | |
| 1945 | // Next, call with a NULL swapchain pointer: |
| 1946 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1947 | swapchain_create_info.pNext = NULL; |
| 1948 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1949 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1950 | "called with NULL pointer"); |
| 1951 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1952 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1953 | pass = (err != VK_SUCCESS); |
| 1954 | ASSERT_TRUE(pass); |
| 1955 | m_errorMonitor->VerifyFound(); |
| 1956 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1957 | // TODO: Enhance swapchain layer so that |
| 1958 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1959 | |
| 1960 | // Next, call with a queue family index that's too large: |
| 1961 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1962 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1963 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1964 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1965 | m_errorMonitor->SetDesiredFailureMsg( |
| 1966 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1967 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1968 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1969 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1970 | pass = (err != VK_SUCCESS); |
| 1971 | ASSERT_TRUE(pass); |
| 1972 | m_errorMonitor->VerifyFound(); |
| 1973 | |
| 1974 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1975 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1976 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1977 | m_errorMonitor->SetDesiredFailureMsg( |
| 1978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1979 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1980 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1981 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1982 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1983 | pass = (err != VK_SUCCESS); |
| 1984 | ASSERT_TRUE(pass); |
| 1985 | m_errorMonitor->VerifyFound(); |
| 1986 | |
| 1987 | // Next, call with an invalid imageSharingMode: |
| 1988 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1989 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1990 | m_errorMonitor->SetDesiredFailureMsg( |
| 1991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1992 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1993 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1994 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1995 | pass = (err != VK_SUCCESS); |
| 1996 | ASSERT_TRUE(pass); |
| 1997 | m_errorMonitor->VerifyFound(); |
| 1998 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1999 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 2000 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2001 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2002 | queueFamilyIndex[0] = 0; |
| 2003 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2004 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2005 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2006 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2007 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2008 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2009 | // Destroy the swapchain: |
| 2010 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2011 | // TODOs: |
| 2012 | // |
| 2013 | // - Try destroying the device without first destroying the swapchain |
| 2014 | // |
| 2015 | // - Try destroying the device without first destroying the surface |
| 2016 | // |
| 2017 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2018 | |
| 2019 | // Destroy the surface: |
| 2020 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2021 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2022 | // Tear down the window: |
| 2023 | xcb_destroy_window(connection, xcb_window); |
| 2024 | xcb_disconnect(connection); |
| 2025 | |
| 2026 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2027 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2028 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2029 | } |
| 2030 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2031 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2032 | VkResult err; |
| 2033 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2034 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2035 | m_errorMonitor->SetDesiredFailureMsg( |
| 2036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2037 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2038 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2039 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2040 | |
| 2041 | // 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] | 2042 | VkImage image; |
| 2043 | VkDeviceMemory mem; |
| 2044 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2045 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2046 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2047 | const int32_t tex_width = 32; |
| 2048 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2049 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2050 | VkImageCreateInfo image_create_info = {}; |
| 2051 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2052 | image_create_info.pNext = NULL; |
| 2053 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2054 | image_create_info.format = tex_format; |
| 2055 | image_create_info.extent.width = tex_width; |
| 2056 | image_create_info.extent.height = tex_height; |
| 2057 | image_create_info.extent.depth = 1; |
| 2058 | image_create_info.mipLevels = 1; |
| 2059 | image_create_info.arrayLayers = 1; |
| 2060 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2061 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2062 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2063 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2064 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2065 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2066 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2067 | mem_alloc.pNext = NULL; |
| 2068 | mem_alloc.allocationSize = 0; |
| 2069 | // Introduce failure, do NOT set memProps to |
| 2070 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2071 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2072 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2073 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2074 | ASSERT_VK_SUCCESS(err); |
| 2075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2076 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2077 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2078 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2079 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2080 | pass = |
| 2081 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2082 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2083 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2084 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2085 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2086 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2087 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2088 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2089 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2090 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2091 | ASSERT_VK_SUCCESS(err); |
| 2092 | |
| 2093 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2094 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2095 | ASSERT_VK_SUCCESS(err); |
| 2096 | |
| 2097 | // Map memory as if to initialize the image |
| 2098 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2099 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2100 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2101 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2102 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2103 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2104 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2105 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2106 | } |
| 2107 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2108 | TEST_F(VkLayerTest, RebindMemory) { |
| 2109 | VkResult err; |
| 2110 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2111 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2112 | m_errorMonitor->SetDesiredFailureMsg( |
| 2113 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2114 | "which has already been bound to mem object"); |
| 2115 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2116 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2117 | |
| 2118 | // 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] | 2119 | VkImage image; |
| 2120 | VkDeviceMemory mem1; |
| 2121 | VkDeviceMemory mem2; |
| 2122 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2124 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2125 | const int32_t tex_width = 32; |
| 2126 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2127 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2128 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2129 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2130 | image_create_info.pNext = NULL; |
| 2131 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2132 | image_create_info.format = tex_format; |
| 2133 | image_create_info.extent.width = tex_width; |
| 2134 | image_create_info.extent.height = tex_height; |
| 2135 | image_create_info.extent.depth = 1; |
| 2136 | image_create_info.mipLevels = 1; |
| 2137 | image_create_info.arrayLayers = 1; |
| 2138 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2139 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2140 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2141 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2142 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2143 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2144 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2145 | mem_alloc.pNext = NULL; |
| 2146 | mem_alloc.allocationSize = 0; |
| 2147 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2149 | // Introduce failure, do NOT set memProps to |
| 2150 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2151 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2152 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2153 | ASSERT_VK_SUCCESS(err); |
| 2154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2155 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2156 | |
| 2157 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2158 | pass = |
| 2159 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2160 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2161 | |
| 2162 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2163 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2164 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2165 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2166 | ASSERT_VK_SUCCESS(err); |
| 2167 | |
| 2168 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2169 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2170 | ASSERT_VK_SUCCESS(err); |
| 2171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2172 | // Introduce validation failure, try to bind a different memory object to |
| 2173 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2174 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2175 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2176 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2177 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2178 | vkDestroyImage(m_device->device(), image, NULL); |
| 2179 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2180 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2181 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2182 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2183 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2184 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2185 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2186 | m_errorMonitor->SetDesiredFailureMsg( |
| 2187 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2188 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2189 | |
| 2190 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2191 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2192 | fenceInfo.pNext = NULL; |
| 2193 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2194 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2195 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2196 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2197 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2198 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2199 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2200 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2201 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2202 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2203 | |
| 2204 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2205 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2206 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2207 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2208 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2209 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2210 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2211 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2212 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2213 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2214 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2215 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2216 | |
| 2217 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2218 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2219 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2220 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2221 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2222 | // This is a positive test. We used to expect error in this case but spec now |
| 2223 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2224 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2225 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2226 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2227 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2228 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2229 | fenceInfo.pNext = NULL; |
| 2230 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2232 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2233 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2234 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2235 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2236 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2237 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2238 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2239 | |
| 2240 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2241 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2242 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2243 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2244 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2245 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2246 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2247 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2248 | |
| 2249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2250 | VkImageObj image(m_device); |
| 2251 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2252 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2253 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2254 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2255 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2256 | VkImageView dsv; |
| 2257 | VkImageViewCreateInfo dsvci = {}; |
| 2258 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2259 | dsvci.image = image.handle(); |
| 2260 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2261 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2262 | dsvci.subresourceRange.layerCount = 1; |
| 2263 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2264 | dsvci.subresourceRange.levelCount = 1; |
| 2265 | dsvci.subresourceRange.aspectMask = |
| 2266 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2267 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2268 | // Create a view with depth / stencil aspect for image with different usage |
| 2269 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2270 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2271 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2272 | |
| 2273 | // Initialize buffer with TRANSFER_DST usage |
| 2274 | vk_testing::Buffer buffer; |
| 2275 | VkMemoryPropertyFlags reqs = 0; |
| 2276 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2277 | VkBufferImageCopy region = {}; |
| 2278 | region.bufferRowLength = 128; |
| 2279 | region.bufferImageHeight = 128; |
| 2280 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2281 | region.imageSubresource.layerCount = 1; |
| 2282 | region.imageExtent.height = 16; |
| 2283 | region.imageExtent.width = 16; |
| 2284 | region.imageExtent.depth = 1; |
| 2285 | |
| 2286 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2287 | "Invalid usage flag for buffer "); |
| 2288 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2289 | // TRANSFER_DST |
| 2290 | BeginCommandBuffer(); |
| 2291 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2292 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2293 | 1, ®ion); |
| 2294 | m_errorMonitor->VerifyFound(); |
| 2295 | |
| 2296 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2297 | "Invalid usage flag for image "); |
| 2298 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2299 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2300 | 1, ®ion); |
| 2301 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2302 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2303 | #endif // MEM_TRACKER_TESTS |
| 2304 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2305 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2306 | |
| 2307 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2308 | VkResult err; |
| 2309 | |
| 2310 | TEST_DESCRIPTION( |
| 2311 | "Create a fence and destroy its device without first destroying the fence."); |
| 2312 | |
| 2313 | // Note that we have to create a new device since destroying the |
| 2314 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2315 | // will destroy the errorMonitor. |
| 2316 | |
| 2317 | m_errorMonitor->SetDesiredFailureMsg( |
| 2318 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2319 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2320 | |
| 2321 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2322 | |
| 2323 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2324 | m_device->queue_props; |
| 2325 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2326 | queue_info.reserve(queue_props.size()); |
| 2327 | std::vector<std::vector<float>> queue_priorities; |
| 2328 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2329 | VkDeviceQueueCreateInfo qi = {}; |
| 2330 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2331 | qi.pNext = NULL; |
| 2332 | qi.queueFamilyIndex = i; |
| 2333 | qi.queueCount = queue_props[i].queueCount; |
| 2334 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2335 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2336 | queue_info.push_back(qi); |
| 2337 | } |
| 2338 | |
| 2339 | std::vector<const char *> device_layer_names; |
| 2340 | std::vector<const char *> device_extension_names; |
| 2341 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2342 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2343 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2344 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2345 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2346 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2347 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2348 | |
| 2349 | // The sacrificial device object |
| 2350 | VkDevice testDevice; |
| 2351 | VkDeviceCreateInfo device_create_info = {}; |
| 2352 | auto features = m_device->phy().features(); |
| 2353 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2354 | device_create_info.pNext = NULL; |
| 2355 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2356 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2357 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2358 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2359 | device_create_info.pEnabledFeatures = &features; |
| 2360 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2361 | ASSERT_VK_SUCCESS(err); |
| 2362 | |
| 2363 | VkFence fence; |
| 2364 | VkFenceCreateInfo fence_create_info = {}; |
| 2365 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2366 | fence_create_info.pNext = NULL; |
| 2367 | fence_create_info.flags = 0; |
| 2368 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2369 | ASSERT_VK_SUCCESS(err); |
| 2370 | |
| 2371 | // Induce failure by not calling vkDestroyFence |
| 2372 | vkDestroyDevice(testDevice, NULL); |
| 2373 | m_errorMonitor->VerifyFound(); |
| 2374 | } |
| 2375 | |
| 2376 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2377 | |
| 2378 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2379 | "attempt to delete them from another."); |
| 2380 | |
| 2381 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2382 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2383 | |
| 2384 | VkCommandPool command_pool_one; |
| 2385 | VkCommandPool command_pool_two; |
| 2386 | |
| 2387 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2388 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2389 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2390 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2391 | |
| 2392 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2393 | &command_pool_one); |
| 2394 | |
| 2395 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2396 | &command_pool_two); |
| 2397 | |
| 2398 | VkCommandBuffer command_buffer[9]; |
| 2399 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2400 | command_buffer_allocate_info.sType = |
| 2401 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2402 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2403 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2404 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2405 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2406 | command_buffer); |
| 2407 | |
| 2408 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2409 | &command_buffer[3]); |
| 2410 | |
| 2411 | m_errorMonitor->VerifyFound(); |
| 2412 | |
| 2413 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2414 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2415 | } |
| 2416 | |
| 2417 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2418 | VkResult err; |
| 2419 | |
| 2420 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2421 | "attempt to delete them from another."); |
| 2422 | |
| 2423 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2424 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2425 | |
| 2426 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2427 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2428 | |
| 2429 | VkDescriptorPoolSize ds_type_count = {}; |
| 2430 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2431 | ds_type_count.descriptorCount = 1; |
| 2432 | |
| 2433 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2434 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2435 | ds_pool_ci.pNext = NULL; |
| 2436 | ds_pool_ci.flags = 0; |
| 2437 | ds_pool_ci.maxSets = 1; |
| 2438 | ds_pool_ci.poolSizeCount = 1; |
| 2439 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2440 | |
| 2441 | VkDescriptorPool ds_pool_one; |
| 2442 | err = |
| 2443 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2444 | ASSERT_VK_SUCCESS(err); |
| 2445 | |
| 2446 | // Create a second descriptor pool |
| 2447 | VkDescriptorPool ds_pool_two; |
| 2448 | err = |
| 2449 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2450 | ASSERT_VK_SUCCESS(err); |
| 2451 | |
| 2452 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2453 | dsl_binding.binding = 0; |
| 2454 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2455 | dsl_binding.descriptorCount = 1; |
| 2456 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2457 | dsl_binding.pImmutableSamplers = NULL; |
| 2458 | |
| 2459 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2460 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2461 | ds_layout_ci.pNext = NULL; |
| 2462 | ds_layout_ci.bindingCount = 1; |
| 2463 | ds_layout_ci.pBindings = &dsl_binding; |
| 2464 | |
| 2465 | VkDescriptorSetLayout ds_layout; |
| 2466 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2467 | &ds_layout); |
| 2468 | ASSERT_VK_SUCCESS(err); |
| 2469 | |
| 2470 | VkDescriptorSet descriptorSet; |
| 2471 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2472 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2473 | alloc_info.descriptorSetCount = 1; |
| 2474 | alloc_info.descriptorPool = ds_pool_one; |
| 2475 | alloc_info.pSetLayouts = &ds_layout; |
| 2476 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2477 | &descriptorSet); |
| 2478 | ASSERT_VK_SUCCESS(err); |
| 2479 | |
| 2480 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2481 | |
| 2482 | m_errorMonitor->VerifyFound(); |
| 2483 | |
| 2484 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2485 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2486 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2487 | } |
| 2488 | |
| 2489 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2490 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2491 | "Invalid VkImage Object "); |
| 2492 | |
| 2493 | TEST_DESCRIPTION( |
| 2494 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2495 | |
| 2496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2497 | |
| 2498 | // Pass bogus handle into GetImageMemoryRequirements |
| 2499 | VkMemoryRequirements mem_reqs; |
| 2500 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2501 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2502 | |
| 2503 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2504 | |
| 2505 | m_errorMonitor->VerifyFound(); |
| 2506 | } |
| 2507 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2508 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2509 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2510 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2511 | TEST_DESCRIPTION( |
| 2512 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2513 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2515 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2516 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2517 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2518 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2519 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2520 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2521 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2522 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2523 | |
| 2524 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2525 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2526 | ds_pool_ci.pNext = NULL; |
| 2527 | ds_pool_ci.maxSets = 1; |
| 2528 | ds_pool_ci.poolSizeCount = 1; |
| 2529 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2530 | |
| 2531 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2532 | err = |
| 2533 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2534 | ASSERT_VK_SUCCESS(err); |
| 2535 | |
| 2536 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2537 | dsl_binding.binding = 0; |
| 2538 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2539 | dsl_binding.descriptorCount = 1; |
| 2540 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2541 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2542 | |
| 2543 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2544 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2545 | ds_layout_ci.pNext = NULL; |
| 2546 | ds_layout_ci.bindingCount = 1; |
| 2547 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2548 | |
| 2549 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2550 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2551 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2552 | ASSERT_VK_SUCCESS(err); |
| 2553 | |
| 2554 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2555 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2556 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2557 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2558 | alloc_info.descriptorPool = ds_pool; |
| 2559 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2560 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2561 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2562 | ASSERT_VK_SUCCESS(err); |
| 2563 | |
| 2564 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2565 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2566 | pipeline_layout_ci.pNext = NULL; |
| 2567 | pipeline_layout_ci.setLayoutCount = 1; |
| 2568 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2569 | |
| 2570 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2572 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2573 | ASSERT_VK_SUCCESS(err); |
| 2574 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2575 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2576 | |
| 2577 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2578 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2579 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2580 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2581 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2582 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2583 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2584 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2585 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2586 | } |
| 2587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2588 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2589 | VkResult err; |
| 2590 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2591 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2592 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2593 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2594 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2595 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2596 | |
| 2597 | // 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] | 2598 | VkImage image; |
| 2599 | VkDeviceMemory mem; |
| 2600 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2602 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2603 | const int32_t tex_width = 32; |
| 2604 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2605 | |
| 2606 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2607 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2608 | image_create_info.pNext = NULL; |
| 2609 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2610 | image_create_info.format = tex_format; |
| 2611 | image_create_info.extent.width = tex_width; |
| 2612 | image_create_info.extent.height = tex_height; |
| 2613 | image_create_info.extent.depth = 1; |
| 2614 | image_create_info.mipLevels = 1; |
| 2615 | image_create_info.arrayLayers = 1; |
| 2616 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2617 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2618 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2619 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2620 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2621 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2622 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2623 | mem_alloc.pNext = NULL; |
| 2624 | mem_alloc.allocationSize = 0; |
| 2625 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2626 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2627 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2628 | ASSERT_VK_SUCCESS(err); |
| 2629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2630 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2631 | |
| 2632 | mem_alloc.allocationSize = mem_reqs.size; |
| 2633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2634 | pass = |
| 2635 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2636 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2637 | |
| 2638 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2639 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2640 | ASSERT_VK_SUCCESS(err); |
| 2641 | |
| 2642 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2643 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2644 | |
| 2645 | // Try to bind free memory that has been freed |
| 2646 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2647 | // This may very well return an error. |
| 2648 | (void)err; |
| 2649 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2650 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2651 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2652 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2653 | } |
| 2654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2655 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2656 | VkResult err; |
| 2657 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2658 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2659 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2660 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2661 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2662 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2664 | // Create an image object, allocate memory, destroy the object and then try |
| 2665 | // to bind it |
| 2666 | VkImage image; |
| 2667 | VkDeviceMemory mem; |
| 2668 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2669 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2670 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2671 | const int32_t tex_width = 32; |
| 2672 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2673 | |
| 2674 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2675 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2676 | image_create_info.pNext = NULL; |
| 2677 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2678 | image_create_info.format = tex_format; |
| 2679 | image_create_info.extent.width = tex_width; |
| 2680 | image_create_info.extent.height = tex_height; |
| 2681 | image_create_info.extent.depth = 1; |
| 2682 | image_create_info.mipLevels = 1; |
| 2683 | image_create_info.arrayLayers = 1; |
| 2684 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2685 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2686 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2687 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2688 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2689 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2690 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2691 | mem_alloc.pNext = NULL; |
| 2692 | mem_alloc.allocationSize = 0; |
| 2693 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2694 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2695 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2696 | ASSERT_VK_SUCCESS(err); |
| 2697 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2698 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2699 | |
| 2700 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | pass = |
| 2702 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2703 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2704 | |
| 2705 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2706 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2707 | ASSERT_VK_SUCCESS(err); |
| 2708 | |
| 2709 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2710 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2711 | ASSERT_VK_SUCCESS(err); |
| 2712 | |
| 2713 | // Now Try to bind memory to this destroyed object |
| 2714 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2715 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2716 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2717 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2718 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2719 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2720 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2721 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2722 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2723 | #endif // OBJ_TRACKER_TESTS |
| 2724 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2725 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2726 | |
| 2727 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2728 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 2729 | TEST_DESCRIPTION( |
| 2730 | "Wait on a event then set it after the wait has been submitted."); |
| 2731 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2732 | m_errorMonitor->ExpectSuccess(); |
| 2733 | |
| 2734 | VkEvent event; |
| 2735 | VkEventCreateInfo event_create_info{}; |
| 2736 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2737 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2738 | |
| 2739 | VkCommandPool command_pool; |
| 2740 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2741 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2742 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2743 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2744 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2745 | &command_pool); |
| 2746 | |
| 2747 | VkCommandBuffer command_buffer; |
| 2748 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2749 | command_buffer_allocate_info.sType = |
| 2750 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2751 | command_buffer_allocate_info.commandPool = command_pool; |
| 2752 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2753 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2754 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2755 | &command_buffer); |
| 2756 | |
| 2757 | VkQueue queue = VK_NULL_HANDLE; |
| 2758 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 2759 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2760 | |
| 2761 | { |
| 2762 | VkCommandBufferBeginInfo begin_info{}; |
| 2763 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2764 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2765 | |
| 2766 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2767 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2768 | nullptr, 0, nullptr); |
| 2769 | vkCmdResetEvent(command_buffer, event, |
| 2770 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2771 | vkEndCommandBuffer(command_buffer); |
| 2772 | } |
| 2773 | { |
| 2774 | VkSubmitInfo submit_info{}; |
| 2775 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2776 | submit_info.commandBufferCount = 1; |
| 2777 | submit_info.pCommandBuffers = &command_buffer; |
| 2778 | submit_info.signalSemaphoreCount = 0; |
| 2779 | submit_info.pSignalSemaphores = nullptr; |
| 2780 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2781 | } |
| 2782 | { vkSetEvent(m_device->device(), event); } |
| 2783 | |
| 2784 | vkQueueWaitIdle(queue); |
| 2785 | |
| 2786 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2787 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2788 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2789 | |
| 2790 | m_errorMonitor->VerifyNotFound(); |
| 2791 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2792 | // This is a positive test. No errors should be generated. |
| 2793 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2794 | TEST_DESCRIPTION( |
| 2795 | "Issue a query and copy from it on a second command buffer."); |
| 2796 | |
| 2797 | if ((m_device->queue_props.empty()) || |
| 2798 | (m_device->queue_props[0].queueCount < 2)) |
| 2799 | return; |
| 2800 | |
| 2801 | m_errorMonitor->ExpectSuccess(); |
| 2802 | |
| 2803 | VkQueryPool query_pool; |
| 2804 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2805 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2806 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2807 | query_pool_create_info.queryCount = 1; |
| 2808 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2809 | &query_pool); |
| 2810 | |
| 2811 | VkCommandPool command_pool; |
| 2812 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2813 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2814 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2815 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2816 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2817 | &command_pool); |
| 2818 | |
| 2819 | VkCommandBuffer command_buffer[2]; |
| 2820 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2821 | command_buffer_allocate_info.sType = |
| 2822 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2823 | command_buffer_allocate_info.commandPool = command_pool; |
| 2824 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2825 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2826 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2827 | command_buffer); |
| 2828 | |
| 2829 | VkQueue queue = VK_NULL_HANDLE; |
| 2830 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2831 | 1, &queue); |
| 2832 | |
| 2833 | uint32_t qfi = 0; |
| 2834 | VkBufferCreateInfo buff_create_info = {}; |
| 2835 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2836 | buff_create_info.size = 1024; |
| 2837 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2838 | buff_create_info.queueFamilyIndexCount = 1; |
| 2839 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2840 | |
| 2841 | VkResult err; |
| 2842 | VkBuffer buffer; |
| 2843 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2844 | ASSERT_VK_SUCCESS(err); |
| 2845 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2846 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2847 | mem_alloc.pNext = NULL; |
| 2848 | mem_alloc.allocationSize = 1024; |
| 2849 | mem_alloc.memoryTypeIndex = 0; |
| 2850 | |
| 2851 | VkMemoryRequirements memReqs; |
| 2852 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2853 | bool pass = |
| 2854 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2855 | if (!pass) { |
| 2856 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2857 | return; |
| 2858 | } |
| 2859 | |
| 2860 | VkDeviceMemory mem; |
| 2861 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2862 | ASSERT_VK_SUCCESS(err); |
| 2863 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2864 | ASSERT_VK_SUCCESS(err); |
| 2865 | |
| 2866 | { |
| 2867 | VkCommandBufferBeginInfo begin_info{}; |
| 2868 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2869 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2870 | |
| 2871 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2872 | vkCmdWriteTimestamp(command_buffer[0], |
| 2873 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2874 | |
| 2875 | vkEndCommandBuffer(command_buffer[0]); |
| 2876 | |
| 2877 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2878 | |
| 2879 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 2880 | 0, 0, 0); |
| 2881 | |
| 2882 | vkEndCommandBuffer(command_buffer[1]); |
| 2883 | } |
| 2884 | { |
| 2885 | VkSubmitInfo submit_info{}; |
| 2886 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2887 | submit_info.commandBufferCount = 2; |
| 2888 | submit_info.pCommandBuffers = command_buffer; |
| 2889 | submit_info.signalSemaphoreCount = 0; |
| 2890 | submit_info.pSignalSemaphores = nullptr; |
| 2891 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2892 | } |
| 2893 | |
| 2894 | vkQueueWaitIdle(queue); |
| 2895 | |
| 2896 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 2897 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 2898 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2899 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2900 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2901 | |
| 2902 | m_errorMonitor->VerifyNotFound(); |
| 2903 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2904 | |
| 2905 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 2906 | TEST_DESCRIPTION( |
| 2907 | "Reset an event then set it after the reset has been submitted."); |
| 2908 | |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2909 | m_errorMonitor->ExpectSuccess(); |
| 2910 | |
| 2911 | VkEvent event; |
| 2912 | VkEventCreateInfo event_create_info{}; |
| 2913 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2914 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2915 | |
| 2916 | VkCommandPool command_pool; |
| 2917 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2918 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2919 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2920 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2921 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2922 | &command_pool); |
| 2923 | |
| 2924 | VkCommandBuffer command_buffer; |
| 2925 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2926 | command_buffer_allocate_info.sType = |
| 2927 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2928 | command_buffer_allocate_info.commandPool = command_pool; |
| 2929 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2930 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2931 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2932 | &command_buffer); |
| 2933 | |
| 2934 | VkQueue queue = VK_NULL_HANDLE; |
| 2935 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 2936 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2937 | |
| 2938 | { |
| 2939 | VkCommandBufferBeginInfo begin_info{}; |
| 2940 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2941 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2942 | |
| 2943 | vkCmdResetEvent(command_buffer, event, |
| 2944 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2945 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 2946 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2947 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2948 | nullptr, 0, nullptr); |
| 2949 | vkEndCommandBuffer(command_buffer); |
| 2950 | } |
| 2951 | { |
| 2952 | VkSubmitInfo submit_info{}; |
| 2953 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2954 | submit_info.commandBufferCount = 1; |
| 2955 | submit_info.pCommandBuffers = &command_buffer; |
| 2956 | submit_info.signalSemaphoreCount = 0; |
| 2957 | submit_info.pSignalSemaphores = nullptr; |
| 2958 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2959 | } |
| 2960 | { |
| 2961 | m_errorMonitor->SetDesiredFailureMsg( |
| 2962 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 2963 | "0x1 that is already in use by a " |
| 2964 | "command buffer."); |
| 2965 | vkSetEvent(m_device->device(), event); |
| 2966 | m_errorMonitor->VerifyFound(); |
| 2967 | } |
| 2968 | |
| 2969 | vkQueueWaitIdle(queue); |
| 2970 | |
| 2971 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2972 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2973 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2974 | } |
| 2975 | |
| 2976 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 2977 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 2978 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 2979 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 2980 | "previously revealed a bug so running this positive test " |
| 2981 | "to prevent a regression."); |
| 2982 | m_errorMonitor->ExpectSuccess(); |
| 2983 | |
| 2984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2985 | VkQueue queue = VK_NULL_HANDLE; |
| 2986 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2987 | 0, &queue); |
| 2988 | |
| 2989 | static const uint32_t NUM_OBJECTS = 2; |
| 2990 | static const uint32_t NUM_FRAMES = 3; |
| 2991 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 2992 | VkFence fences[NUM_OBJECTS] = {}; |
| 2993 | |
| 2994 | VkCommandPool cmd_pool; |
| 2995 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 2996 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2997 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2998 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2999 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3000 | nullptr, &cmd_pool); |
| 3001 | ASSERT_VK_SUCCESS(err); |
| 3002 | |
| 3003 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3004 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3005 | cmd_buf_info.commandPool = cmd_pool; |
| 3006 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3007 | cmd_buf_info.commandBufferCount = 1; |
| 3008 | |
| 3009 | VkFenceCreateInfo fence_ci = {}; |
| 3010 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3011 | fence_ci.pNext = nullptr; |
| 3012 | fence_ci.flags = 0; |
| 3013 | |
| 3014 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3015 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3016 | &cmd_buffers[i]); |
| 3017 | ASSERT_VK_SUCCESS(err); |
| 3018 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3019 | ASSERT_VK_SUCCESS(err); |
| 3020 | } |
| 3021 | |
| 3022 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3023 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3024 | // Create empty cmd buffer |
| 3025 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3026 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3027 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3028 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3029 | ASSERT_VK_SUCCESS(err); |
| 3030 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3031 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3032 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3033 | VkSubmitInfo submit_info = {}; |
| 3034 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3035 | submit_info.commandBufferCount = 1; |
| 3036 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3037 | // Submit cmd buffer and wait for fence |
| 3038 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3039 | ASSERT_VK_SUCCESS(err); |
| 3040 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3041 | UINT64_MAX); |
| 3042 | ASSERT_VK_SUCCESS(err); |
| 3043 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3044 | ASSERT_VK_SUCCESS(err); |
| 3045 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3046 | } |
| 3047 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3048 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3049 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3050 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3051 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3052 | } |
| 3053 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3054 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3055 | |
| 3056 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3057 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3058 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3059 | if ((m_device->queue_props.empty()) || |
| 3060 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3061 | return; |
| 3062 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3063 | m_errorMonitor->ExpectSuccess(); |
| 3064 | |
| 3065 | VkSemaphore semaphore; |
| 3066 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3067 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3068 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3069 | &semaphore); |
| 3070 | |
| 3071 | VkCommandPool command_pool; |
| 3072 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3073 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3074 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3075 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3076 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3077 | &command_pool); |
| 3078 | |
| 3079 | VkCommandBuffer command_buffer[2]; |
| 3080 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3081 | command_buffer_allocate_info.sType = |
| 3082 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3083 | command_buffer_allocate_info.commandPool = command_pool; |
| 3084 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3085 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3086 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3087 | command_buffer); |
| 3088 | |
| 3089 | VkQueue queue = VK_NULL_HANDLE; |
| 3090 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3091 | 1, &queue); |
| 3092 | |
| 3093 | { |
| 3094 | VkCommandBufferBeginInfo begin_info{}; |
| 3095 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3096 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3097 | |
| 3098 | vkCmdPipelineBarrier(command_buffer[0], |
| 3099 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3100 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3101 | 0, nullptr, 0, nullptr); |
| 3102 | |
| 3103 | VkViewport viewport{}; |
| 3104 | viewport.maxDepth = 1.0f; |
| 3105 | viewport.minDepth = 0.0f; |
| 3106 | viewport.width = 512; |
| 3107 | viewport.height = 512; |
| 3108 | viewport.x = 0; |
| 3109 | viewport.y = 0; |
| 3110 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3111 | vkEndCommandBuffer(command_buffer[0]); |
| 3112 | } |
| 3113 | { |
| 3114 | VkCommandBufferBeginInfo begin_info{}; |
| 3115 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3116 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3117 | |
| 3118 | VkViewport viewport{}; |
| 3119 | viewport.maxDepth = 1.0f; |
| 3120 | viewport.minDepth = 0.0f; |
| 3121 | viewport.width = 512; |
| 3122 | viewport.height = 512; |
| 3123 | viewport.x = 0; |
| 3124 | viewport.y = 0; |
| 3125 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3126 | vkEndCommandBuffer(command_buffer[1]); |
| 3127 | } |
| 3128 | { |
| 3129 | VkSubmitInfo submit_info{}; |
| 3130 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3131 | submit_info.commandBufferCount = 1; |
| 3132 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3133 | submit_info.signalSemaphoreCount = 1; |
| 3134 | submit_info.pSignalSemaphores = &semaphore; |
| 3135 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3136 | } |
| 3137 | { |
| 3138 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3139 | VkSubmitInfo submit_info{}; |
| 3140 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3141 | submit_info.commandBufferCount = 1; |
| 3142 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3143 | submit_info.waitSemaphoreCount = 1; |
| 3144 | submit_info.pWaitSemaphores = &semaphore; |
| 3145 | submit_info.pWaitDstStageMask = flags; |
| 3146 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3147 | } |
| 3148 | |
| 3149 | vkQueueWaitIdle(m_device->m_queue); |
| 3150 | |
| 3151 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3152 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3153 | &command_buffer[0]); |
| 3154 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3155 | |
| 3156 | m_errorMonitor->VerifyNotFound(); |
| 3157 | } |
| 3158 | |
| 3159 | // This is a positive test. No errors should be generated. |
| 3160 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3161 | |
| 3162 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3163 | "submitted on separate queues, the second having a fence" |
| 3164 | "followed by a QueueWaitIdle."); |
| 3165 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3166 | if ((m_device->queue_props.empty()) || |
| 3167 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3168 | return; |
| 3169 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3170 | m_errorMonitor->ExpectSuccess(); |
| 3171 | |
| 3172 | VkFence fence; |
| 3173 | VkFenceCreateInfo fence_create_info{}; |
| 3174 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3175 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3176 | |
| 3177 | VkSemaphore semaphore; |
| 3178 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3179 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3180 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3181 | &semaphore); |
| 3182 | |
| 3183 | VkCommandPool command_pool; |
| 3184 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3185 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3186 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3187 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3188 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3189 | &command_pool); |
| 3190 | |
| 3191 | VkCommandBuffer command_buffer[2]; |
| 3192 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3193 | command_buffer_allocate_info.sType = |
| 3194 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3195 | command_buffer_allocate_info.commandPool = command_pool; |
| 3196 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3197 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3198 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3199 | command_buffer); |
| 3200 | |
| 3201 | VkQueue queue = VK_NULL_HANDLE; |
| 3202 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3203 | 1, &queue); |
| 3204 | |
| 3205 | { |
| 3206 | VkCommandBufferBeginInfo begin_info{}; |
| 3207 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3208 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3209 | |
| 3210 | vkCmdPipelineBarrier(command_buffer[0], |
| 3211 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3212 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3213 | 0, nullptr, 0, nullptr); |
| 3214 | |
| 3215 | VkViewport viewport{}; |
| 3216 | viewport.maxDepth = 1.0f; |
| 3217 | viewport.minDepth = 0.0f; |
| 3218 | viewport.width = 512; |
| 3219 | viewport.height = 512; |
| 3220 | viewport.x = 0; |
| 3221 | viewport.y = 0; |
| 3222 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3223 | vkEndCommandBuffer(command_buffer[0]); |
| 3224 | } |
| 3225 | { |
| 3226 | VkCommandBufferBeginInfo begin_info{}; |
| 3227 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3228 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3229 | |
| 3230 | VkViewport viewport{}; |
| 3231 | viewport.maxDepth = 1.0f; |
| 3232 | viewport.minDepth = 0.0f; |
| 3233 | viewport.width = 512; |
| 3234 | viewport.height = 512; |
| 3235 | viewport.x = 0; |
| 3236 | viewport.y = 0; |
| 3237 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3238 | vkEndCommandBuffer(command_buffer[1]); |
| 3239 | } |
| 3240 | { |
| 3241 | VkSubmitInfo submit_info{}; |
| 3242 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3243 | submit_info.commandBufferCount = 1; |
| 3244 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3245 | submit_info.signalSemaphoreCount = 1; |
| 3246 | submit_info.pSignalSemaphores = &semaphore; |
| 3247 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3248 | } |
| 3249 | { |
| 3250 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3251 | VkSubmitInfo submit_info{}; |
| 3252 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3253 | submit_info.commandBufferCount = 1; |
| 3254 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3255 | submit_info.waitSemaphoreCount = 1; |
| 3256 | submit_info.pWaitSemaphores = &semaphore; |
| 3257 | submit_info.pWaitDstStageMask = flags; |
| 3258 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3259 | } |
| 3260 | |
| 3261 | vkQueueWaitIdle(m_device->m_queue); |
| 3262 | |
| 3263 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3264 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3265 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3266 | &command_buffer[0]); |
| 3267 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3268 | |
| 3269 | m_errorMonitor->VerifyNotFound(); |
| 3270 | } |
| 3271 | |
| 3272 | // This is a positive test. No errors should be generated. |
| 3273 | TEST_F(VkLayerTest, |
| 3274 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3275 | |
| 3276 | TEST_DESCRIPTION( |
| 3277 | "Two command buffers, each in a separate QueueSubmit call " |
| 3278 | "submitted on separate queues, the second having a fence" |
| 3279 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3280 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3281 | if ((m_device->queue_props.empty()) || |
| 3282 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3283 | return; |
| 3284 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3285 | m_errorMonitor->ExpectSuccess(); |
| 3286 | |
| 3287 | VkFence fence; |
| 3288 | VkFenceCreateInfo fence_create_info{}; |
| 3289 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3290 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3291 | |
| 3292 | VkSemaphore semaphore; |
| 3293 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3294 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3295 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3296 | &semaphore); |
| 3297 | |
| 3298 | VkCommandPool command_pool; |
| 3299 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3300 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3301 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3302 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3303 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3304 | &command_pool); |
| 3305 | |
| 3306 | VkCommandBuffer command_buffer[2]; |
| 3307 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3308 | command_buffer_allocate_info.sType = |
| 3309 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3310 | command_buffer_allocate_info.commandPool = command_pool; |
| 3311 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3312 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3313 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3314 | command_buffer); |
| 3315 | |
| 3316 | VkQueue queue = VK_NULL_HANDLE; |
| 3317 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3318 | 1, &queue); |
| 3319 | |
| 3320 | { |
| 3321 | VkCommandBufferBeginInfo begin_info{}; |
| 3322 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3323 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3324 | |
| 3325 | vkCmdPipelineBarrier(command_buffer[0], |
| 3326 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3327 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3328 | 0, nullptr, 0, nullptr); |
| 3329 | |
| 3330 | VkViewport viewport{}; |
| 3331 | viewport.maxDepth = 1.0f; |
| 3332 | viewport.minDepth = 0.0f; |
| 3333 | viewport.width = 512; |
| 3334 | viewport.height = 512; |
| 3335 | viewport.x = 0; |
| 3336 | viewport.y = 0; |
| 3337 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3338 | vkEndCommandBuffer(command_buffer[0]); |
| 3339 | } |
| 3340 | { |
| 3341 | VkCommandBufferBeginInfo begin_info{}; |
| 3342 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3343 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3344 | |
| 3345 | VkViewport viewport{}; |
| 3346 | viewport.maxDepth = 1.0f; |
| 3347 | viewport.minDepth = 0.0f; |
| 3348 | viewport.width = 512; |
| 3349 | viewport.height = 512; |
| 3350 | viewport.x = 0; |
| 3351 | viewport.y = 0; |
| 3352 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3353 | vkEndCommandBuffer(command_buffer[1]); |
| 3354 | } |
| 3355 | { |
| 3356 | VkSubmitInfo submit_info{}; |
| 3357 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3358 | submit_info.commandBufferCount = 1; |
| 3359 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3360 | submit_info.signalSemaphoreCount = 1; |
| 3361 | submit_info.pSignalSemaphores = &semaphore; |
| 3362 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3363 | } |
| 3364 | { |
| 3365 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3366 | VkSubmitInfo submit_info{}; |
| 3367 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3368 | submit_info.commandBufferCount = 1; |
| 3369 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3370 | submit_info.waitSemaphoreCount = 1; |
| 3371 | submit_info.pWaitSemaphores = &semaphore; |
| 3372 | submit_info.pWaitDstStageMask = flags; |
| 3373 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3374 | } |
| 3375 | |
| 3376 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3377 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3378 | |
| 3379 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3380 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3381 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3382 | &command_buffer[0]); |
| 3383 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3384 | |
| 3385 | m_errorMonitor->VerifyNotFound(); |
| 3386 | } |
| 3387 | |
| 3388 | // This is a positive test. No errors should be generated. |
| 3389 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3390 | |
| 3391 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3392 | "submitted on separate queues, the second having a fence, " |
| 3393 | "followed by a WaitForFences call."); |
| 3394 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3395 | if ((m_device->queue_props.empty()) || |
| 3396 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3397 | return; |
| 3398 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3399 | m_errorMonitor->ExpectSuccess(); |
| 3400 | |
| 3401 | VkFence fence; |
| 3402 | VkFenceCreateInfo fence_create_info{}; |
| 3403 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3404 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3405 | |
| 3406 | VkSemaphore semaphore; |
| 3407 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3408 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3409 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3410 | &semaphore); |
| 3411 | |
| 3412 | VkCommandPool command_pool; |
| 3413 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3414 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3415 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3416 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3417 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3418 | &command_pool); |
| 3419 | |
| 3420 | VkCommandBuffer command_buffer[2]; |
| 3421 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3422 | command_buffer_allocate_info.sType = |
| 3423 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3424 | command_buffer_allocate_info.commandPool = command_pool; |
| 3425 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3426 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3427 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3428 | command_buffer); |
| 3429 | |
| 3430 | VkQueue queue = VK_NULL_HANDLE; |
| 3431 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3432 | 1, &queue); |
| 3433 | |
| 3434 | |
| 3435 | { |
| 3436 | VkCommandBufferBeginInfo begin_info{}; |
| 3437 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3438 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3439 | |
| 3440 | vkCmdPipelineBarrier(command_buffer[0], |
| 3441 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3442 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3443 | 0, nullptr, 0, nullptr); |
| 3444 | |
| 3445 | VkViewport viewport{}; |
| 3446 | viewport.maxDepth = 1.0f; |
| 3447 | viewport.minDepth = 0.0f; |
| 3448 | viewport.width = 512; |
| 3449 | viewport.height = 512; |
| 3450 | viewport.x = 0; |
| 3451 | viewport.y = 0; |
| 3452 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3453 | vkEndCommandBuffer(command_buffer[0]); |
| 3454 | } |
| 3455 | { |
| 3456 | VkCommandBufferBeginInfo begin_info{}; |
| 3457 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3458 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3459 | |
| 3460 | VkViewport viewport{}; |
| 3461 | viewport.maxDepth = 1.0f; |
| 3462 | viewport.minDepth = 0.0f; |
| 3463 | viewport.width = 512; |
| 3464 | viewport.height = 512; |
| 3465 | viewport.x = 0; |
| 3466 | viewport.y = 0; |
| 3467 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3468 | vkEndCommandBuffer(command_buffer[1]); |
| 3469 | } |
| 3470 | { |
| 3471 | VkSubmitInfo submit_info{}; |
| 3472 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3473 | submit_info.commandBufferCount = 1; |
| 3474 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3475 | submit_info.signalSemaphoreCount = 1; |
| 3476 | submit_info.pSignalSemaphores = &semaphore; |
| 3477 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3478 | } |
| 3479 | { |
| 3480 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3481 | VkSubmitInfo submit_info{}; |
| 3482 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3483 | submit_info.commandBufferCount = 1; |
| 3484 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3485 | submit_info.waitSemaphoreCount = 1; |
| 3486 | submit_info.pWaitSemaphores = &semaphore; |
| 3487 | submit_info.pWaitDstStageMask = flags; |
| 3488 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3489 | } |
| 3490 | |
| 3491 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3492 | |
| 3493 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3494 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3495 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3496 | &command_buffer[0]); |
| 3497 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3498 | |
| 3499 | m_errorMonitor->VerifyNotFound(); |
| 3500 | } |
| 3501 | |
| 3502 | // This is a positive test. No errors should be generated. |
| 3503 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3504 | |
| 3505 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3506 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3507 | "second having a fence, " |
| 3508 | "followed by a WaitForFences call."); |
| 3509 | |
| 3510 | m_errorMonitor->ExpectSuccess(); |
| 3511 | |
| 3512 | VkFence fence; |
| 3513 | VkFenceCreateInfo fence_create_info{}; |
| 3514 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3515 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3516 | |
| 3517 | VkSemaphore semaphore; |
| 3518 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3519 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3520 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3521 | &semaphore); |
| 3522 | |
| 3523 | VkCommandPool command_pool; |
| 3524 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3525 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3526 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3527 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3528 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3529 | &command_pool); |
| 3530 | |
| 3531 | VkCommandBuffer command_buffer[2]; |
| 3532 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3533 | command_buffer_allocate_info.sType = |
| 3534 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3535 | command_buffer_allocate_info.commandPool = command_pool; |
| 3536 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3537 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3538 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3539 | command_buffer); |
| 3540 | |
| 3541 | { |
| 3542 | VkCommandBufferBeginInfo begin_info{}; |
| 3543 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3544 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3545 | |
| 3546 | vkCmdPipelineBarrier(command_buffer[0], |
| 3547 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3548 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3549 | 0, nullptr, 0, nullptr); |
| 3550 | |
| 3551 | VkViewport viewport{}; |
| 3552 | viewport.maxDepth = 1.0f; |
| 3553 | viewport.minDepth = 0.0f; |
| 3554 | viewport.width = 512; |
| 3555 | viewport.height = 512; |
| 3556 | viewport.x = 0; |
| 3557 | viewport.y = 0; |
| 3558 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3559 | vkEndCommandBuffer(command_buffer[0]); |
| 3560 | } |
| 3561 | { |
| 3562 | VkCommandBufferBeginInfo begin_info{}; |
| 3563 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3564 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3565 | |
| 3566 | VkViewport viewport{}; |
| 3567 | viewport.maxDepth = 1.0f; |
| 3568 | viewport.minDepth = 0.0f; |
| 3569 | viewport.width = 512; |
| 3570 | viewport.height = 512; |
| 3571 | viewport.x = 0; |
| 3572 | viewport.y = 0; |
| 3573 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3574 | vkEndCommandBuffer(command_buffer[1]); |
| 3575 | } |
| 3576 | { |
| 3577 | VkSubmitInfo submit_info{}; |
| 3578 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3579 | submit_info.commandBufferCount = 1; |
| 3580 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3581 | submit_info.signalSemaphoreCount = 1; |
| 3582 | submit_info.pSignalSemaphores = &semaphore; |
| 3583 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3584 | } |
| 3585 | { |
| 3586 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3587 | VkSubmitInfo submit_info{}; |
| 3588 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3589 | submit_info.commandBufferCount = 1; |
| 3590 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3591 | submit_info.waitSemaphoreCount = 1; |
| 3592 | submit_info.pWaitSemaphores = &semaphore; |
| 3593 | submit_info.pWaitDstStageMask = flags; |
| 3594 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3595 | } |
| 3596 | |
| 3597 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3598 | |
| 3599 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3600 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3601 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3602 | &command_buffer[0]); |
| 3603 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3604 | |
| 3605 | m_errorMonitor->VerifyNotFound(); |
| 3606 | } |
| 3607 | |
| 3608 | // This is a positive test. No errors should be generated. |
| 3609 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3610 | |
| 3611 | TEST_DESCRIPTION( |
| 3612 | "Two command buffers, each in a separate QueueSubmit call " |
| 3613 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3614 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3615 | |
| 3616 | m_errorMonitor->ExpectSuccess(); |
| 3617 | |
| 3618 | VkFence fence; |
| 3619 | VkFenceCreateInfo fence_create_info{}; |
| 3620 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3621 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3622 | |
| 3623 | VkCommandPool command_pool; |
| 3624 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3625 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3626 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3627 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3628 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3629 | &command_pool); |
| 3630 | |
| 3631 | VkCommandBuffer command_buffer[2]; |
| 3632 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3633 | command_buffer_allocate_info.sType = |
| 3634 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3635 | command_buffer_allocate_info.commandPool = command_pool; |
| 3636 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3637 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3638 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3639 | command_buffer); |
| 3640 | |
| 3641 | { |
| 3642 | VkCommandBufferBeginInfo begin_info{}; |
| 3643 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3644 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3645 | |
| 3646 | vkCmdPipelineBarrier(command_buffer[0], |
| 3647 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3648 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3649 | 0, nullptr, 0, nullptr); |
| 3650 | |
| 3651 | VkViewport viewport{}; |
| 3652 | viewport.maxDepth = 1.0f; |
| 3653 | viewport.minDepth = 0.0f; |
| 3654 | viewport.width = 512; |
| 3655 | viewport.height = 512; |
| 3656 | viewport.x = 0; |
| 3657 | viewport.y = 0; |
| 3658 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3659 | vkEndCommandBuffer(command_buffer[0]); |
| 3660 | } |
| 3661 | { |
| 3662 | VkCommandBufferBeginInfo begin_info{}; |
| 3663 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3664 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3665 | |
| 3666 | VkViewport viewport{}; |
| 3667 | viewport.maxDepth = 1.0f; |
| 3668 | viewport.minDepth = 0.0f; |
| 3669 | viewport.width = 512; |
| 3670 | viewport.height = 512; |
| 3671 | viewport.x = 0; |
| 3672 | viewport.y = 0; |
| 3673 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3674 | vkEndCommandBuffer(command_buffer[1]); |
| 3675 | } |
| 3676 | { |
| 3677 | VkSubmitInfo submit_info{}; |
| 3678 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3679 | submit_info.commandBufferCount = 1; |
| 3680 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3681 | submit_info.signalSemaphoreCount = 0; |
| 3682 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3683 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3684 | } |
| 3685 | { |
| 3686 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3687 | VkSubmitInfo submit_info{}; |
| 3688 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3689 | submit_info.commandBufferCount = 1; |
| 3690 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3691 | submit_info.waitSemaphoreCount = 0; |
| 3692 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3693 | submit_info.pWaitDstStageMask = flags; |
| 3694 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3695 | } |
| 3696 | |
| 3697 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3698 | |
| 3699 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3700 | |
| 3701 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3702 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3703 | &command_buffer[0]); |
| 3704 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3705 | |
| 3706 | m_errorMonitor->VerifyNotFound(); |
| 3707 | } |
| 3708 | |
| 3709 | // This is a positive test. No errors should be generated. |
| 3710 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3711 | |
| 3712 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3713 | "on the same queue, the second having a fence, followed " |
| 3714 | "by a WaitForFences call."); |
| 3715 | |
| 3716 | m_errorMonitor->ExpectSuccess(); |
| 3717 | |
| 3718 | VkFence fence; |
| 3719 | VkFenceCreateInfo fence_create_info{}; |
| 3720 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3721 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3722 | |
| 3723 | VkCommandPool command_pool; |
| 3724 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3725 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3726 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3727 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3728 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3729 | &command_pool); |
| 3730 | |
| 3731 | VkCommandBuffer command_buffer[2]; |
| 3732 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3733 | command_buffer_allocate_info.sType = |
| 3734 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3735 | command_buffer_allocate_info.commandPool = command_pool; |
| 3736 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3737 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3738 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3739 | command_buffer); |
| 3740 | |
| 3741 | { |
| 3742 | VkCommandBufferBeginInfo begin_info{}; |
| 3743 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3744 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3745 | |
| 3746 | vkCmdPipelineBarrier(command_buffer[0], |
| 3747 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3748 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3749 | 0, nullptr, 0, nullptr); |
| 3750 | |
| 3751 | VkViewport viewport{}; |
| 3752 | viewport.maxDepth = 1.0f; |
| 3753 | viewport.minDepth = 0.0f; |
| 3754 | viewport.width = 512; |
| 3755 | viewport.height = 512; |
| 3756 | viewport.x = 0; |
| 3757 | viewport.y = 0; |
| 3758 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3759 | vkEndCommandBuffer(command_buffer[0]); |
| 3760 | } |
| 3761 | { |
| 3762 | VkCommandBufferBeginInfo begin_info{}; |
| 3763 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3764 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3765 | |
| 3766 | VkViewport viewport{}; |
| 3767 | viewport.maxDepth = 1.0f; |
| 3768 | viewport.minDepth = 0.0f; |
| 3769 | viewport.width = 512; |
| 3770 | viewport.height = 512; |
| 3771 | viewport.x = 0; |
| 3772 | viewport.y = 0; |
| 3773 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3774 | vkEndCommandBuffer(command_buffer[1]); |
| 3775 | } |
| 3776 | { |
| 3777 | VkSubmitInfo submit_info{}; |
| 3778 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3779 | submit_info.commandBufferCount = 1; |
| 3780 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3781 | submit_info.signalSemaphoreCount = 0; |
| 3782 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3783 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3784 | } |
| 3785 | { |
| 3786 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3787 | VkSubmitInfo submit_info{}; |
| 3788 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3789 | submit_info.commandBufferCount = 1; |
| 3790 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3791 | submit_info.waitSemaphoreCount = 0; |
| 3792 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3793 | submit_info.pWaitDstStageMask = flags; |
| 3794 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3795 | } |
| 3796 | |
| 3797 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3798 | |
| 3799 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3800 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3801 | &command_buffer[0]); |
| 3802 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3803 | |
| 3804 | m_errorMonitor->VerifyNotFound(); |
| 3805 | } |
| 3806 | |
| 3807 | // This is a positive test. No errors should be generated. |
| 3808 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3809 | |
| 3810 | TEST_DESCRIPTION( |
| 3811 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3812 | "QueueSubmit call followed by a WaitForFences call."); |
| 3813 | |
| 3814 | m_errorMonitor->ExpectSuccess(); |
| 3815 | |
| 3816 | VkFence fence; |
| 3817 | VkFenceCreateInfo fence_create_info{}; |
| 3818 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3819 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3820 | |
| 3821 | VkSemaphore semaphore; |
| 3822 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3823 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3824 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3825 | &semaphore); |
| 3826 | |
| 3827 | VkCommandPool command_pool; |
| 3828 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3829 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3830 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3831 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3832 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3833 | &command_pool); |
| 3834 | |
| 3835 | VkCommandBuffer command_buffer[2]; |
| 3836 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3837 | command_buffer_allocate_info.sType = |
| 3838 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3839 | command_buffer_allocate_info.commandPool = command_pool; |
| 3840 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3841 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3842 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3843 | command_buffer); |
| 3844 | |
| 3845 | { |
| 3846 | VkCommandBufferBeginInfo begin_info{}; |
| 3847 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3848 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3849 | |
| 3850 | vkCmdPipelineBarrier(command_buffer[0], |
| 3851 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3852 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3853 | 0, nullptr, 0, nullptr); |
| 3854 | |
| 3855 | VkViewport viewport{}; |
| 3856 | viewport.maxDepth = 1.0f; |
| 3857 | viewport.minDepth = 0.0f; |
| 3858 | viewport.width = 512; |
| 3859 | viewport.height = 512; |
| 3860 | viewport.x = 0; |
| 3861 | viewport.y = 0; |
| 3862 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3863 | vkEndCommandBuffer(command_buffer[0]); |
| 3864 | } |
| 3865 | { |
| 3866 | VkCommandBufferBeginInfo begin_info{}; |
| 3867 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3868 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3869 | |
| 3870 | VkViewport viewport{}; |
| 3871 | viewport.maxDepth = 1.0f; |
| 3872 | viewport.minDepth = 0.0f; |
| 3873 | viewport.width = 512; |
| 3874 | viewport.height = 512; |
| 3875 | viewport.x = 0; |
| 3876 | viewport.y = 0; |
| 3877 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3878 | vkEndCommandBuffer(command_buffer[1]); |
| 3879 | } |
| 3880 | { |
| 3881 | VkSubmitInfo submit_info[2]; |
| 3882 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3883 | |
| 3884 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3885 | submit_info[0].pNext = NULL; |
| 3886 | submit_info[0].commandBufferCount = 1; |
| 3887 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3888 | submit_info[0].signalSemaphoreCount = 1; |
| 3889 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3890 | submit_info[0].waitSemaphoreCount = 0; |
| 3891 | submit_info[0].pWaitSemaphores = NULL; |
| 3892 | submit_info[0].pWaitDstStageMask = 0; |
| 3893 | |
| 3894 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3895 | submit_info[1].pNext = NULL; |
| 3896 | submit_info[1].commandBufferCount = 1; |
| 3897 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3898 | submit_info[1].waitSemaphoreCount = 1; |
| 3899 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3900 | submit_info[1].pWaitDstStageMask = flags; |
| 3901 | submit_info[1].signalSemaphoreCount = 0; |
| 3902 | submit_info[1].pSignalSemaphores = NULL; |
| 3903 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3904 | } |
| 3905 | |
| 3906 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3907 | |
| 3908 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3909 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3910 | &command_buffer[0]); |
| 3911 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3912 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3913 | |
| 3914 | m_errorMonitor->VerifyNotFound(); |
| 3915 | } |
| 3916 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3917 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3918 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3919 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 3920 | "state is required but not correctly bound."); |
| 3921 | |
| 3922 | // Dynamic depth bias |
| 3923 | m_errorMonitor->SetDesiredFailureMsg( |
| 3924 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3925 | "Dynamic depth bias state not set for this command buffer"); |
| 3926 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3927 | BsoFailDepthBias); |
| 3928 | m_errorMonitor->VerifyFound(); |
| 3929 | } |
| 3930 | |
| 3931 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 3932 | TEST_DESCRIPTION( |
| 3933 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 3934 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3935 | |
| 3936 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | m_errorMonitor->SetDesiredFailureMsg( |
| 3938 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3939 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3940 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3941 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3942 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3943 | } |
| 3944 | |
| 3945 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 3946 | TEST_DESCRIPTION( |
| 3947 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 3948 | "state is required but not correctly bound."); |
| 3949 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3950 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | m_errorMonitor->SetDesiredFailureMsg( |
| 3952 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3953 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3954 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3955 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3956 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 3960 | TEST_DESCRIPTION( |
| 3961 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 3962 | "state is required but not correctly bound."); |
| 3963 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3964 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3965 | m_errorMonitor->SetDesiredFailureMsg( |
| 3966 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3967 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3968 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3969 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3970 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3971 | } |
| 3972 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3973 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3974 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3975 | "Run a simple draw calls to validate failure when Blend Constants " |
| 3976 | "dynamic state is required but not correctly bound."); |
| 3977 | // Dynamic blend constant state |
| 3978 | m_errorMonitor->SetDesiredFailureMsg( |
| 3979 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3980 | "Dynamic blend constants state not set for this command buffer"); |
| 3981 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3982 | BsoFailBlend); |
| 3983 | m_errorMonitor->VerifyFound(); |
| 3984 | } |
| 3985 | |
| 3986 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 3987 | TEST_DESCRIPTION( |
| 3988 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3989 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3990 | if (!m_device->phy().features().depthBounds) { |
| 3991 | printf("Device does not support depthBounds test; skipped.\n"); |
| 3992 | return; |
| 3993 | } |
| 3994 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3995 | m_errorMonitor->SetDesiredFailureMsg( |
| 3996 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3997 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3999 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4000 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4001 | } |
| 4002 | |
| 4003 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4004 | TEST_DESCRIPTION( |
| 4005 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4006 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4007 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4008 | m_errorMonitor->SetDesiredFailureMsg( |
| 4009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4010 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4011 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4012 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4013 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4014 | } |
| 4015 | |
| 4016 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4017 | TEST_DESCRIPTION( |
| 4018 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4019 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4020 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4021 | m_errorMonitor->SetDesiredFailureMsg( |
| 4022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4023 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4024 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4025 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4026 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4027 | } |
| 4028 | |
| 4029 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4030 | TEST_DESCRIPTION( |
| 4031 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4032 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4033 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | m_errorMonitor->SetDesiredFailureMsg( |
| 4035 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4036 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4037 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4038 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4039 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4040 | } |
| 4041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4042 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4043 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4045 | m_errorMonitor->SetDesiredFailureMsg( |
| 4046 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4047 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4048 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4049 | |
| 4050 | VkFenceCreateInfo fenceInfo = {}; |
| 4051 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4052 | fenceInfo.pNext = NULL; |
| 4053 | fenceInfo.flags = 0; |
| 4054 | |
| 4055 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4056 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4057 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4059 | // We luck out b/c by default the framework creates CB w/ the |
| 4060 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4061 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4062 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4063 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4064 | EndCommandBuffer(); |
| 4065 | |
| 4066 | testFence.init(*m_device, fenceInfo); |
| 4067 | |
| 4068 | // Bypass framework since it does the waits automatically |
| 4069 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4070 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4071 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4072 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4073 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4074 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4075 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4076 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4077 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4078 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4079 | submit_info.pSignalSemaphores = NULL; |
| 4080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4081 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 4082 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4084 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4085 | // submitted once |
| 4086 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4087 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4088 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4089 | } |
| 4090 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4091 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4092 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4093 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4094 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4096 | "Unable to allocate 1 descriptors of " |
| 4097 | "type " |
| 4098 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4099 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4100 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4101 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4103 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4104 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4105 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4106 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4107 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4108 | |
| 4109 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4110 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4111 | ds_pool_ci.pNext = NULL; |
| 4112 | ds_pool_ci.flags = 0; |
| 4113 | ds_pool_ci.maxSets = 1; |
| 4114 | ds_pool_ci.poolSizeCount = 1; |
| 4115 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4116 | |
| 4117 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | err = |
| 4119 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4120 | ASSERT_VK_SUCCESS(err); |
| 4121 | |
| 4122 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4123 | dsl_binding.binding = 0; |
| 4124 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4125 | dsl_binding.descriptorCount = 1; |
| 4126 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4127 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4128 | |
| 4129 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4130 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4131 | ds_layout_ci.pNext = NULL; |
| 4132 | ds_layout_ci.bindingCount = 1; |
| 4133 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4134 | |
| 4135 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4136 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4137 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4138 | ASSERT_VK_SUCCESS(err); |
| 4139 | |
| 4140 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4141 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4142 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4143 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4144 | alloc_info.descriptorPool = ds_pool; |
| 4145 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4146 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4147 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4148 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4149 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4150 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4151 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4152 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4153 | } |
| 4154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4155 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4156 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4158 | m_errorMonitor->SetDesiredFailureMsg( |
| 4159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4160 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4161 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4162 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4163 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4164 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4165 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4166 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4168 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4169 | |
| 4170 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4171 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4172 | ds_pool_ci.pNext = NULL; |
| 4173 | ds_pool_ci.maxSets = 1; |
| 4174 | ds_pool_ci.poolSizeCount = 1; |
| 4175 | ds_pool_ci.flags = 0; |
| 4176 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4177 | // app can only call vkResetDescriptorPool on this pool.; |
| 4178 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4179 | |
| 4180 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4181 | err = |
| 4182 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4183 | ASSERT_VK_SUCCESS(err); |
| 4184 | |
| 4185 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4186 | dsl_binding.binding = 0; |
| 4187 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4188 | dsl_binding.descriptorCount = 1; |
| 4189 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4190 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4191 | |
| 4192 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4194 | ds_layout_ci.pNext = NULL; |
| 4195 | ds_layout_ci.bindingCount = 1; |
| 4196 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4197 | |
| 4198 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4199 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4200 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4201 | ASSERT_VK_SUCCESS(err); |
| 4202 | |
| 4203 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4204 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4205 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4206 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4207 | alloc_info.descriptorPool = ds_pool; |
| 4208 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4209 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4210 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4211 | ASSERT_VK_SUCCESS(err); |
| 4212 | |
| 4213 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4214 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4215 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4216 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4217 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4218 | } |
| 4219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4220 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4221 | // Attempt to clear Descriptor Pool with bad object. |
| 4222 | // ObjectTracker should catch this. |
| 4223 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4224 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4225 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4226 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4227 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4228 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4229 | } |
| 4230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4231 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4232 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4233 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4234 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4235 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4236 | |
| 4237 | uint64_t fake_set_handle = 0xbaad6001; |
| 4238 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4239 | VkResult err; |
| 4240 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4241 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4242 | |
| 4243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4244 | |
| 4245 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4246 | layout_bindings[0].binding = 0; |
| 4247 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4248 | layout_bindings[0].descriptorCount = 1; |
| 4249 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4250 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4251 | |
| 4252 | VkDescriptorSetLayout descriptor_set_layout; |
| 4253 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4254 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4255 | dslci.pNext = NULL; |
| 4256 | dslci.bindingCount = 1; |
| 4257 | dslci.pBindings = layout_bindings; |
| 4258 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4259 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4260 | |
| 4261 | VkPipelineLayout pipeline_layout; |
| 4262 | VkPipelineLayoutCreateInfo plci = {}; |
| 4263 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4264 | plci.pNext = NULL; |
| 4265 | plci.setLayoutCount = 1; |
| 4266 | plci.pSetLayouts = &descriptor_set_layout; |
| 4267 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4268 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4269 | |
| 4270 | BeginCommandBuffer(); |
| 4271 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4272 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4273 | m_errorMonitor->VerifyFound(); |
| 4274 | EndCommandBuffer(); |
| 4275 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4276 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4277 | } |
| 4278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4279 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4280 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4281 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4282 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4283 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4285 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4286 | |
| 4287 | VkPipelineLayout pipeline_layout; |
| 4288 | VkPipelineLayoutCreateInfo plci = {}; |
| 4289 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4290 | plci.pNext = NULL; |
| 4291 | plci.setLayoutCount = 1; |
| 4292 | plci.pSetLayouts = &bad_layout; |
| 4293 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4294 | |
| 4295 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4296 | } |
| 4297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4298 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4299 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4300 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4301 | // Create a valid cmd buffer |
| 4302 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4303 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4304 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4305 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4306 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4307 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4308 | BeginCommandBuffer(); |
| 4309 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4310 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4311 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4312 | // Now issue a draw call with no pipeline bound |
| 4313 | m_errorMonitor->SetDesiredFailureMsg( |
| 4314 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4315 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4316 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4317 | BeginCommandBuffer(); |
| 4318 | Draw(1, 0, 0, 0); |
| 4319 | m_errorMonitor->VerifyFound(); |
| 4320 | // Finally same check once more but with Dispatch/Compute |
| 4321 | m_errorMonitor->SetDesiredFailureMsg( |
| 4322 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4323 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4324 | BeginCommandBuffer(); |
| 4325 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4326 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4327 | } |
| 4328 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4329 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4330 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4331 | // CommandBuffer |
| 4332 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4333 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4334 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4335 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4336 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4337 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4338 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4340 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4341 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4342 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4343 | |
| 4344 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4345 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4346 | ds_pool_ci.pNext = NULL; |
| 4347 | ds_pool_ci.maxSets = 1; |
| 4348 | ds_pool_ci.poolSizeCount = 1; |
| 4349 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4350 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4351 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4352 | err = |
| 4353 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4354 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4355 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4356 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4357 | dsl_binding.binding = 0; |
| 4358 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4359 | dsl_binding.descriptorCount = 1; |
| 4360 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4361 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4362 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4363 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4364 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4365 | ds_layout_ci.pNext = NULL; |
| 4366 | ds_layout_ci.bindingCount = 1; |
| 4367 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4368 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4369 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4370 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4371 | ASSERT_VK_SUCCESS(err); |
| 4372 | |
| 4373 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4374 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4375 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4376 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4377 | alloc_info.descriptorPool = ds_pool; |
| 4378 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4379 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4380 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4381 | ASSERT_VK_SUCCESS(err); |
| 4382 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4383 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4384 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4385 | pipeline_layout_ci.pNext = NULL; |
| 4386 | pipeline_layout_ci.setLayoutCount = 1; |
| 4387 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4388 | |
| 4389 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4391 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4392 | ASSERT_VK_SUCCESS(err); |
| 4393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4394 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4395 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4396 | // 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] | 4397 | // on more devices |
| 4398 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4399 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4400 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4401 | VkPipelineObj pipe(m_device); |
| 4402 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4403 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4404 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4405 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4406 | |
| 4407 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4408 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4409 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4410 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4411 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4412 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4413 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4414 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4415 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4416 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4417 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4418 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4419 | } |
| 4420 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4422 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4423 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4425 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4426 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4427 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4428 | |
| 4429 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4430 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4432 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4433 | |
| 4434 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4436 | ds_pool_ci.pNext = NULL; |
| 4437 | ds_pool_ci.maxSets = 1; |
| 4438 | ds_pool_ci.poolSizeCount = 1; |
| 4439 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4440 | |
| 4441 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4442 | err = |
| 4443 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4444 | ASSERT_VK_SUCCESS(err); |
| 4445 | |
| 4446 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4447 | dsl_binding.binding = 0; |
| 4448 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4449 | dsl_binding.descriptorCount = 1; |
| 4450 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4451 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4452 | |
| 4453 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4454 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4455 | ds_layout_ci.pNext = NULL; |
| 4456 | ds_layout_ci.bindingCount = 1; |
| 4457 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4458 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4460 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4461 | ASSERT_VK_SUCCESS(err); |
| 4462 | |
| 4463 | VkDescriptorSet descriptorSet; |
| 4464 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4465 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4466 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4467 | alloc_info.descriptorPool = ds_pool; |
| 4468 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4469 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4470 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4471 | ASSERT_VK_SUCCESS(err); |
| 4472 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4473 | VkBufferView view = |
| 4474 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4475 | VkWriteDescriptorSet descriptor_write; |
| 4476 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4477 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4478 | descriptor_write.dstSet = descriptorSet; |
| 4479 | descriptor_write.dstBinding = 0; |
| 4480 | descriptor_write.descriptorCount = 1; |
| 4481 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4482 | descriptor_write.pTexelBufferView = &view; |
| 4483 | |
| 4484 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4485 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4486 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4487 | |
| 4488 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4489 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4490 | } |
| 4491 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4492 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4493 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4494 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4495 | // 1. No dynamicOffset supplied |
| 4496 | // 2. Too many dynamicOffsets supplied |
| 4497 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4498 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4499 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4500 | " requires 1 dynamicOffsets, but only " |
| 4501 | "0 dynamicOffsets are left in " |
| 4502 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4503 | |
| 4504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4505 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4506 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4507 | |
| 4508 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4510 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4511 | |
| 4512 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4513 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4514 | ds_pool_ci.pNext = NULL; |
| 4515 | ds_pool_ci.maxSets = 1; |
| 4516 | ds_pool_ci.poolSizeCount = 1; |
| 4517 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4518 | |
| 4519 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4520 | err = |
| 4521 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4522 | ASSERT_VK_SUCCESS(err); |
| 4523 | |
| 4524 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4525 | dsl_binding.binding = 0; |
| 4526 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4527 | dsl_binding.descriptorCount = 1; |
| 4528 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4529 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4530 | |
| 4531 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4532 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4533 | ds_layout_ci.pNext = NULL; |
| 4534 | ds_layout_ci.bindingCount = 1; |
| 4535 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4536 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4537 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4538 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4539 | ASSERT_VK_SUCCESS(err); |
| 4540 | |
| 4541 | VkDescriptorSet descriptorSet; |
| 4542 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4543 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4544 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4545 | alloc_info.descriptorPool = ds_pool; |
| 4546 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4547 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4548 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4549 | ASSERT_VK_SUCCESS(err); |
| 4550 | |
| 4551 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4552 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4553 | pipeline_layout_ci.pNext = NULL; |
| 4554 | pipeline_layout_ci.setLayoutCount = 1; |
| 4555 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4556 | |
| 4557 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4558 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4559 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4560 | ASSERT_VK_SUCCESS(err); |
| 4561 | |
| 4562 | // Create a buffer to update the descriptor with |
| 4563 | uint32_t qfi = 0; |
| 4564 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4565 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4566 | buffCI.size = 1024; |
| 4567 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4568 | buffCI.queueFamilyIndexCount = 1; |
| 4569 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4570 | |
| 4571 | VkBuffer dyub; |
| 4572 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4573 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4574 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4575 | // error |
| 4576 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4577 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4578 | mem_alloc.pNext = NULL; |
| 4579 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4580 | mem_alloc.memoryTypeIndex = 0; |
| 4581 | |
| 4582 | VkMemoryRequirements memReqs; |
| 4583 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4584 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4585 | 0); |
| 4586 | if (!pass) { |
| 4587 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4588 | return; |
| 4589 | } |
| 4590 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4591 | VkDeviceMemory mem; |
| 4592 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4593 | ASSERT_VK_SUCCESS(err); |
| 4594 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4595 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4596 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4597 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4598 | buffInfo.buffer = dyub; |
| 4599 | buffInfo.offset = 0; |
| 4600 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4601 | |
| 4602 | VkWriteDescriptorSet descriptor_write; |
| 4603 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4604 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4605 | descriptor_write.dstSet = descriptorSet; |
| 4606 | descriptor_write.dstBinding = 0; |
| 4607 | descriptor_write.descriptorCount = 1; |
| 4608 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4609 | descriptor_write.pBufferInfo = &buffInfo; |
| 4610 | |
| 4611 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4612 | |
| 4613 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4614 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4615 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4616 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4617 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4618 | uint32_t pDynOff[2] = {512, 756}; |
| 4619 | // 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] | 4620 | m_errorMonitor->SetDesiredFailureMsg( |
| 4621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4622 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4623 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4624 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4625 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4626 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4627 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4628 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4629 | " dynamic offset 512 combined with " |
| 4630 | "offset 0 and range 1024 that " |
| 4631 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4632 | // Create PSO to be used for draw-time errors below |
| 4633 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4634 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4635 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4636 | "out gl_PerVertex { \n" |
| 4637 | " vec4 gl_Position;\n" |
| 4638 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4639 | "void main(){\n" |
| 4640 | " gl_Position = vec4(1);\n" |
| 4641 | "}\n"; |
| 4642 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4643 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4644 | "\n" |
| 4645 | "layout(location=0) out vec4 x;\n" |
| 4646 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4647 | "void main(){\n" |
| 4648 | " x = vec4(bar.y);\n" |
| 4649 | "}\n"; |
| 4650 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4651 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4652 | VkPipelineObj pipe(m_device); |
| 4653 | pipe.AddShader(&vs); |
| 4654 | pipe.AddShader(&fs); |
| 4655 | pipe.AddColorAttachment(); |
| 4656 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4657 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4658 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4659 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4660 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4661 | // /w range 1024 & size 1024 |
| 4662 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4663 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4664 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4665 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4666 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4667 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4668 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4669 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4670 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4671 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4672 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4673 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4674 | } |
| 4675 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4676 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4677 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4678 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4679 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4680 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4681 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4682 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4683 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4684 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4685 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4686 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4687 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4688 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4689 | // |
| 4690 | // Check for invalid push constant ranges in pipeline layouts. |
| 4691 | // |
| 4692 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4693 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4694 | char const *msg; |
| 4695 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4696 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4697 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4698 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4699 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4700 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4701 | "size 0."}, |
| 4702 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4703 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4704 | "size 1."}, |
| 4705 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4706 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4707 | "size 1."}, |
| 4708 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4709 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4710 | "size 0."}, |
| 4711 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4712 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4713 | "offset 1. Offset must"}, |
| 4714 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4715 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4716 | "with offset "}, |
| 4717 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4718 | "vkCreatePipelineLayout() call has push constants " |
| 4719 | "index 0 with offset "}, |
| 4720 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4721 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4722 | "with offset "}, |
| 4723 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4724 | "vkCreatePipelineLayout() call has push " |
| 4725 | "constants index 0 with offset "}, |
| 4726 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4727 | "vkCreatePipelineLayout() call has push " |
| 4728 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4729 | }}; |
| 4730 | |
| 4731 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4732 | for (const auto &iter : range_tests) { |
| 4733 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4734 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4735 | iter.msg); |
| 4736 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4737 | NULL, &pipeline_layout); |
| 4738 | m_errorMonitor->VerifyFound(); |
| 4739 | if (VK_SUCCESS == err) { |
| 4740 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4741 | } |
| 4742 | } |
| 4743 | |
| 4744 | // Check for invalid stage flag |
| 4745 | pc_range.offset = 0; |
| 4746 | pc_range.size = 16; |
| 4747 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4748 | m_errorMonitor->SetDesiredFailureMsg( |
| 4749 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4750 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4751 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4752 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4753 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4754 | if (VK_SUCCESS == err) { |
| 4755 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4756 | } |
| 4757 | |
| 4758 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4759 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4760 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4761 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4762 | char const *msg; |
| 4763 | }; |
| 4764 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4765 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4766 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4767 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4768 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4769 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4770 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4771 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4772 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4773 | { |
| 4774 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4775 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4776 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4777 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4778 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4779 | "vkCreatePipelineLayout() call has push constants with " |
| 4780 | "overlapping " |
| 4781 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4782 | }, |
| 4783 | { |
| 4784 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4785 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4786 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4787 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4788 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4789 | "vkCreatePipelineLayout() call has push constants with " |
| 4790 | "overlapping " |
| 4791 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4792 | }, |
| 4793 | { |
| 4794 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4795 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4796 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4797 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4798 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4799 | "vkCreatePipelineLayout() call has push constants with " |
| 4800 | "overlapping " |
| 4801 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4802 | }, |
| 4803 | { |
| 4804 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4805 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4806 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4807 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4808 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4809 | "vkCreatePipelineLayout() call has push constants with " |
| 4810 | "overlapping " |
| 4811 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4812 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4813 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4814 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4815 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4816 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4817 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4818 | iter.msg); |
| 4819 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4820 | NULL, &pipeline_layout); |
| 4821 | m_errorMonitor->VerifyFound(); |
| 4822 | if (VK_SUCCESS == err) { |
| 4823 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4824 | } |
| 4825 | } |
| 4826 | |
| 4827 | // Run some positive tests to make sure overlap checking in the layer is OK |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4828 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4829 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4830 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4831 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4832 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4833 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4834 | ""}, |
| 4835 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4836 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4837 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4838 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4839 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4840 | ""}}}; |
| 4841 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4842 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4843 | m_errorMonitor->ExpectSuccess(); |
| 4844 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4845 | NULL, &pipeline_layout); |
| 4846 | m_errorMonitor->VerifyNotFound(); |
| 4847 | if (VK_SUCCESS == err) { |
| 4848 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4849 | } |
| 4850 | } |
| 4851 | |
| 4852 | // |
| 4853 | // CmdPushConstants tests |
| 4854 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4855 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4856 | |
| 4857 | // Check for invalid offset and size and if range is within layout range(s) |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4858 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4859 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4860 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4861 | "must be greater than zero and a multiple of 4."}, |
| 4862 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4863 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4864 | "must be greater than zero and a multiple of 4."}, |
| 4865 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4866 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4867 | "must be greater than zero and a multiple of 4."}, |
| 4868 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4869 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4870 | "Offset must be a multiple of 4."}, |
| 4871 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4872 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4873 | "Offset must be a multiple of 4."}, |
| 4874 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4875 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4876 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4877 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4878 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4879 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4880 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4881 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4882 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4883 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4884 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4885 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4886 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4887 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4888 | "any of the ranges in pipeline layout"}, |
| 4889 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4890 | 0, 16}, |
| 4891 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4892 | "any of the ranges in pipeline layout"}, |
| 4893 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4894 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4895 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4896 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4897 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4898 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4899 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4900 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4901 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4902 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4903 | }}; |
| 4904 | |
| 4905 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4906 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4907 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4908 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4909 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4910 | pipeline_layout_ci.pushConstantRangeCount = |
| 4911 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4912 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4913 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4914 | &pipeline_layout); |
| 4915 | ASSERT_VK_SUCCESS(err); |
| 4916 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4917 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4919 | iter.msg); |
| 4920 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4921 | iter.range.stageFlags, iter.range.offset, |
| 4922 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4923 | m_errorMonitor->VerifyFound(); |
| 4924 | } |
| 4925 | |
| 4926 | // Check for invalid stage flag |
| 4927 | m_errorMonitor->SetDesiredFailureMsg( |
| 4928 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4929 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4930 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4931 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4932 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4933 | EndCommandBuffer(); |
| 4934 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4935 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4936 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4937 | // overlapping range tests with cmd |
| 4938 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4939 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4940 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4941 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4942 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4943 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4944 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4945 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4946 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4947 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4948 | }}; |
| 4949 | const VkPushConstantRange pc_range3[] = { |
| 4950 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4951 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4952 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4953 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4954 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4955 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4956 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4957 | }; |
| 4958 | pipeline_layout_ci.pushConstantRangeCount = |
| 4959 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4960 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4961 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4962 | &pipeline_layout); |
| 4963 | ASSERT_VK_SUCCESS(err); |
| 4964 | BeginCommandBuffer(); |
| 4965 | for (const auto &iter : cmd_overlap_tests) { |
| 4966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4967 | iter.msg); |
| 4968 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4969 | iter.range.stageFlags, iter.range.offset, |
| 4970 | iter.range.size, dummy_values); |
| 4971 | m_errorMonitor->VerifyFound(); |
| 4972 | } |
| 4973 | EndCommandBuffer(); |
| 4974 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4975 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4976 | |
| 4977 | // positive overlapping range tests with cmd |
| 4978 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4979 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4980 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4981 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4982 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4983 | }}; |
| 4984 | const VkPushConstantRange pc_range4[] = { |
| 4985 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4986 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4987 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4988 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4989 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4990 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4991 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4992 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4993 | }; |
| 4994 | pipeline_layout_ci.pushConstantRangeCount = |
| 4995 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4996 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4997 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4998 | &pipeline_layout); |
| 4999 | ASSERT_VK_SUCCESS(err); |
| 5000 | BeginCommandBuffer(); |
| 5001 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5002 | m_errorMonitor->ExpectSuccess(); |
| 5003 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5004 | iter.range.stageFlags, iter.range.offset, |
| 5005 | iter.range.size, dummy_values); |
| 5006 | m_errorMonitor->VerifyNotFound(); |
| 5007 | } |
| 5008 | EndCommandBuffer(); |
| 5009 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5010 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5011 | } |
| 5012 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5013 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5014 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5015 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5016 | |
| 5017 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5018 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5019 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5020 | |
| 5021 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5022 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5023 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5024 | ds_type_count[0].descriptorCount = 10; |
| 5025 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5026 | ds_type_count[1].descriptorCount = 2; |
| 5027 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5028 | ds_type_count[2].descriptorCount = 2; |
| 5029 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5030 | ds_type_count[3].descriptorCount = 5; |
| 5031 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5032 | // type |
| 5033 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5034 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5035 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5036 | |
| 5037 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5038 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5039 | ds_pool_ci.pNext = NULL; |
| 5040 | ds_pool_ci.maxSets = 5; |
| 5041 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5042 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5043 | |
| 5044 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5045 | err = |
| 5046 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5047 | ASSERT_VK_SUCCESS(err); |
| 5048 | |
| 5049 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5050 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5051 | dsl_binding[0].binding = 0; |
| 5052 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5053 | dsl_binding[0].descriptorCount = 5; |
| 5054 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5055 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5056 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5057 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5058 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5059 | dsl_fs_stage_only.binding = 0; |
| 5060 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5061 | dsl_fs_stage_only.descriptorCount = 5; |
| 5062 | dsl_fs_stage_only.stageFlags = |
| 5063 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5064 | // bind time |
| 5065 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5066 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5067 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5068 | ds_layout_ci.pNext = NULL; |
| 5069 | ds_layout_ci.bindingCount = 1; |
| 5070 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5071 | static const uint32_t NUM_LAYOUTS = 4; |
| 5072 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5073 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5074 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5075 | // layout for error case |
| 5076 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5077 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5078 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5079 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5080 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5081 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5082 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5083 | dsl_binding[0].binding = 0; |
| 5084 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5085 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5086 | dsl_binding[1].binding = 1; |
| 5087 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5088 | dsl_binding[1].descriptorCount = 2; |
| 5089 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5090 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5091 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5092 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5093 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5094 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5095 | ASSERT_VK_SUCCESS(err); |
| 5096 | dsl_binding[0].binding = 0; |
| 5097 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5098 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5099 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5101 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5104 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5105 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5106 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5107 | ASSERT_VK_SUCCESS(err); |
| 5108 | |
| 5109 | static const uint32_t NUM_SETS = 4; |
| 5110 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5111 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5112 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5113 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5114 | alloc_info.descriptorPool = ds_pool; |
| 5115 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5116 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5117 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5118 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5119 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5120 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5121 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5122 | err = |
| 5123 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5124 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5125 | |
| 5126 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5127 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5128 | pipeline_layout_ci.pNext = NULL; |
| 5129 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5130 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5131 | |
| 5132 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5133 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5134 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5135 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5136 | // Create pipelineLayout with only one setLayout |
| 5137 | pipeline_layout_ci.setLayoutCount = 1; |
| 5138 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5139 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5140 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5141 | ASSERT_VK_SUCCESS(err); |
| 5142 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5143 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5144 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5145 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5146 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5147 | ASSERT_VK_SUCCESS(err); |
| 5148 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5149 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5150 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5151 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5152 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5153 | ASSERT_VK_SUCCESS(err); |
| 5154 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5155 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5156 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5157 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5158 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5159 | ASSERT_VK_SUCCESS(err); |
| 5160 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5161 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5162 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5163 | pl_bad_s0[1] = ds_layout[1]; |
| 5164 | pipeline_layout_ci.setLayoutCount = 2; |
| 5165 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5166 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5167 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5168 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5169 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5170 | |
| 5171 | // Create a buffer to update the descriptor with |
| 5172 | uint32_t qfi = 0; |
| 5173 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5174 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5175 | buffCI.size = 1024; |
| 5176 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5177 | buffCI.queueFamilyIndexCount = 1; |
| 5178 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5179 | |
| 5180 | VkBuffer dyub; |
| 5181 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5182 | ASSERT_VK_SUCCESS(err); |
| 5183 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5184 | static const uint32_t NUM_BUFFS = 5; |
| 5185 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5186 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5187 | buffInfo[i].buffer = dyub; |
| 5188 | buffInfo[i].offset = 0; |
| 5189 | buffInfo[i].range = 1024; |
| 5190 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5191 | VkImage image; |
| 5192 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5193 | const int32_t tex_width = 32; |
| 5194 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5195 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5196 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5197 | image_create_info.pNext = NULL; |
| 5198 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5199 | image_create_info.format = tex_format; |
| 5200 | image_create_info.extent.width = tex_width; |
| 5201 | image_create_info.extent.height = tex_height; |
| 5202 | image_create_info.extent.depth = 1; |
| 5203 | image_create_info.mipLevels = 1; |
| 5204 | image_create_info.arrayLayers = 1; |
| 5205 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5206 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5207 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5208 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5209 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5210 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5211 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5212 | VkMemoryRequirements memReqs; |
| 5213 | VkDeviceMemory imageMem; |
| 5214 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5215 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5216 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5217 | memAlloc.pNext = NULL; |
| 5218 | memAlloc.allocationSize = 0; |
| 5219 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5220 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5221 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5222 | pass = |
| 5223 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5224 | ASSERT_TRUE(pass); |
| 5225 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5226 | ASSERT_VK_SUCCESS(err); |
| 5227 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5228 | ASSERT_VK_SUCCESS(err); |
| 5229 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5230 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5231 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5232 | image_view_create_info.image = image; |
| 5233 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5234 | image_view_create_info.format = tex_format; |
| 5235 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5236 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5237 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5238 | image_view_create_info.subresourceRange.aspectMask = |
| 5239 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5240 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5241 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5242 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5243 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5244 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5245 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5246 | imageInfo[0].imageView = view; |
| 5247 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5248 | imageInfo[1].imageView = view; |
| 5249 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5250 | imageInfo[2].imageView = view; |
| 5251 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5252 | imageInfo[3].imageView = view; |
| 5253 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5254 | |
| 5255 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5256 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5257 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5258 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5259 | descriptor_write[0].dstBinding = 0; |
| 5260 | descriptor_write[0].descriptorCount = 5; |
| 5261 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5262 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5263 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5264 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5265 | descriptor_write[1].dstBinding = 0; |
| 5266 | descriptor_write[1].descriptorCount = 2; |
| 5267 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5268 | descriptor_write[1].pImageInfo = imageInfo; |
| 5269 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5270 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5271 | descriptor_write[2].dstBinding = 1; |
| 5272 | descriptor_write[2].descriptorCount = 2; |
| 5273 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5274 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5275 | |
| 5276 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5277 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5278 | // Create PSO to be used for draw-time errors below |
| 5279 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5280 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5281 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5282 | "out gl_PerVertex {\n" |
| 5283 | " vec4 gl_Position;\n" |
| 5284 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5285 | "void main(){\n" |
| 5286 | " gl_Position = vec4(1);\n" |
| 5287 | "}\n"; |
| 5288 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5289 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5290 | "\n" |
| 5291 | "layout(location=0) out vec4 x;\n" |
| 5292 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5293 | "void main(){\n" |
| 5294 | " x = vec4(bar.y);\n" |
| 5295 | "}\n"; |
| 5296 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5297 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5298 | VkPipelineObj pipe(m_device); |
| 5299 | pipe.AddShader(&vs); |
| 5300 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5301 | pipe.AddColorAttachment(); |
| 5302 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5303 | |
| 5304 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5306 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5307 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5308 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5309 | // of PSO |
| 5310 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5311 | // cmd_pipeline.c |
| 5312 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5313 | // cmd_bind_graphics_pipeline() |
| 5314 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5315 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5316 | // First cause various verify_layout_compatibility() fails |
| 5317 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5318 | // verify_set_layout_compatibility fail cases: |
| 5319 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5320 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5321 | " due to: invalid VkPipelineLayout "); |
| 5322 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5323 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5324 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5325 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5326 | m_errorMonitor->VerifyFound(); |
| 5327 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5328 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5329 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5330 | " attempting to bind set to index 1"); |
| 5331 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5332 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5333 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5334 | m_errorMonitor->VerifyFound(); |
| 5335 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5336 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5337 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5338 | // descriptors |
| 5339 | m_errorMonitor->SetDesiredFailureMsg( |
| 5340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5341 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5342 | vkCmdBindDescriptorSets( |
| 5343 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5344 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5345 | m_errorMonitor->VerifyFound(); |
| 5346 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5347 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5348 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5349 | m_errorMonitor->SetDesiredFailureMsg( |
| 5350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5351 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5352 | vkCmdBindDescriptorSets( |
| 5353 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5354 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5355 | m_errorMonitor->VerifyFound(); |
| 5356 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5357 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5358 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5359 | m_errorMonitor->SetDesiredFailureMsg( |
| 5360 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5361 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5362 | vkCmdBindDescriptorSets( |
| 5363 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5364 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5365 | m_errorMonitor->VerifyFound(); |
| 5366 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5367 | // Cause INFO messages due to disturbing previously bound Sets |
| 5368 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5369 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5370 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5371 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5372 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5373 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5374 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5375 | " previously bound as set #0 was disturbed "); |
| 5376 | vkCmdBindDescriptorSets( |
| 5377 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5378 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5379 | m_errorMonitor->VerifyFound(); |
| 5380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5382 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5383 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5384 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5385 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5386 | " newly bound as set #0 so set #1 and " |
| 5387 | "any subsequent sets were disturbed "); |
| 5388 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5389 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5390 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5391 | m_errorMonitor->VerifyFound(); |
| 5392 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5393 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5394 | // 1. Error due to not binding required set (we actually use same code as |
| 5395 | // above to disturb set0) |
| 5396 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5397 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5398 | 2, &descriptorSet[0], 0, NULL); |
| 5399 | vkCmdBindDescriptorSets( |
| 5400 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5401 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5402 | m_errorMonitor->SetDesiredFailureMsg( |
| 5403 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5404 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5405 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5406 | m_errorMonitor->VerifyFound(); |
| 5407 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5408 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5409 | // 2. Error due to bound set not being compatible with PSO's |
| 5410 | // VkPipelineLayout (diff stageFlags in this case) |
| 5411 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5412 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5413 | 2, &descriptorSet[0], 0, NULL); |
| 5414 | m_errorMonitor->SetDesiredFailureMsg( |
| 5415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5416 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5417 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5418 | m_errorMonitor->VerifyFound(); |
| 5419 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5420 | // Remaining clean-up |
| 5421 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5422 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5423 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5424 | } |
| 5425 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5426 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5427 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5428 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5429 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5430 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5431 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 5432 | vkDestroyImage(m_device->device(), image, NULL); |
| 5433 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5434 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5436 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5438 | m_errorMonitor->SetDesiredFailureMsg( |
| 5439 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5440 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5441 | |
| 5442 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5443 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5444 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5445 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5446 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5447 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5448 | } |
| 5449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5450 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5451 | VkResult err; |
| 5452 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5453 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5454 | m_errorMonitor->SetDesiredFailureMsg( |
| 5455 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5456 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5457 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5458 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5459 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5460 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5461 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5462 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5463 | cmd.commandPool = m_commandPool; |
| 5464 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5465 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5466 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5467 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5468 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5469 | |
| 5470 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5471 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5472 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5473 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5474 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5475 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5476 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5477 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5478 | |
| 5479 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5480 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5481 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5482 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5483 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5484 | } |
| 5485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5486 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5487 | // Cause error due to Begin while recording CB |
| 5488 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5489 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5490 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5492 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5493 | |
| 5494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5495 | |
| 5496 | // Calls AllocateCommandBuffers |
| 5497 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5499 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5500 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5501 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5502 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5503 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5504 | cmd_buf_info.pNext = NULL; |
| 5505 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5506 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5507 | |
| 5508 | // Begin CB to transition to recording state |
| 5509 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5510 | // Can't re-begin. This should trigger error |
| 5511 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5512 | m_errorMonitor->VerifyFound(); |
| 5513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5515 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5516 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5517 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5518 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5519 | m_errorMonitor->VerifyFound(); |
| 5520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5521 | m_errorMonitor->SetDesiredFailureMsg( |
| 5522 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5523 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5524 | // Transition CB to RECORDED state |
| 5525 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5526 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5527 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5528 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5529 | } |
| 5530 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5531 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5532 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5533 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5535 | m_errorMonitor->SetDesiredFailureMsg( |
| 5536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5537 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5538 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5539 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5540 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5541 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5542 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5543 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5544 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5545 | |
| 5546 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5547 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5548 | ds_pool_ci.pNext = NULL; |
| 5549 | ds_pool_ci.maxSets = 1; |
| 5550 | ds_pool_ci.poolSizeCount = 1; |
| 5551 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5552 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5553 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5554 | err = |
| 5555 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5556 | ASSERT_VK_SUCCESS(err); |
| 5557 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5558 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5559 | dsl_binding.binding = 0; |
| 5560 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5561 | dsl_binding.descriptorCount = 1; |
| 5562 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5563 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5564 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5565 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5566 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5567 | ds_layout_ci.pNext = NULL; |
| 5568 | ds_layout_ci.bindingCount = 1; |
| 5569 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5570 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5571 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5572 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5573 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5574 | ASSERT_VK_SUCCESS(err); |
| 5575 | |
| 5576 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5577 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5578 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5579 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5580 | alloc_info.descriptorPool = ds_pool; |
| 5581 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5582 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5583 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5584 | ASSERT_VK_SUCCESS(err); |
| 5585 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5586 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5587 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5588 | pipeline_layout_ci.setLayoutCount = 1; |
| 5589 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5590 | |
| 5591 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5592 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5593 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5594 | ASSERT_VK_SUCCESS(err); |
| 5595 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5596 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5597 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5598 | |
| 5599 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5601 | vp_state_ci.scissorCount = 1; |
| 5602 | vp_state_ci.pScissors = ≻ |
| 5603 | vp_state_ci.viewportCount = 1; |
| 5604 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5605 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5606 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5607 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5608 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5609 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5610 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5611 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5612 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5613 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5614 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5615 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5616 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5617 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5618 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5619 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5620 | gp_ci.layout = pipeline_layout; |
| 5621 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5622 | |
| 5623 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5624 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5625 | pc_ci.initialDataSize = 0; |
| 5626 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5627 | |
| 5628 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5629 | VkPipelineCache pipelineCache; |
| 5630 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5631 | err = |
| 5632 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5633 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5635 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5636 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5637 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5638 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5639 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5640 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5641 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5642 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5643 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5644 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5645 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5646 | { |
| 5647 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5648 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5649 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5651 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5652 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5653 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5655 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5656 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5657 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5658 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5659 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5660 | |
| 5661 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5662 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5663 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5664 | ds_pool_ci.poolSizeCount = 1; |
| 5665 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5666 | |
| 5667 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5668 | err = vkCreateDescriptorPool(m_device->device(), |
| 5669 | 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] | 5670 | ASSERT_VK_SUCCESS(err); |
| 5671 | |
| 5672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5673 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5675 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5677 | dsl_binding.pImmutableSamplers = NULL; |
| 5678 | |
| 5679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5680 | ds_layout_ci.sType = |
| 5681 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5682 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5683 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5684 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5685 | |
| 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 | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5689 | ASSERT_VK_SUCCESS(err); |
| 5690 | |
| 5691 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5692 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5693 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5694 | ASSERT_VK_SUCCESS(err); |
| 5695 | |
| 5696 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5697 | pipeline_layout_ci.sType = |
| 5698 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5699 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5700 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5701 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5702 | |
| 5703 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5704 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5705 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5706 | ASSERT_VK_SUCCESS(err); |
| 5707 | |
| 5708 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5709 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5710 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5711 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5712 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5713 | // 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] | 5714 | VkShaderObj |
| 5715 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5716 | this); |
| 5717 | VkShaderObj |
| 5718 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5719 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5720 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5721 | shaderStages[0].sType = |
| 5722 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5723 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5724 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5725 | shaderStages[1].sType = |
| 5726 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5727 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5728 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5729 | shaderStages[2].sType = |
| 5730 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5731 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5732 | shaderStages[2].shader = te.handle(); |
| 5733 | |
| 5734 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | iaCI.sType = |
| 5736 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5737 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5738 | |
| 5739 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5740 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5741 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5742 | |
| 5743 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5744 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5745 | gp_ci.pNext = NULL; |
| 5746 | gp_ci.stageCount = 3; |
| 5747 | gp_ci.pStages = shaderStages; |
| 5748 | gp_ci.pVertexInputState = NULL; |
| 5749 | gp_ci.pInputAssemblyState = &iaCI; |
| 5750 | gp_ci.pTessellationState = &tsCI; |
| 5751 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5752 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5753 | gp_ci.pMultisampleState = NULL; |
| 5754 | gp_ci.pDepthStencilState = NULL; |
| 5755 | gp_ci.pColorBlendState = NULL; |
| 5756 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5757 | gp_ci.layout = pipeline_layout; |
| 5758 | gp_ci.renderPass = renderPass(); |
| 5759 | |
| 5760 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5761 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5762 | pc_ci.pNext = NULL; |
| 5763 | pc_ci.initialSize = 0; |
| 5764 | pc_ci.initialData = 0; |
| 5765 | pc_ci.maxSize = 0; |
| 5766 | |
| 5767 | VkPipeline pipeline; |
| 5768 | VkPipelineCache pipelineCache; |
| 5769 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5770 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5771 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5772 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5773 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5774 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5775 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5776 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5777 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5778 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5779 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5780 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5781 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5782 | } |
| 5783 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5784 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5785 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5786 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5787 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5788 | m_errorMonitor->SetDesiredFailureMsg( |
| 5789 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5790 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5791 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5792 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5793 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5794 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5795 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5796 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5797 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5798 | |
| 5799 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5800 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5801 | ds_pool_ci.maxSets = 1; |
| 5802 | ds_pool_ci.poolSizeCount = 1; |
| 5803 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5804 | |
| 5805 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5806 | err = |
| 5807 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5808 | ASSERT_VK_SUCCESS(err); |
| 5809 | |
| 5810 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5811 | dsl_binding.binding = 0; |
| 5812 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5813 | dsl_binding.descriptorCount = 1; |
| 5814 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5815 | |
| 5816 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5817 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5818 | ds_layout_ci.bindingCount = 1; |
| 5819 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5820 | |
| 5821 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5822 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5823 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5824 | ASSERT_VK_SUCCESS(err); |
| 5825 | |
| 5826 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5827 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5828 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5829 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5830 | alloc_info.descriptorPool = ds_pool; |
| 5831 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5832 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5833 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5834 | ASSERT_VK_SUCCESS(err); |
| 5835 | |
| 5836 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5838 | pipeline_layout_ci.setLayoutCount = 1; |
| 5839 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5840 | |
| 5841 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5842 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5843 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5844 | ASSERT_VK_SUCCESS(err); |
| 5845 | |
| 5846 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5847 | |
| 5848 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5849 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5850 | vp_state_ci.scissorCount = 0; |
| 5851 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5852 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5853 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5854 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5855 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5856 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5857 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5858 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5859 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5860 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5861 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5862 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5863 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5864 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5866 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5867 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5868 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5869 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5870 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5871 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5872 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5873 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5874 | |
| 5875 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5876 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5877 | gp_ci.stageCount = 2; |
| 5878 | gp_ci.pStages = shaderStages; |
| 5879 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5880 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5881 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5882 | gp_ci.layout = pipeline_layout; |
| 5883 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5884 | |
| 5885 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5886 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5887 | |
| 5888 | VkPipeline pipeline; |
| 5889 | VkPipelineCache pipelineCache; |
| 5890 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5891 | err = |
| 5892 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5893 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5894 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5895 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5896 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5897 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5898 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5899 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5900 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5901 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5902 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5903 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5904 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5905 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5906 | // 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] | 5907 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5908 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5909 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5911 | m_errorMonitor->SetDesiredFailureMsg( |
| 5912 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5913 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5914 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5915 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5916 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5917 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5918 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5919 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5920 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5921 | |
| 5922 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5923 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5924 | ds_pool_ci.maxSets = 1; |
| 5925 | ds_pool_ci.poolSizeCount = 1; |
| 5926 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5927 | |
| 5928 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5929 | err = |
| 5930 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5931 | ASSERT_VK_SUCCESS(err); |
| 5932 | |
| 5933 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5934 | dsl_binding.binding = 0; |
| 5935 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5936 | dsl_binding.descriptorCount = 1; |
| 5937 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5938 | |
| 5939 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5940 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5941 | ds_layout_ci.bindingCount = 1; |
| 5942 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5943 | |
| 5944 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5945 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5946 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5947 | ASSERT_VK_SUCCESS(err); |
| 5948 | |
| 5949 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5950 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5951 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5952 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5953 | alloc_info.descriptorPool = ds_pool; |
| 5954 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5955 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5956 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5957 | ASSERT_VK_SUCCESS(err); |
| 5958 | |
| 5959 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5960 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5961 | pipeline_layout_ci.setLayoutCount = 1; |
| 5962 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5963 | |
| 5964 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5965 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5966 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5967 | ASSERT_VK_SUCCESS(err); |
| 5968 | |
| 5969 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5970 | // Set scissor as dynamic to avoid second error |
| 5971 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5972 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5973 | dyn_state_ci.dynamicStateCount = 1; |
| 5974 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5975 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5976 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5978 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5979 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5980 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5981 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5982 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5983 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5984 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5985 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5986 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5987 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5988 | |
| 5989 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5990 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5991 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5992 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5993 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5994 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5995 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5996 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5997 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5998 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5999 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6000 | gp_ci.stageCount = 2; |
| 6001 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6002 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6004 | // should cause validation error |
| 6005 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6006 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6007 | gp_ci.layout = pipeline_layout; |
| 6008 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6009 | |
| 6010 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6012 | |
| 6013 | VkPipeline pipeline; |
| 6014 | VkPipelineCache pipelineCache; |
| 6015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6016 | err = |
| 6017 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6018 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6019 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6020 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6021 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6022 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6023 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6024 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6025 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6026 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6027 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6028 | } |
| 6029 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6030 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6031 | // count |
| 6032 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6033 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6034 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | m_errorMonitor->SetDesiredFailureMsg( |
| 6036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6037 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6038 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6039 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6040 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6041 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6042 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6043 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6044 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6045 | |
| 6046 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6047 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6048 | ds_pool_ci.maxSets = 1; |
| 6049 | ds_pool_ci.poolSizeCount = 1; |
| 6050 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6051 | |
| 6052 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6053 | err = |
| 6054 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6055 | ASSERT_VK_SUCCESS(err); |
| 6056 | |
| 6057 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6058 | dsl_binding.binding = 0; |
| 6059 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6060 | dsl_binding.descriptorCount = 1; |
| 6061 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6062 | |
| 6063 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6064 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6065 | ds_layout_ci.bindingCount = 1; |
| 6066 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6067 | |
| 6068 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6069 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6070 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6071 | ASSERT_VK_SUCCESS(err); |
| 6072 | |
| 6073 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6074 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6075 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6076 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6077 | alloc_info.descriptorPool = ds_pool; |
| 6078 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6080 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6081 | ASSERT_VK_SUCCESS(err); |
| 6082 | |
| 6083 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6084 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6085 | pipeline_layout_ci.setLayoutCount = 1; |
| 6086 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6087 | |
| 6088 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6089 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6090 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6091 | ASSERT_VK_SUCCESS(err); |
| 6092 | |
| 6093 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6094 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6095 | vp_state_ci.viewportCount = 1; |
| 6096 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6097 | vp_state_ci.scissorCount = 1; |
| 6098 | vp_state_ci.pScissors = |
| 6099 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6100 | |
| 6101 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6102 | // Set scissor as dynamic to avoid that error |
| 6103 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6104 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6105 | dyn_state_ci.dynamicStateCount = 1; |
| 6106 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6107 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6108 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6109 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6110 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6111 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6112 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6113 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6114 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6115 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6116 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6117 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6118 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6119 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6120 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6121 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6122 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6123 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6124 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6125 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6126 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6127 | |
| 6128 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6129 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6130 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6131 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6132 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6133 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6134 | rs_ci.pNext = nullptr; |
| 6135 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6136 | VkPipelineColorBlendAttachmentState att = {}; |
| 6137 | att.blendEnable = VK_FALSE; |
| 6138 | att.colorWriteMask = 0xf; |
| 6139 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6140 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6141 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6142 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6143 | cb_ci.attachmentCount = 1; |
| 6144 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6145 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6146 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6147 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6148 | gp_ci.stageCount = 2; |
| 6149 | gp_ci.pStages = shaderStages; |
| 6150 | gp_ci.pVertexInputState = &vi_ci; |
| 6151 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6152 | gp_ci.pViewportState = &vp_state_ci; |
| 6153 | gp_ci.pRasterizationState = &rs_ci; |
| 6154 | gp_ci.pColorBlendState = &cb_ci; |
| 6155 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6156 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6157 | gp_ci.layout = pipeline_layout; |
| 6158 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6159 | |
| 6160 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6161 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6162 | |
| 6163 | VkPipeline pipeline; |
| 6164 | VkPipelineCache pipelineCache; |
| 6165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6166 | err = |
| 6167 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6168 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6170 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6171 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6172 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6173 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6174 | // 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] | 6175 | // First need to successfully create the PSO from above by setting |
| 6176 | // pViewports |
| 6177 | m_errorMonitor->SetDesiredFailureMsg( |
| 6178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6179 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6180 | "scissorCount is 1. These counts must match."); |
| 6181 | |
| 6182 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6183 | vp_state_ci.pViewports = &vp; |
| 6184 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6185 | &gp_ci, NULL, &pipeline); |
| 6186 | ASSERT_VK_SUCCESS(err); |
| 6187 | BeginCommandBuffer(); |
| 6188 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6189 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6190 | VkRect2D scissors[2] = {}; // don't care about data |
| 6191 | // Count of 2 doesn't match PSO count of 1 |
| 6192 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6193 | Draw(1, 0, 0, 0); |
| 6194 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6195 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6196 | |
| 6197 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6198 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6199 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6200 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6201 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6202 | } |
| 6203 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6204 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6205 | // viewportCount |
| 6206 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6207 | VkResult err; |
| 6208 | |
| 6209 | m_errorMonitor->SetDesiredFailureMsg( |
| 6210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6211 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6212 | |
| 6213 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6214 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6215 | |
| 6216 | VkDescriptorPoolSize ds_type_count = {}; |
| 6217 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6218 | ds_type_count.descriptorCount = 1; |
| 6219 | |
| 6220 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6221 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6222 | ds_pool_ci.maxSets = 1; |
| 6223 | ds_pool_ci.poolSizeCount = 1; |
| 6224 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6225 | |
| 6226 | VkDescriptorPool ds_pool; |
| 6227 | err = |
| 6228 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6229 | ASSERT_VK_SUCCESS(err); |
| 6230 | |
| 6231 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6232 | dsl_binding.binding = 0; |
| 6233 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6234 | dsl_binding.descriptorCount = 1; |
| 6235 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6236 | |
| 6237 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6238 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6239 | ds_layout_ci.bindingCount = 1; |
| 6240 | ds_layout_ci.pBindings = &dsl_binding; |
| 6241 | |
| 6242 | VkDescriptorSetLayout ds_layout; |
| 6243 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6244 | &ds_layout); |
| 6245 | ASSERT_VK_SUCCESS(err); |
| 6246 | |
| 6247 | VkDescriptorSet descriptorSet; |
| 6248 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6249 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6250 | alloc_info.descriptorSetCount = 1; |
| 6251 | alloc_info.descriptorPool = ds_pool; |
| 6252 | alloc_info.pSetLayouts = &ds_layout; |
| 6253 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6254 | &descriptorSet); |
| 6255 | ASSERT_VK_SUCCESS(err); |
| 6256 | |
| 6257 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6258 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6259 | pipeline_layout_ci.setLayoutCount = 1; |
| 6260 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6261 | |
| 6262 | VkPipelineLayout pipeline_layout; |
| 6263 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6264 | &pipeline_layout); |
| 6265 | ASSERT_VK_SUCCESS(err); |
| 6266 | |
| 6267 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6268 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6269 | vp_state_ci.scissorCount = 1; |
| 6270 | vp_state_ci.pScissors = |
| 6271 | NULL; // Null scissor w/ count of 1 should cause error |
| 6272 | vp_state_ci.viewportCount = 1; |
| 6273 | vp_state_ci.pViewports = |
| 6274 | NULL; // vp is dynamic (below) so this won't cause error |
| 6275 | |
| 6276 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6277 | // Set scissor as dynamic to avoid that error |
| 6278 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6279 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6280 | dyn_state_ci.dynamicStateCount = 1; |
| 6281 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6282 | |
| 6283 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6284 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6285 | |
| 6286 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6287 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6288 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6289 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6290 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6291 | // but add it to be able to run on more devices |
| 6292 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6293 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6294 | |
| 6295 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6296 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6297 | vi_ci.pNext = nullptr; |
| 6298 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6299 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6300 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6301 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6302 | |
| 6303 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6304 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6305 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6306 | |
| 6307 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6308 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6309 | rs_ci.pNext = nullptr; |
| 6310 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6311 | VkPipelineColorBlendAttachmentState att = {}; |
| 6312 | att.blendEnable = VK_FALSE; |
| 6313 | att.colorWriteMask = 0xf; |
| 6314 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6315 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6316 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6317 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6318 | cb_ci.attachmentCount = 1; |
| 6319 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6320 | |
| 6321 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6322 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6323 | gp_ci.stageCount = 2; |
| 6324 | gp_ci.pStages = shaderStages; |
| 6325 | gp_ci.pVertexInputState = &vi_ci; |
| 6326 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6327 | gp_ci.pViewportState = &vp_state_ci; |
| 6328 | gp_ci.pRasterizationState = &rs_ci; |
| 6329 | gp_ci.pColorBlendState = &cb_ci; |
| 6330 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6331 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6332 | gp_ci.layout = pipeline_layout; |
| 6333 | gp_ci.renderPass = renderPass(); |
| 6334 | |
| 6335 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6336 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6337 | |
| 6338 | VkPipeline pipeline; |
| 6339 | VkPipelineCache pipelineCache; |
| 6340 | |
| 6341 | err = |
| 6342 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6343 | ASSERT_VK_SUCCESS(err); |
| 6344 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6345 | &gp_ci, NULL, &pipeline); |
| 6346 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6347 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6348 | |
| 6349 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6350 | // First need to successfully create the PSO from above by setting |
| 6351 | // pViewports |
| 6352 | m_errorMonitor->SetDesiredFailureMsg( |
| 6353 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6354 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6355 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6356 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6357 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6358 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6359 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6360 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6361 | ASSERT_VK_SUCCESS(err); |
| 6362 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6363 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6364 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6365 | VkViewport viewports[2] = {}; // don't care about data |
| 6366 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6367 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6368 | Draw(1, 0, 0, 0); |
| 6369 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6370 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6371 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6372 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6373 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6374 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6375 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6376 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6377 | } |
| 6378 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6379 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6380 | VkResult err; |
| 6381 | |
| 6382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6383 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6384 | |
| 6385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6386 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6387 | |
| 6388 | VkDescriptorPoolSize ds_type_count = {}; |
| 6389 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6390 | ds_type_count.descriptorCount = 1; |
| 6391 | |
| 6392 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6393 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6394 | ds_pool_ci.maxSets = 1; |
| 6395 | ds_pool_ci.poolSizeCount = 1; |
| 6396 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6397 | |
| 6398 | VkDescriptorPool ds_pool; |
| 6399 | err = |
| 6400 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6401 | ASSERT_VK_SUCCESS(err); |
| 6402 | |
| 6403 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6404 | dsl_binding.binding = 0; |
| 6405 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6406 | dsl_binding.descriptorCount = 1; |
| 6407 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6408 | |
| 6409 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6410 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6411 | ds_layout_ci.bindingCount = 1; |
| 6412 | ds_layout_ci.pBindings = &dsl_binding; |
| 6413 | |
| 6414 | VkDescriptorSetLayout ds_layout; |
| 6415 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6416 | &ds_layout); |
| 6417 | ASSERT_VK_SUCCESS(err); |
| 6418 | |
| 6419 | VkDescriptorSet descriptorSet; |
| 6420 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6421 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6422 | alloc_info.descriptorSetCount = 1; |
| 6423 | alloc_info.descriptorPool = ds_pool; |
| 6424 | alloc_info.pSetLayouts = &ds_layout; |
| 6425 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6426 | &descriptorSet); |
| 6427 | ASSERT_VK_SUCCESS(err); |
| 6428 | |
| 6429 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6430 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6431 | pipeline_layout_ci.setLayoutCount = 1; |
| 6432 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6433 | |
| 6434 | VkPipelineLayout pipeline_layout; |
| 6435 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6436 | &pipeline_layout); |
| 6437 | ASSERT_VK_SUCCESS(err); |
| 6438 | |
| 6439 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6440 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6441 | vp_state_ci.scissorCount = 1; |
| 6442 | vp_state_ci.pScissors = NULL; |
| 6443 | vp_state_ci.viewportCount = 1; |
| 6444 | vp_state_ci.pViewports = NULL; |
| 6445 | |
| 6446 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6447 | VK_DYNAMIC_STATE_SCISSOR, |
| 6448 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6449 | // Set scissor as dynamic to avoid that error |
| 6450 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6451 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6452 | dyn_state_ci.dynamicStateCount = 2; |
| 6453 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6454 | |
| 6455 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6456 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6457 | |
| 6458 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6459 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6460 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6461 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6462 | this); // TODO - We shouldn't need a fragment shader |
| 6463 | // but add it to be able to run on more devices |
| 6464 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6465 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6466 | |
| 6467 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6468 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6469 | vi_ci.pNext = nullptr; |
| 6470 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6471 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6472 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6473 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6474 | |
| 6475 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6476 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6477 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6478 | |
| 6479 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6480 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6481 | rs_ci.pNext = nullptr; |
| 6482 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6483 | // Check too low (line width of -1.0f). |
| 6484 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6485 | |
| 6486 | VkPipelineColorBlendAttachmentState att = {}; |
| 6487 | att.blendEnable = VK_FALSE; |
| 6488 | att.colorWriteMask = 0xf; |
| 6489 | |
| 6490 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6491 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6492 | cb_ci.pNext = nullptr; |
| 6493 | cb_ci.attachmentCount = 1; |
| 6494 | cb_ci.pAttachments = &att; |
| 6495 | |
| 6496 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6497 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6498 | gp_ci.stageCount = 2; |
| 6499 | gp_ci.pStages = shaderStages; |
| 6500 | gp_ci.pVertexInputState = &vi_ci; |
| 6501 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6502 | gp_ci.pViewportState = &vp_state_ci; |
| 6503 | gp_ci.pRasterizationState = &rs_ci; |
| 6504 | gp_ci.pColorBlendState = &cb_ci; |
| 6505 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6506 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6507 | gp_ci.layout = pipeline_layout; |
| 6508 | gp_ci.renderPass = renderPass(); |
| 6509 | |
| 6510 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6511 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6512 | |
| 6513 | VkPipeline pipeline; |
| 6514 | VkPipelineCache pipelineCache; |
| 6515 | |
| 6516 | err = |
| 6517 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6518 | ASSERT_VK_SUCCESS(err); |
| 6519 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6520 | &gp_ci, NULL, &pipeline); |
| 6521 | |
| 6522 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6523 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6524 | |
| 6525 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6526 | "Attempt to set lineWidth to 65536"); |
| 6527 | |
| 6528 | // Check too high (line width of 65536.0f). |
| 6529 | rs_ci.lineWidth = 65536.0f; |
| 6530 | |
| 6531 | err = |
| 6532 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6533 | ASSERT_VK_SUCCESS(err); |
| 6534 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6535 | &gp_ci, NULL, &pipeline); |
| 6536 | |
| 6537 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6538 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6539 | |
| 6540 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6541 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6542 | |
| 6543 | dyn_state_ci.dynamicStateCount = 3; |
| 6544 | |
| 6545 | rs_ci.lineWidth = 1.0f; |
| 6546 | |
| 6547 | err = |
| 6548 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6549 | ASSERT_VK_SUCCESS(err); |
| 6550 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6551 | &gp_ci, NULL, &pipeline); |
| 6552 | BeginCommandBuffer(); |
| 6553 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6554 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6555 | |
| 6556 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6557 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6558 | m_errorMonitor->VerifyFound(); |
| 6559 | |
| 6560 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6561 | "Attempt to set lineWidth to 65536"); |
| 6562 | |
| 6563 | // Check too high with dynamic setting. |
| 6564 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6565 | m_errorMonitor->VerifyFound(); |
| 6566 | EndCommandBuffer(); |
| 6567 | |
| 6568 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6569 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6570 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6571 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6572 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6573 | } |
| 6574 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6575 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6576 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6577 | m_errorMonitor->SetDesiredFailureMsg( |
| 6578 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6579 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6580 | |
| 6581 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6582 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6583 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6584 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6586 | // that |
| 6587 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6588 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6589 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6590 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6591 | } |
| 6592 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6594 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6595 | m_errorMonitor->SetDesiredFailureMsg( |
| 6596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6597 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6598 | |
| 6599 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6600 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6601 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6602 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6603 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6604 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6605 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6606 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6607 | rp_begin.pNext = NULL; |
| 6608 | rp_begin.renderPass = renderPass(); |
| 6609 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6610 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6611 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6612 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6614 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6615 | } |
| 6616 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6617 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 6618 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 6619 | "the number of renderPass attachments that use loadOp" |
| 6620 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 6621 | |
| 6622 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6623 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6624 | |
| 6625 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 6626 | VkAttachmentReference attach = {}; |
| 6627 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6628 | VkSubpassDescription subpass = {}; |
| 6629 | subpass.inputAttachmentCount = 1; |
| 6630 | subpass.pInputAttachments = &attach; |
| 6631 | VkRenderPassCreateInfo rpci = {}; |
| 6632 | rpci.subpassCount = 1; |
| 6633 | rpci.pSubpasses = &subpass; |
| 6634 | rpci.attachmentCount = 1; |
| 6635 | VkAttachmentDescription attach_desc = {}; |
| 6636 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6637 | // Set loadOp to CLEAR |
| 6638 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6639 | rpci.pAttachments = &attach_desc; |
| 6640 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 6641 | VkRenderPass rp; |
| 6642 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6643 | |
| 6644 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 6645 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 6646 | hinfo.renderPass = VK_NULL_HANDLE; |
| 6647 | hinfo.subpass = 0; |
| 6648 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 6649 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 6650 | hinfo.queryFlags = 0; |
| 6651 | hinfo.pipelineStatistics = 0; |
| 6652 | VkCommandBufferBeginInfo info = {}; |
| 6653 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 6654 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6655 | info.pInheritanceInfo = &hinfo; |
| 6656 | |
| 6657 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 6658 | VkRenderPassBeginInfo rp_begin = {}; |
| 6659 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6660 | rp_begin.pNext = NULL; |
| 6661 | rp_begin.renderPass = renderPass(); |
| 6662 | rp_begin.framebuffer = framebuffer(); |
| 6663 | rp_begin.clearValueCount = 0; // Should be 1 |
| 6664 | |
| 6665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6666 | " has a clearValueCount of 0 but the " |
| 6667 | "actual number of attachments in " |
| 6668 | "renderPass "); |
| 6669 | |
| 6670 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6671 | VK_SUBPASS_CONTENTS_INLINE); |
| 6672 | |
| 6673 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 6674 | |
| 6675 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6676 | } |
| 6677 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6678 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6679 | |
| 6680 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6681 | |
| 6682 | m_errorMonitor->SetDesiredFailureMsg( |
| 6683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6684 | "It is invalid to issue this call inside an active render pass"); |
| 6685 | |
| 6686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6687 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6688 | |
| 6689 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6690 | BeginCommandBuffer(); |
| 6691 | |
| 6692 | // Call directly into vkEndCommandBuffer instead of the |
| 6693 | // the framework's EndCommandBuffer, which inserts a |
| 6694 | // vkEndRenderPass |
| 6695 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6696 | |
| 6697 | m_errorMonitor->VerifyFound(); |
| 6698 | |
| 6699 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6700 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6701 | } |
| 6702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6703 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6704 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6705 | m_errorMonitor->SetDesiredFailureMsg( |
| 6706 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6707 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6708 | |
| 6709 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6710 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6711 | |
| 6712 | // Renderpass is started here |
| 6713 | BeginCommandBuffer(); |
| 6714 | |
| 6715 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6716 | vk_testing::Buffer dstBuffer; |
| 6717 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6718 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6719 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6720 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6721 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6722 | } |
| 6723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6724 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6725 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6726 | m_errorMonitor->SetDesiredFailureMsg( |
| 6727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6728 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6729 | |
| 6730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6731 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6732 | |
| 6733 | // Renderpass is started here |
| 6734 | BeginCommandBuffer(); |
| 6735 | |
| 6736 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6737 | vk_testing::Buffer dstBuffer; |
| 6738 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6740 | VkDeviceSize dstOffset = 0; |
| 6741 | VkDeviceSize dataSize = 1024; |
| 6742 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6744 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6745 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6746 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6747 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6748 | } |
| 6749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6751 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6752 | m_errorMonitor->SetDesiredFailureMsg( |
| 6753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6754 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6755 | |
| 6756 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6757 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6758 | |
| 6759 | // Renderpass is started here |
| 6760 | BeginCommandBuffer(); |
| 6761 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6762 | VkClearColorValue clear_color; |
| 6763 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6764 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6765 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6766 | const int32_t tex_width = 32; |
| 6767 | const int32_t tex_height = 32; |
| 6768 | VkImageCreateInfo image_create_info = {}; |
| 6769 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6770 | image_create_info.pNext = NULL; |
| 6771 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6772 | image_create_info.format = tex_format; |
| 6773 | image_create_info.extent.width = tex_width; |
| 6774 | image_create_info.extent.height = tex_height; |
| 6775 | image_create_info.extent.depth = 1; |
| 6776 | image_create_info.mipLevels = 1; |
| 6777 | image_create_info.arrayLayers = 1; |
| 6778 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6779 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6780 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6781 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6782 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6783 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6784 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6785 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6786 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6787 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6788 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6789 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6790 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6791 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6792 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6793 | } |
| 6794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6795 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6796 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6797 | m_errorMonitor->SetDesiredFailureMsg( |
| 6798 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6799 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6800 | |
| 6801 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6802 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6803 | |
| 6804 | // Renderpass is started here |
| 6805 | BeginCommandBuffer(); |
| 6806 | |
| 6807 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6808 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6809 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6810 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6811 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6812 | image_create_info.extent.width = 64; |
| 6813 | image_create_info.extent.height = 64; |
| 6814 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6815 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6816 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6817 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6818 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6819 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6820 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6821 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6822 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | vkCmdClearDepthStencilImage( |
| 6825 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6826 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6827 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6828 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6829 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6830 | } |
| 6831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6832 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6833 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6834 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6835 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6836 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6837 | "vkCmdClearAttachments: This call " |
| 6838 | "must be issued inside an active " |
| 6839 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6840 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6841 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6842 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6843 | |
| 6844 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6845 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6846 | ASSERT_VK_SUCCESS(err); |
| 6847 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6848 | VkClearAttachment color_attachment; |
| 6849 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6850 | color_attachment.clearValue.color.float32[0] = 0; |
| 6851 | color_attachment.clearValue.color.float32[1] = 0; |
| 6852 | color_attachment.clearValue.color.float32[2] = 0; |
| 6853 | color_attachment.clearValue.color.float32[3] = 0; |
| 6854 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6855 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6856 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6857 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6858 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6859 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6860 | } |
| 6861 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6862 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6863 | // Try to add a buffer memory barrier with no buffer. |
| 6864 | m_errorMonitor->SetDesiredFailureMsg( |
| 6865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6866 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6867 | |
| 6868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6869 | BeginCommandBuffer(); |
| 6870 | |
| 6871 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6872 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6873 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6874 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6875 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6876 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6877 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6878 | buf_barrier.offset = 0; |
| 6879 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6880 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6881 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6882 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6883 | |
| 6884 | m_errorMonitor->VerifyFound(); |
| 6885 | } |
| 6886 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6887 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6888 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6889 | |
| 6890 | m_errorMonitor->SetDesiredFailureMsg( |
| 6891 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6892 | |
| 6893 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6895 | |
| 6896 | VkMemoryBarrier mem_barrier = {}; |
| 6897 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6898 | mem_barrier.pNext = NULL; |
| 6899 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6900 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6901 | BeginCommandBuffer(); |
| 6902 | // BeginCommandBuffer() starts a render pass |
| 6903 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6904 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6905 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6906 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6907 | m_errorMonitor->VerifyFound(); |
| 6908 | |
| 6909 | m_errorMonitor->SetDesiredFailureMsg( |
| 6910 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6911 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6912 | VkImageObj image(m_device); |
| 6913 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6914 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6915 | ASSERT_TRUE(image.initialized()); |
| 6916 | VkImageMemoryBarrier img_barrier = {}; |
| 6917 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6918 | img_barrier.pNext = NULL; |
| 6919 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6920 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6921 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6922 | // New layout can't be UNDEFINED |
| 6923 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6924 | img_barrier.image = image.handle(); |
| 6925 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6926 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6927 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6928 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6929 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6930 | img_barrier.subresourceRange.layerCount = 1; |
| 6931 | img_barrier.subresourceRange.levelCount = 1; |
| 6932 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6933 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6934 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6935 | nullptr, 1, &img_barrier); |
| 6936 | m_errorMonitor->VerifyFound(); |
| 6937 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6938 | |
| 6939 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6940 | "Subresource must have the sum of the " |
| 6941 | "baseArrayLayer"); |
| 6942 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6943 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6944 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6945 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6946 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6947 | nullptr, 1, &img_barrier); |
| 6948 | m_errorMonitor->VerifyFound(); |
| 6949 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6950 | |
| 6951 | m_errorMonitor->SetDesiredFailureMsg( |
| 6952 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6953 | "Subresource must have the sum of the baseMipLevel"); |
| 6954 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6955 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6956 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6957 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6958 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6959 | nullptr, 1, &img_barrier); |
| 6960 | m_errorMonitor->VerifyFound(); |
| 6961 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6962 | |
| 6963 | m_errorMonitor->SetDesiredFailureMsg( |
| 6964 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6965 | "Buffer Barriers cannot be used during a render pass"); |
| 6966 | vk_testing::Buffer buffer; |
| 6967 | buffer.init(*m_device, 256); |
| 6968 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6969 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6970 | buf_barrier.pNext = NULL; |
| 6971 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6972 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6973 | buf_barrier.buffer = buffer.handle(); |
| 6974 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6975 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6976 | buf_barrier.offset = 0; |
| 6977 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6978 | // Can't send buffer barrier during a render pass |
| 6979 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6980 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6981 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6982 | &buf_barrier, 0, nullptr); |
| 6983 | m_errorMonitor->VerifyFound(); |
| 6984 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6985 | |
| 6986 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6987 | "which is not less than total size"); |
| 6988 | buf_barrier.offset = 257; |
| 6989 | // Offset greater than total size |
| 6990 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6991 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6992 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6993 | &buf_barrier, 0, nullptr); |
| 6994 | m_errorMonitor->VerifyFound(); |
| 6995 | buf_barrier.offset = 0; |
| 6996 | |
| 6997 | m_errorMonitor->SetDesiredFailureMsg( |
| 6998 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6999 | buf_barrier.size = 257; |
| 7000 | // Size greater than total size |
| 7001 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7002 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7003 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7004 | &buf_barrier, 0, nullptr); |
| 7005 | m_errorMonitor->VerifyFound(); |
| 7006 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7007 | |
| 7008 | m_errorMonitor->SetDesiredFailureMsg( |
| 7009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7010 | "Image is a depth and stencil format and thus must " |
| 7011 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7012 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7013 | VkDepthStencilObj ds_image(m_device); |
| 7014 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7015 | ASSERT_TRUE(ds_image.initialized()); |
| 7016 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7017 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7018 | img_barrier.image = ds_image.handle(); |
| 7019 | // Leave aspectMask at COLOR on purpose |
| 7020 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7021 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7022 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7023 | nullptr, 1, &img_barrier); |
| 7024 | m_errorMonitor->VerifyFound(); |
| 7025 | } |
| 7026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7027 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7028 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7029 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7030 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7031 | m_errorMonitor->SetDesiredFailureMsg( |
| 7032 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7033 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7034 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7036 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7037 | uint32_t qfi = 0; |
| 7038 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7039 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7040 | buffCI.size = 1024; |
| 7041 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7042 | buffCI.queueFamilyIndexCount = 1; |
| 7043 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7044 | |
| 7045 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7046 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7047 | ASSERT_VK_SUCCESS(err); |
| 7048 | |
| 7049 | BeginCommandBuffer(); |
| 7050 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7051 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7052 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7053 | // 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] | 7054 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7055 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7056 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7057 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7058 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7059 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7060 | } |
| 7061 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7062 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7063 | // Create an out-of-range queueFamilyIndex |
| 7064 | m_errorMonitor->SetDesiredFailureMsg( |
| 7065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7066 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7067 | "of the indices specified when the device was created, via the " |
| 7068 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7069 | |
| 7070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7071 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7072 | VkBufferCreateInfo buffCI = {}; |
| 7073 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7074 | buffCI.size = 1024; |
| 7075 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7076 | buffCI.queueFamilyIndexCount = 1; |
| 7077 | // Introduce failure by specifying invalid queue_family_index |
| 7078 | uint32_t qfi = 777; |
| 7079 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7080 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7081 | |
| 7082 | VkBuffer ib; |
| 7083 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7084 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7085 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7086 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7087 | } |
| 7088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7089 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7090 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7091 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7092 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7093 | m_errorMonitor->SetDesiredFailureMsg( |
| 7094 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7095 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7096 | |
| 7097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7098 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7099 | |
| 7100 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7101 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7102 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7103 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7104 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7105 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7106 | } |
| 7107 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7108 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7109 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7110 | "that do not have correct usage bits sets."); |
| 7111 | VkResult err; |
| 7112 | |
| 7113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7114 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7115 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7116 | ds_type_count[i].type = VkDescriptorType(i); |
| 7117 | ds_type_count[i].descriptorCount = 1; |
| 7118 | } |
| 7119 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7120 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7121 | ds_pool_ci.pNext = NULL; |
| 7122 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7123 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7124 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7125 | |
| 7126 | VkDescriptorPool ds_pool; |
| 7127 | err = |
| 7128 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7129 | ASSERT_VK_SUCCESS(err); |
| 7130 | |
| 7131 | // Create 10 layouts where each has a single descriptor of different type |
| 7132 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7133 | {}; |
| 7134 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7135 | dsl_binding[i].binding = 0; |
| 7136 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7137 | dsl_binding[i].descriptorCount = 1; |
| 7138 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7139 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7140 | } |
| 7141 | |
| 7142 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7143 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7144 | ds_layout_ci.pNext = NULL; |
| 7145 | ds_layout_ci.bindingCount = 1; |
| 7146 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7147 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7148 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7149 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7150 | NULL, ds_layouts + i); |
| 7151 | ASSERT_VK_SUCCESS(err); |
| 7152 | } |
| 7153 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7154 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7155 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7156 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7157 | alloc_info.descriptorPool = ds_pool; |
| 7158 | alloc_info.pSetLayouts = ds_layouts; |
| 7159 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7160 | descriptor_sets); |
| 7161 | ASSERT_VK_SUCCESS(err); |
| 7162 | |
| 7163 | // Create a buffer & bufferView to be used for invalid updates |
| 7164 | VkBufferCreateInfo buff_ci = {}; |
| 7165 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7166 | // This usage is not valid for any descriptor type |
| 7167 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7168 | buff_ci.size = 256; |
| 7169 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7170 | VkBuffer buffer; |
| 7171 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7172 | ASSERT_VK_SUCCESS(err); |
| 7173 | |
| 7174 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7175 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7176 | buff_view_ci.buffer = buffer; |
| 7177 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7178 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7179 | VkBufferView buff_view; |
| 7180 | err = |
| 7181 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7182 | ASSERT_VK_SUCCESS(err); |
| 7183 | |
| 7184 | // Create an image to be used for invalid updates |
| 7185 | VkImageCreateInfo image_ci = {}; |
| 7186 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7187 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7188 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7189 | image_ci.extent.width = 64; |
| 7190 | image_ci.extent.height = 64; |
| 7191 | image_ci.extent.depth = 1; |
| 7192 | image_ci.mipLevels = 1; |
| 7193 | image_ci.arrayLayers = 1; |
| 7194 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7195 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7196 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7197 | // This usage is not valid for any descriptor type |
| 7198 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7199 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7200 | VkImage image; |
| 7201 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7202 | ASSERT_VK_SUCCESS(err); |
| 7203 | // Bind memory to image |
| 7204 | VkMemoryRequirements mem_reqs; |
| 7205 | VkDeviceMemory image_mem; |
| 7206 | bool pass; |
| 7207 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7208 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7209 | mem_alloc.pNext = NULL; |
| 7210 | mem_alloc.allocationSize = 0; |
| 7211 | mem_alloc.memoryTypeIndex = 0; |
| 7212 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7213 | mem_alloc.allocationSize = mem_reqs.size; |
| 7214 | pass = |
| 7215 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7216 | ASSERT_TRUE(pass); |
| 7217 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7218 | ASSERT_VK_SUCCESS(err); |
| 7219 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7220 | ASSERT_VK_SUCCESS(err); |
| 7221 | // Now create view for image |
| 7222 | VkImageViewCreateInfo image_view_ci = {}; |
| 7223 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7224 | image_view_ci.image = image; |
| 7225 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7226 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7227 | image_view_ci.subresourceRange.layerCount = 1; |
| 7228 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7229 | image_view_ci.subresourceRange.levelCount = 1; |
| 7230 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7231 | VkImageView image_view; |
| 7232 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7233 | &image_view); |
| 7234 | ASSERT_VK_SUCCESS(err); |
| 7235 | |
| 7236 | VkDescriptorBufferInfo buff_info = {}; |
| 7237 | buff_info.buffer = buffer; |
| 7238 | VkDescriptorImageInfo img_info = {}; |
| 7239 | img_info.imageView = image_view; |
| 7240 | VkWriteDescriptorSet descriptor_write = {}; |
| 7241 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7242 | descriptor_write.dstBinding = 0; |
| 7243 | descriptor_write.descriptorCount = 1; |
| 7244 | descriptor_write.pTexelBufferView = &buff_view; |
| 7245 | descriptor_write.pBufferInfo = &buff_info; |
| 7246 | descriptor_write.pImageInfo = &img_info; |
| 7247 | |
| 7248 | // These error messages align with VkDescriptorType struct |
| 7249 | const char *error_msgs[] = { |
| 7250 | "", // placeholder, no error for SAMPLER descriptor |
| 7251 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7252 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7253 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7254 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7255 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 7256 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7257 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7258 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7259 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7260 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7261 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7262 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7263 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7264 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7265 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7266 | error_msgs[i]); |
| 7267 | |
| 7268 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7269 | NULL); |
| 7270 | |
| 7271 | m_errorMonitor->VerifyFound(); |
| 7272 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7273 | } |
| 7274 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7275 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7276 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7277 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7278 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7279 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7280 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7281 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7282 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7283 | } |
| 7284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7285 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7286 | // 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] | 7287 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7289 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7290 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7291 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7292 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7293 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7294 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7295 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7296 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7297 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7298 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7299 | |
| 7300 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7301 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7302 | ds_pool_ci.pNext = NULL; |
| 7303 | ds_pool_ci.maxSets = 1; |
| 7304 | ds_pool_ci.poolSizeCount = 1; |
| 7305 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7306 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7307 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7308 | err = |
| 7309 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7310 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7311 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7312 | dsl_binding.binding = 0; |
| 7313 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7314 | dsl_binding.descriptorCount = 1; |
| 7315 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7316 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7317 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7318 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7319 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7320 | ds_layout_ci.pNext = NULL; |
| 7321 | ds_layout_ci.bindingCount = 1; |
| 7322 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7323 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7324 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7325 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7326 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7327 | ASSERT_VK_SUCCESS(err); |
| 7328 | |
| 7329 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7330 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7331 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7332 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7333 | alloc_info.descriptorPool = ds_pool; |
| 7334 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7335 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7336 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7337 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7338 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7339 | VkSamplerCreateInfo sampler_ci = {}; |
| 7340 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7341 | sampler_ci.pNext = NULL; |
| 7342 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7343 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7344 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7345 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7346 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7347 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7348 | sampler_ci.mipLodBias = 1.0; |
| 7349 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7350 | sampler_ci.maxAnisotropy = 1; |
| 7351 | sampler_ci.compareEnable = VK_FALSE; |
| 7352 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7353 | sampler_ci.minLod = 1.0; |
| 7354 | sampler_ci.maxLod = 1.0; |
| 7355 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7356 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7357 | VkSampler sampler; |
| 7358 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7359 | ASSERT_VK_SUCCESS(err); |
| 7360 | |
| 7361 | VkDescriptorImageInfo info = {}; |
| 7362 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7363 | |
| 7364 | VkWriteDescriptorSet descriptor_write; |
| 7365 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7366 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7367 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7368 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7369 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7370 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7371 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7372 | |
| 7373 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7375 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7376 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7377 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7378 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7379 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7380 | } |
| 7381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7382 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7383 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7384 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7386 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7387 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7388 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7389 | "starting at binding offset of 0 combined with update array element " |
| 7390 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7391 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7392 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7393 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7394 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7395 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7396 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7397 | |
| 7398 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7399 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7400 | ds_pool_ci.pNext = NULL; |
| 7401 | ds_pool_ci.maxSets = 1; |
| 7402 | ds_pool_ci.poolSizeCount = 1; |
| 7403 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7404 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7405 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7406 | err = |
| 7407 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7408 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7409 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7410 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7411 | dsl_binding.binding = 0; |
| 7412 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7413 | dsl_binding.descriptorCount = 1; |
| 7414 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7415 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7416 | |
| 7417 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7418 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7419 | ds_layout_ci.pNext = NULL; |
| 7420 | ds_layout_ci.bindingCount = 1; |
| 7421 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7422 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7423 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7424 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7425 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7426 | ASSERT_VK_SUCCESS(err); |
| 7427 | |
| 7428 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7429 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7430 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7431 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7432 | alloc_info.descriptorPool = ds_pool; |
| 7433 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7434 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7435 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7436 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7437 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7438 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7439 | VkDescriptorBufferInfo buff_info = {}; |
| 7440 | buff_info.buffer = |
| 7441 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7442 | buff_info.offset = 0; |
| 7443 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7444 | |
| 7445 | VkWriteDescriptorSet descriptor_write; |
| 7446 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7447 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7448 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7449 | descriptor_write.dstArrayElement = |
| 7450 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7451 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7452 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7453 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7454 | |
| 7455 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7456 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7457 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7458 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7459 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7460 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7461 | } |
| 7462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7463 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7464 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7465 | // index 2 |
| 7466 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7467 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7469 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7470 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7472 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7473 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7474 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7475 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7476 | |
| 7477 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7478 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7479 | ds_pool_ci.pNext = NULL; |
| 7480 | ds_pool_ci.maxSets = 1; |
| 7481 | ds_pool_ci.poolSizeCount = 1; |
| 7482 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7483 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7484 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7485 | err = |
| 7486 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7487 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7488 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7489 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7490 | dsl_binding.binding = 0; |
| 7491 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7492 | dsl_binding.descriptorCount = 1; |
| 7493 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7494 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7495 | |
| 7496 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7497 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7498 | ds_layout_ci.pNext = NULL; |
| 7499 | ds_layout_ci.bindingCount = 1; |
| 7500 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7501 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7502 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7503 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7504 | ASSERT_VK_SUCCESS(err); |
| 7505 | |
| 7506 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7507 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7508 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7509 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7510 | alloc_info.descriptorPool = ds_pool; |
| 7511 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7512 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7513 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7514 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7515 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7516 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7517 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7518 | sampler_ci.pNext = NULL; |
| 7519 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7520 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7521 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7522 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7523 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7524 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7525 | sampler_ci.mipLodBias = 1.0; |
| 7526 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7527 | sampler_ci.maxAnisotropy = 1; |
| 7528 | sampler_ci.compareEnable = VK_FALSE; |
| 7529 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7530 | sampler_ci.minLod = 1.0; |
| 7531 | sampler_ci.maxLod = 1.0; |
| 7532 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7533 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7534 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7535 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7536 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7537 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7538 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7539 | VkDescriptorImageInfo info = {}; |
| 7540 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7541 | |
| 7542 | VkWriteDescriptorSet descriptor_write; |
| 7543 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7544 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7545 | descriptor_write.dstSet = descriptorSet; |
| 7546 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7547 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7548 | // 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] | 7549 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7550 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7551 | |
| 7552 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7553 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7554 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7555 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7556 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7557 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7559 | } |
| 7560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7561 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7562 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7563 | // types |
| 7564 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7565 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7566 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7567 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7568 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7569 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7570 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7571 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7572 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7573 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7574 | |
| 7575 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7576 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7577 | ds_pool_ci.pNext = NULL; |
| 7578 | ds_pool_ci.maxSets = 1; |
| 7579 | ds_pool_ci.poolSizeCount = 1; |
| 7580 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7581 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7582 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7583 | err = |
| 7584 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7585 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7586 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7587 | dsl_binding.binding = 0; |
| 7588 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7589 | dsl_binding.descriptorCount = 1; |
| 7590 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7591 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7592 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7593 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7594 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7595 | ds_layout_ci.pNext = NULL; |
| 7596 | ds_layout_ci.bindingCount = 1; |
| 7597 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7598 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7599 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7600 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7601 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7602 | ASSERT_VK_SUCCESS(err); |
| 7603 | |
| 7604 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7605 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7606 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7607 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7608 | alloc_info.descriptorPool = ds_pool; |
| 7609 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7610 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7611 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7612 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7613 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7614 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7615 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7616 | sampler_ci.pNext = NULL; |
| 7617 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7618 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7619 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7620 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7621 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7622 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7623 | sampler_ci.mipLodBias = 1.0; |
| 7624 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7625 | sampler_ci.maxAnisotropy = 1; |
| 7626 | sampler_ci.compareEnable = VK_FALSE; |
| 7627 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7628 | sampler_ci.minLod = 1.0; |
| 7629 | sampler_ci.maxLod = 1.0; |
| 7630 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7631 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7632 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7633 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7634 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7635 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7636 | VkDescriptorImageInfo info = {}; |
| 7637 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7638 | |
| 7639 | VkWriteDescriptorSet descriptor_write; |
| 7640 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7641 | descriptor_write.sType = |
| 7642 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7643 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7644 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7645 | // 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] | 7646 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7647 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7648 | |
| 7649 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7650 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7651 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7652 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7653 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7654 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7655 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7656 | } |
| 7657 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7658 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7659 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7660 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7662 | m_errorMonitor->SetDesiredFailureMsg( |
| 7663 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7664 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7665 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7667 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7668 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7669 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7670 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7671 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7672 | |
| 7673 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7674 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7675 | ds_pool_ci.pNext = NULL; |
| 7676 | ds_pool_ci.maxSets = 1; |
| 7677 | ds_pool_ci.poolSizeCount = 1; |
| 7678 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7679 | |
| 7680 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7681 | err = |
| 7682 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7683 | ASSERT_VK_SUCCESS(err); |
| 7684 | |
| 7685 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7686 | dsl_binding.binding = 0; |
| 7687 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7688 | dsl_binding.descriptorCount = 1; |
| 7689 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7690 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7691 | |
| 7692 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7693 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7694 | ds_layout_ci.pNext = NULL; |
| 7695 | ds_layout_ci.bindingCount = 1; |
| 7696 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7697 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7698 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7699 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7700 | ASSERT_VK_SUCCESS(err); |
| 7701 | |
| 7702 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7703 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7704 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7705 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7706 | alloc_info.descriptorPool = ds_pool; |
| 7707 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7708 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7709 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7710 | ASSERT_VK_SUCCESS(err); |
| 7711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7712 | VkSampler sampler = |
| 7713 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7714 | |
| 7715 | VkDescriptorImageInfo descriptor_info; |
| 7716 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7717 | descriptor_info.sampler = sampler; |
| 7718 | |
| 7719 | VkWriteDescriptorSet descriptor_write; |
| 7720 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7721 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7722 | descriptor_write.dstSet = descriptorSet; |
| 7723 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7724 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7725 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7726 | descriptor_write.pImageInfo = &descriptor_info; |
| 7727 | |
| 7728 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7729 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7730 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7731 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7732 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7733 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7734 | } |
| 7735 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7736 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7737 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7738 | // imageView |
| 7739 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7740 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7741 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7742 | "Attempted write update to combined " |
| 7743 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7744 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7745 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7747 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7748 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7749 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7750 | |
| 7751 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7752 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7753 | ds_pool_ci.pNext = NULL; |
| 7754 | ds_pool_ci.maxSets = 1; |
| 7755 | ds_pool_ci.poolSizeCount = 1; |
| 7756 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7757 | |
| 7758 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7759 | err = |
| 7760 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7761 | ASSERT_VK_SUCCESS(err); |
| 7762 | |
| 7763 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7764 | dsl_binding.binding = 0; |
| 7765 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7766 | dsl_binding.descriptorCount = 1; |
| 7767 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7768 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7769 | |
| 7770 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7771 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7772 | ds_layout_ci.pNext = NULL; |
| 7773 | ds_layout_ci.bindingCount = 1; |
| 7774 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7775 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7776 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7777 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7778 | ASSERT_VK_SUCCESS(err); |
| 7779 | |
| 7780 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7781 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7782 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7783 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7784 | alloc_info.descriptorPool = ds_pool; |
| 7785 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7786 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7787 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7788 | ASSERT_VK_SUCCESS(err); |
| 7789 | |
| 7790 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7791 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7792 | sampler_ci.pNext = NULL; |
| 7793 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7794 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7795 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7796 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7797 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7798 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7799 | sampler_ci.mipLodBias = 1.0; |
| 7800 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7801 | sampler_ci.maxAnisotropy = 1; |
| 7802 | sampler_ci.compareEnable = VK_FALSE; |
| 7803 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7804 | sampler_ci.minLod = 1.0; |
| 7805 | sampler_ci.maxLod = 1.0; |
| 7806 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7807 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7808 | |
| 7809 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7810 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7811 | ASSERT_VK_SUCCESS(err); |
| 7812 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7813 | VkImageView view = |
| 7814 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7815 | |
| 7816 | VkDescriptorImageInfo descriptor_info; |
| 7817 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7818 | descriptor_info.sampler = sampler; |
| 7819 | descriptor_info.imageView = view; |
| 7820 | |
| 7821 | VkWriteDescriptorSet descriptor_write; |
| 7822 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7823 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7824 | descriptor_write.dstSet = descriptorSet; |
| 7825 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7826 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7827 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7828 | descriptor_write.pImageInfo = &descriptor_info; |
| 7829 | |
| 7830 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7831 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7832 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7833 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7834 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7835 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7836 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7837 | } |
| 7838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7839 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7840 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7841 | // into the other |
| 7842 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7843 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7844 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7845 | " binding #1 with type " |
| 7846 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7847 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7848 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7850 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7851 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7852 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7853 | ds_type_count[0].descriptorCount = 1; |
| 7854 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7855 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7856 | |
| 7857 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7858 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7859 | ds_pool_ci.pNext = NULL; |
| 7860 | ds_pool_ci.maxSets = 1; |
| 7861 | ds_pool_ci.poolSizeCount = 2; |
| 7862 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7863 | |
| 7864 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7865 | err = |
| 7866 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7867 | ASSERT_VK_SUCCESS(err); |
| 7868 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7869 | dsl_binding[0].binding = 0; |
| 7870 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7871 | dsl_binding[0].descriptorCount = 1; |
| 7872 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7873 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7874 | dsl_binding[1].binding = 1; |
| 7875 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7876 | dsl_binding[1].descriptorCount = 1; |
| 7877 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7878 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7879 | |
| 7880 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7881 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7882 | ds_layout_ci.pNext = NULL; |
| 7883 | ds_layout_ci.bindingCount = 2; |
| 7884 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7885 | |
| 7886 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7887 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7888 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7889 | ASSERT_VK_SUCCESS(err); |
| 7890 | |
| 7891 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7892 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7893 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7894 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7895 | alloc_info.descriptorPool = ds_pool; |
| 7896 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7897 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7898 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7899 | ASSERT_VK_SUCCESS(err); |
| 7900 | |
| 7901 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7902 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7903 | sampler_ci.pNext = NULL; |
| 7904 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7905 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7906 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7907 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7908 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7909 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7910 | sampler_ci.mipLodBias = 1.0; |
| 7911 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7912 | sampler_ci.maxAnisotropy = 1; |
| 7913 | sampler_ci.compareEnable = VK_FALSE; |
| 7914 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7915 | sampler_ci.minLod = 1.0; |
| 7916 | sampler_ci.maxLod = 1.0; |
| 7917 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7918 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7919 | |
| 7920 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7921 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7922 | ASSERT_VK_SUCCESS(err); |
| 7923 | |
| 7924 | VkDescriptorImageInfo info = {}; |
| 7925 | info.sampler = sampler; |
| 7926 | |
| 7927 | VkWriteDescriptorSet descriptor_write; |
| 7928 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7929 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7930 | descriptor_write.dstSet = descriptorSet; |
| 7931 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7932 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7933 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7934 | descriptor_write.pImageInfo = &info; |
| 7935 | // This write update should succeed |
| 7936 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7937 | // Now perform a copy update that fails due to type mismatch |
| 7938 | VkCopyDescriptorSet copy_ds_update; |
| 7939 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7940 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7941 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7942 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7943 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7944 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7945 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7946 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7947 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7948 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7949 | // 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] | 7950 | m_errorMonitor->SetDesiredFailureMsg( |
| 7951 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7952 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7953 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7954 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7955 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7956 | copy_ds_update.srcBinding = |
| 7957 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7958 | copy_ds_update.dstSet = descriptorSet; |
| 7959 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7960 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7961 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7962 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7963 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7964 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7965 | // 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] | 7966 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7967 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7968 | "update array offset of 0 and update of " |
| 7969 | "5 descriptors oversteps total number " |
| 7970 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7971 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7972 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7973 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7974 | copy_ds_update.srcSet = descriptorSet; |
| 7975 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7976 | copy_ds_update.dstSet = descriptorSet; |
| 7977 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7978 | copy_ds_update.descriptorCount = |
| 7979 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7980 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7981 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7982 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7983 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7984 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7985 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7986 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7987 | } |
| 7988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7989 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7990 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7991 | // sampleCount |
| 7992 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7993 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7994 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7995 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7996 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7998 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7999 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8000 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8001 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8002 | |
| 8003 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8004 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8005 | ds_pool_ci.pNext = NULL; |
| 8006 | ds_pool_ci.maxSets = 1; |
| 8007 | ds_pool_ci.poolSizeCount = 1; |
| 8008 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8009 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8010 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8011 | err = |
| 8012 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8013 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8014 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8015 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8016 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8017 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8018 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8019 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8020 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8021 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8022 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8023 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8024 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8025 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8026 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8027 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8028 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8029 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8030 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8031 | ASSERT_VK_SUCCESS(err); |
| 8032 | |
| 8033 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8034 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8035 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8036 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8037 | alloc_info.descriptorPool = ds_pool; |
| 8038 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8039 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8040 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8041 | ASSERT_VK_SUCCESS(err); |
| 8042 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8043 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8044 | pipe_ms_state_ci.sType = |
| 8045 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8046 | pipe_ms_state_ci.pNext = NULL; |
| 8047 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8048 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8049 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8050 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8051 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8052 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8053 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8054 | pipeline_layout_ci.pNext = NULL; |
| 8055 | pipeline_layout_ci.setLayoutCount = 1; |
| 8056 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8057 | |
| 8058 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8059 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8060 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8061 | ASSERT_VK_SUCCESS(err); |
| 8062 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8063 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8064 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8065 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8066 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8067 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8068 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8069 | VkPipelineObj pipe(m_device); |
| 8070 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8071 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8072 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8073 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8074 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8075 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8076 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8077 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8078 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8079 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8080 | // Render triangle (the error should trigger on the attempt to draw). |
| 8081 | Draw(3, 1, 0, 0); |
| 8082 | |
| 8083 | // Finalize recording of the command buffer |
| 8084 | EndCommandBuffer(); |
| 8085 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8086 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8087 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8088 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8089 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8090 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8091 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8092 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8093 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8094 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8095 | // number of color attachments. In this case, we don't add any color |
| 8096 | // blend attachments even though we have a color attachment. |
| 8097 | VkResult err; |
| 8098 | |
| 8099 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8100 | "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] | 8101 | |
| 8102 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8103 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8104 | VkDescriptorPoolSize ds_type_count = {}; |
| 8105 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8106 | ds_type_count.descriptorCount = 1; |
| 8107 | |
| 8108 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8109 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8110 | ds_pool_ci.pNext = NULL; |
| 8111 | ds_pool_ci.maxSets = 1; |
| 8112 | ds_pool_ci.poolSizeCount = 1; |
| 8113 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8114 | |
| 8115 | VkDescriptorPool ds_pool; |
| 8116 | err = |
| 8117 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8118 | ASSERT_VK_SUCCESS(err); |
| 8119 | |
| 8120 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8121 | dsl_binding.binding = 0; |
| 8122 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8123 | dsl_binding.descriptorCount = 1; |
| 8124 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8125 | dsl_binding.pImmutableSamplers = NULL; |
| 8126 | |
| 8127 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8128 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8129 | ds_layout_ci.pNext = NULL; |
| 8130 | ds_layout_ci.bindingCount = 1; |
| 8131 | ds_layout_ci.pBindings = &dsl_binding; |
| 8132 | |
| 8133 | VkDescriptorSetLayout ds_layout; |
| 8134 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8135 | &ds_layout); |
| 8136 | ASSERT_VK_SUCCESS(err); |
| 8137 | |
| 8138 | VkDescriptorSet descriptorSet; |
| 8139 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8140 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8141 | alloc_info.descriptorSetCount = 1; |
| 8142 | alloc_info.descriptorPool = ds_pool; |
| 8143 | alloc_info.pSetLayouts = &ds_layout; |
| 8144 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8145 | &descriptorSet); |
| 8146 | ASSERT_VK_SUCCESS(err); |
| 8147 | |
| 8148 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8149 | pipe_ms_state_ci.sType = |
| 8150 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8151 | pipe_ms_state_ci.pNext = NULL; |
| 8152 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8153 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8154 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8155 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8156 | |
| 8157 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8158 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8159 | pipeline_layout_ci.pNext = NULL; |
| 8160 | pipeline_layout_ci.setLayoutCount = 1; |
| 8161 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8162 | |
| 8163 | VkPipelineLayout pipeline_layout; |
| 8164 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8165 | &pipeline_layout); |
| 8166 | ASSERT_VK_SUCCESS(err); |
| 8167 | |
| 8168 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8169 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8170 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8171 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8172 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8173 | // but add it to be able to run on more devices |
| 8174 | VkPipelineObj pipe(m_device); |
| 8175 | pipe.AddShader(&vs); |
| 8176 | pipe.AddShader(&fs); |
| 8177 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8178 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8179 | |
| 8180 | BeginCommandBuffer(); |
| 8181 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8182 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8183 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8184 | // Render triangle (the error should trigger on the attempt to draw). |
| 8185 | Draw(3, 1, 0, 0); |
| 8186 | |
| 8187 | // Finalize recording of the command buffer |
| 8188 | EndCommandBuffer(); |
| 8189 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8190 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8191 | |
| 8192 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8193 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8194 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8195 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8197 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8198 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8199 | // to issuing a Draw |
| 8200 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8201 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8202 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8203 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8204 | "vkCmdClearAttachments() issued on CB object "); |
| 8205 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8206 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8208 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8209 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8210 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8211 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8212 | |
| 8213 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8214 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8215 | ds_pool_ci.pNext = NULL; |
| 8216 | ds_pool_ci.maxSets = 1; |
| 8217 | ds_pool_ci.poolSizeCount = 1; |
| 8218 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8219 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8220 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8221 | err = |
| 8222 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8223 | ASSERT_VK_SUCCESS(err); |
| 8224 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8225 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8226 | dsl_binding.binding = 0; |
| 8227 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8228 | dsl_binding.descriptorCount = 1; |
| 8229 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8230 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8231 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8232 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8233 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8234 | ds_layout_ci.pNext = NULL; |
| 8235 | ds_layout_ci.bindingCount = 1; |
| 8236 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8237 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8238 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8239 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8240 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8241 | ASSERT_VK_SUCCESS(err); |
| 8242 | |
| 8243 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8244 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8245 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8246 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8247 | alloc_info.descriptorPool = ds_pool; |
| 8248 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8249 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8250 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8251 | ASSERT_VK_SUCCESS(err); |
| 8252 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8253 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8254 | pipe_ms_state_ci.sType = |
| 8255 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8256 | pipe_ms_state_ci.pNext = NULL; |
| 8257 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8258 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8259 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8260 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8261 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8262 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8263 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8264 | pipeline_layout_ci.pNext = NULL; |
| 8265 | pipeline_layout_ci.setLayoutCount = 1; |
| 8266 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8267 | |
| 8268 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8269 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8270 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8271 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8273 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8274 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8275 | // 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] | 8276 | // on more devices |
| 8277 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8278 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8279 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8280 | VkPipelineObj pipe(m_device); |
| 8281 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8282 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8283 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8284 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8285 | |
| 8286 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8287 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8288 | // Main thing we care about for this test is that the VkImage obj we're |
| 8289 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8290 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8291 | VkClearAttachment color_attachment; |
| 8292 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8293 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8294 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8295 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8296 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8297 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8298 | VkClearRect clear_rect = { |
| 8299 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8301 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8302 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8303 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8304 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8305 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8306 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8307 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8308 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8309 | } |
| 8310 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8311 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8312 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8314 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8315 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8316 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8317 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8319 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8320 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8321 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8322 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8323 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8324 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8325 | |
| 8326 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8327 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8328 | ds_pool_ci.pNext = NULL; |
| 8329 | ds_pool_ci.maxSets = 1; |
| 8330 | ds_pool_ci.poolSizeCount = 1; |
| 8331 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8332 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8333 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8334 | err = |
| 8335 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8336 | ASSERT_VK_SUCCESS(err); |
| 8337 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8338 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8339 | dsl_binding.binding = 0; |
| 8340 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8341 | dsl_binding.descriptorCount = 1; |
| 8342 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8343 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8344 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8345 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8346 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8347 | ds_layout_ci.pNext = NULL; |
| 8348 | ds_layout_ci.bindingCount = 1; |
| 8349 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8350 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8351 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8352 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8353 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8354 | ASSERT_VK_SUCCESS(err); |
| 8355 | |
| 8356 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8357 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8358 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8359 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8360 | alloc_info.descriptorPool = ds_pool; |
| 8361 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8363 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8364 | ASSERT_VK_SUCCESS(err); |
| 8365 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8366 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8367 | pipe_ms_state_ci.sType = |
| 8368 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8369 | pipe_ms_state_ci.pNext = NULL; |
| 8370 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8371 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8372 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8373 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8374 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8375 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8376 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8377 | pipeline_layout_ci.pNext = NULL; |
| 8378 | pipeline_layout_ci.setLayoutCount = 1; |
| 8379 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8380 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8382 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8383 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8384 | ASSERT_VK_SUCCESS(err); |
| 8385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8386 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8387 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8388 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8389 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8390 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8391 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8392 | VkPipelineObj pipe(m_device); |
| 8393 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8394 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8395 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8396 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8397 | pipe.SetViewport(m_viewports); |
| 8398 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8399 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8400 | |
| 8401 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8402 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8403 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8404 | // Don't care about actual data, just need to get to draw to flag error |
| 8405 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8406 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8407 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8408 | 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] | 8409 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8410 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8411 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8412 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8413 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8414 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8415 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8416 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8417 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8418 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8419 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8420 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8421 | "images in the wrong layout when they're copied or transitioned."); |
| 8422 | // 3 in ValidateCmdBufImageLayouts |
| 8423 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8424 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8425 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8426 | m_errorMonitor->SetDesiredFailureMsg( |
| 8427 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8428 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8429 | |
| 8430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8431 | // Create src & dst images to use for copy operations |
| 8432 | VkImage src_image; |
| 8433 | VkImage dst_image; |
| 8434 | |
| 8435 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8436 | const int32_t tex_width = 32; |
| 8437 | const int32_t tex_height = 32; |
| 8438 | |
| 8439 | VkImageCreateInfo image_create_info = {}; |
| 8440 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8441 | image_create_info.pNext = NULL; |
| 8442 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8443 | image_create_info.format = tex_format; |
| 8444 | image_create_info.extent.width = tex_width; |
| 8445 | image_create_info.extent.height = tex_height; |
| 8446 | image_create_info.extent.depth = 1; |
| 8447 | image_create_info.mipLevels = 1; |
| 8448 | image_create_info.arrayLayers = 4; |
| 8449 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8450 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8451 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8452 | image_create_info.flags = 0; |
| 8453 | |
| 8454 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8455 | ASSERT_VK_SUCCESS(err); |
| 8456 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8457 | ASSERT_VK_SUCCESS(err); |
| 8458 | |
| 8459 | BeginCommandBuffer(); |
| 8460 | VkImageCopy copyRegion; |
| 8461 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8462 | copyRegion.srcSubresource.mipLevel = 0; |
| 8463 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8464 | copyRegion.srcSubresource.layerCount = 1; |
| 8465 | copyRegion.srcOffset.x = 0; |
| 8466 | copyRegion.srcOffset.y = 0; |
| 8467 | copyRegion.srcOffset.z = 0; |
| 8468 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8469 | copyRegion.dstSubresource.mipLevel = 0; |
| 8470 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8471 | copyRegion.dstSubresource.layerCount = 1; |
| 8472 | copyRegion.dstOffset.x = 0; |
| 8473 | copyRegion.dstOffset.y = 0; |
| 8474 | copyRegion.dstOffset.z = 0; |
| 8475 | copyRegion.extent.width = 1; |
| 8476 | copyRegion.extent.height = 1; |
| 8477 | copyRegion.extent.depth = 1; |
| 8478 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8479 | m_errorMonitor->VerifyFound(); |
| 8480 | // Now cause error due to src image layout changing |
| 8481 | m_errorMonitor->SetDesiredFailureMsg( |
| 8482 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8483 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8484 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8485 | m_errorMonitor->VerifyFound(); |
| 8486 | // Final src error is due to bad layout type |
| 8487 | m_errorMonitor->SetDesiredFailureMsg( |
| 8488 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8489 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8490 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8491 | m_errorMonitor->VerifyFound(); |
| 8492 | // Now verify same checks for dst |
| 8493 | m_errorMonitor->SetDesiredFailureMsg( |
| 8494 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8495 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8496 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8497 | m_errorMonitor->VerifyFound(); |
| 8498 | // Now cause error due to src image layout changing |
| 8499 | m_errorMonitor->SetDesiredFailureMsg( |
| 8500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8501 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8502 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8503 | m_errorMonitor->VerifyFound(); |
| 8504 | m_errorMonitor->SetDesiredFailureMsg( |
| 8505 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8506 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8507 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8508 | m_errorMonitor->VerifyFound(); |
| 8509 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8510 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8511 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8512 | image_barrier[0].image = src_image; |
| 8513 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8514 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8515 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8516 | m_errorMonitor->SetDesiredFailureMsg( |
| 8517 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8518 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8519 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8520 | m_errorMonitor->VerifyFound(); |
| 8521 | |
| 8522 | // Finally some layout errors at RenderPass create time |
| 8523 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8524 | VkAttachmentReference attach = {}; |
| 8525 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8526 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8527 | VkSubpassDescription subpass = {}; |
| 8528 | subpass.inputAttachmentCount = 1; |
| 8529 | subpass.pInputAttachments = &attach; |
| 8530 | VkRenderPassCreateInfo rpci = {}; |
| 8531 | rpci.subpassCount = 1; |
| 8532 | rpci.pSubpasses = &subpass; |
| 8533 | rpci.attachmentCount = 1; |
| 8534 | VkAttachmentDescription attach_desc = {}; |
| 8535 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8536 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8537 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8538 | VkRenderPass rp; |
| 8539 | m_errorMonitor->SetDesiredFailureMsg( |
| 8540 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8541 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8542 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8543 | m_errorMonitor->VerifyFound(); |
| 8544 | // error w/ non-general layout |
| 8545 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8546 | |
| 8547 | m_errorMonitor->SetDesiredFailureMsg( |
| 8548 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8549 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8550 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8551 | m_errorMonitor->VerifyFound(); |
| 8552 | subpass.inputAttachmentCount = 0; |
| 8553 | subpass.colorAttachmentCount = 1; |
| 8554 | subpass.pColorAttachments = &attach; |
| 8555 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8556 | // perf warning for GENERAL layout on color attachment |
| 8557 | m_errorMonitor->SetDesiredFailureMsg( |
| 8558 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8559 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8560 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8561 | m_errorMonitor->VerifyFound(); |
| 8562 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8563 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8564 | m_errorMonitor->SetDesiredFailureMsg( |
| 8565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8566 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8567 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8568 | m_errorMonitor->VerifyFound(); |
| 8569 | subpass.colorAttachmentCount = 0; |
| 8570 | subpass.pDepthStencilAttachment = &attach; |
| 8571 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8572 | // perf warning for GENERAL layout on DS attachment |
| 8573 | m_errorMonitor->SetDesiredFailureMsg( |
| 8574 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8575 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8576 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8577 | m_errorMonitor->VerifyFound(); |
| 8578 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8579 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8580 | m_errorMonitor->SetDesiredFailureMsg( |
| 8581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8582 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8583 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8584 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8585 | // For this error we need a valid renderpass so create default one |
| 8586 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8587 | attach.attachment = 0; |
| 8588 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8589 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8590 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8591 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8592 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8593 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8594 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8595 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8596 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8597 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8598 | " with invalid first layout " |
| 8599 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8600 | "ONLY_OPTIMAL"); |
| 8601 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8602 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8603 | |
| 8604 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8605 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8606 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8607 | #endif // DRAW_STATE_TESTS |
| 8608 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8609 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8610 | #if GTEST_IS_THREADSAFE |
| 8611 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8612 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8613 | VkEvent event; |
| 8614 | bool bailout; |
| 8615 | }; |
| 8616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8617 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8618 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8619 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8620 | for (int i = 0; i < 10000; i++) { |
| 8621 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8622 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8623 | if (data->bailout) { |
| 8624 | break; |
| 8625 | } |
| 8626 | } |
| 8627 | return NULL; |
| 8628 | } |
| 8629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8630 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8631 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8633 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8634 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8635 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8636 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8637 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8639 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8640 | // Calls AllocateCommandBuffers |
| 8641 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8642 | |
| 8643 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8644 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8645 | |
| 8646 | VkEventCreateInfo event_info; |
| 8647 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8648 | VkResult err; |
| 8649 | |
| 8650 | memset(&event_info, 0, sizeof(event_info)); |
| 8651 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8652 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8653 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8654 | ASSERT_VK_SUCCESS(err); |
| 8655 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8656 | err = vkResetEvent(device(), event); |
| 8657 | ASSERT_VK_SUCCESS(err); |
| 8658 | |
| 8659 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8660 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8661 | data.event = event; |
| 8662 | data.bailout = false; |
| 8663 | m_errorMonitor->SetBailout(&data.bailout); |
| 8664 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8665 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8666 | // Add many entries to command buffer from this thread at the same time. |
| 8667 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8668 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8669 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8670 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8671 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8672 | m_errorMonitor->SetBailout(NULL); |
| 8673 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8674 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8675 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8676 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8677 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8678 | #endif // GTEST_IS_THREADSAFE |
| 8679 | #endif // THREADING_TESTS |
| 8680 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8681 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8682 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8684 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8685 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8687 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8688 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8689 | VkShaderModule module; |
| 8690 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8691 | struct icd_spv_header spv; |
| 8692 | |
| 8693 | spv.magic = ICD_SPV_MAGIC; |
| 8694 | spv.version = ICD_SPV_VERSION; |
| 8695 | spv.gen_magic = 0; |
| 8696 | |
| 8697 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8698 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8699 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8700 | moduleCreateInfo.codeSize = 4; |
| 8701 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8702 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8703 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8704 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8705 | } |
| 8706 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8707 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8708 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8709 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8710 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8711 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8712 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8713 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8714 | VkShaderModule module; |
| 8715 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8716 | struct icd_spv_header spv; |
| 8717 | |
| 8718 | spv.magic = ~ICD_SPV_MAGIC; |
| 8719 | spv.version = ICD_SPV_VERSION; |
| 8720 | spv.gen_magic = 0; |
| 8721 | |
| 8722 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8723 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8724 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8725 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8726 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8727 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8728 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8729 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8730 | } |
| 8731 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8732 | #if 0 |
| 8733 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8734 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8735 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8736 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8737 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8738 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8739 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8740 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8741 | VkShaderModule module; |
| 8742 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8743 | struct icd_spv_header spv; |
| 8744 | |
| 8745 | spv.magic = ICD_SPV_MAGIC; |
| 8746 | spv.version = ~ICD_SPV_VERSION; |
| 8747 | spv.gen_magic = 0; |
| 8748 | |
| 8749 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8750 | moduleCreateInfo.pNext = NULL; |
| 8751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8752 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8753 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8754 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8755 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8756 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8757 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8758 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8759 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8761 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8762 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8763 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8764 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8766 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8767 | |
| 8768 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8769 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8770 | "\n" |
| 8771 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8772 | "out gl_PerVertex {\n" |
| 8773 | " vec4 gl_Position;\n" |
| 8774 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8775 | "void main(){\n" |
| 8776 | " gl_Position = vec4(1);\n" |
| 8777 | " x = 0;\n" |
| 8778 | "}\n"; |
| 8779 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8780 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8781 | "\n" |
| 8782 | "layout(location=0) out vec4 color;\n" |
| 8783 | "void main(){\n" |
| 8784 | " color = vec4(1);\n" |
| 8785 | "}\n"; |
| 8786 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8787 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8788 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8789 | |
| 8790 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8791 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8792 | pipe.AddShader(&vs); |
| 8793 | pipe.AddShader(&fs); |
| 8794 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8795 | VkDescriptorSetObj descriptorSet(m_device); |
| 8796 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8797 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8798 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8799 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8800 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8801 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8802 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8803 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8804 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8805 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8806 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8807 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8809 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8810 | |
| 8811 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8812 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8813 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8814 | "out gl_PerVertex {\n" |
| 8815 | " vec4 gl_Position;\n" |
| 8816 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8817 | "void main(){\n" |
| 8818 | " gl_Position = vec4(1);\n" |
| 8819 | "}\n"; |
| 8820 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8821 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8822 | "\n" |
| 8823 | "layout(location=0) in float x;\n" |
| 8824 | "layout(location=0) out vec4 color;\n" |
| 8825 | "void main(){\n" |
| 8826 | " color = vec4(x);\n" |
| 8827 | "}\n"; |
| 8828 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8829 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8830 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8831 | |
| 8832 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8833 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8834 | pipe.AddShader(&vs); |
| 8835 | pipe.AddShader(&fs); |
| 8836 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8837 | VkDescriptorSetObj descriptorSet(m_device); |
| 8838 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8839 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8840 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8841 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8842 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8843 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8844 | } |
| 8845 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8846 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8847 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8848 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8849 | |
| 8850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8851 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8852 | |
| 8853 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8854 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8855 | "\n" |
| 8856 | "out gl_PerVertex {\n" |
| 8857 | " vec4 gl_Position;\n" |
| 8858 | "};\n" |
| 8859 | "void main(){\n" |
| 8860 | " gl_Position = vec4(1);\n" |
| 8861 | "}\n"; |
| 8862 | char const *fsSource = |
| 8863 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8864 | "\n" |
| 8865 | "in block { layout(location=0) float x; } ins;\n" |
| 8866 | "layout(location=0) out vec4 color;\n" |
| 8867 | "void main(){\n" |
| 8868 | " color = vec4(ins.x);\n" |
| 8869 | "}\n"; |
| 8870 | |
| 8871 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8872 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8873 | |
| 8874 | VkPipelineObj pipe(m_device); |
| 8875 | pipe.AddColorAttachment(); |
| 8876 | pipe.AddShader(&vs); |
| 8877 | pipe.AddShader(&fs); |
| 8878 | |
| 8879 | VkDescriptorSetObj descriptorSet(m_device); |
| 8880 | descriptorSet.AppendDummy(); |
| 8881 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8882 | |
| 8883 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8884 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8885 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8886 | } |
| 8887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8888 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8890 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8891 | "output arr[2] of float32' vs 'ptr to " |
| 8892 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8893 | |
| 8894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8895 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8896 | |
| 8897 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8898 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8899 | "\n" |
| 8900 | "layout(location=0) out float x[2];\n" |
| 8901 | "out gl_PerVertex {\n" |
| 8902 | " vec4 gl_Position;\n" |
| 8903 | "};\n" |
| 8904 | "void main(){\n" |
| 8905 | " x[0] = 0; x[1] = 0;\n" |
| 8906 | " gl_Position = vec4(1);\n" |
| 8907 | "}\n"; |
| 8908 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8909 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8910 | "\n" |
| 8911 | "layout(location=0) in float x[3];\n" |
| 8912 | "layout(location=0) out vec4 color;\n" |
| 8913 | "void main(){\n" |
| 8914 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8915 | "}\n"; |
| 8916 | |
| 8917 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8918 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8919 | |
| 8920 | VkPipelineObj pipe(m_device); |
| 8921 | pipe.AddColorAttachment(); |
| 8922 | pipe.AddShader(&vs); |
| 8923 | pipe.AddShader(&fs); |
| 8924 | |
| 8925 | VkDescriptorSetObj descriptorSet(m_device); |
| 8926 | descriptorSet.AppendDummy(); |
| 8927 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8928 | |
| 8929 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8930 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8931 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8932 | } |
| 8933 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8934 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8935 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8936 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8937 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8938 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8939 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8940 | |
| 8941 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8942 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8943 | "\n" |
| 8944 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8945 | "out gl_PerVertex {\n" |
| 8946 | " vec4 gl_Position;\n" |
| 8947 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8948 | "void main(){\n" |
| 8949 | " x = 0;\n" |
| 8950 | " gl_Position = vec4(1);\n" |
| 8951 | "}\n"; |
| 8952 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8953 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8954 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8955 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8956 | "layout(location=0) out vec4 color;\n" |
| 8957 | "void main(){\n" |
| 8958 | " color = vec4(x);\n" |
| 8959 | "}\n"; |
| 8960 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8961 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8962 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8963 | |
| 8964 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8965 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8966 | pipe.AddShader(&vs); |
| 8967 | pipe.AddShader(&fs); |
| 8968 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8969 | VkDescriptorSetObj descriptorSet(m_device); |
| 8970 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8971 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8972 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8973 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8974 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8975 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8976 | } |
| 8977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8978 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8979 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8980 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8981 | |
| 8982 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8983 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8984 | |
| 8985 | char const *vsSource = |
| 8986 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8987 | "\n" |
| 8988 | "out block { layout(location=0) int x; } outs;\n" |
| 8989 | "out gl_PerVertex {\n" |
| 8990 | " vec4 gl_Position;\n" |
| 8991 | "};\n" |
| 8992 | "void main(){\n" |
| 8993 | " outs.x = 0;\n" |
| 8994 | " gl_Position = vec4(1);\n" |
| 8995 | "}\n"; |
| 8996 | char const *fsSource = |
| 8997 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8998 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8999 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9000 | "layout(location=0) out vec4 color;\n" |
| 9001 | "void main(){\n" |
| 9002 | " color = vec4(ins.x);\n" |
| 9003 | "}\n"; |
| 9004 | |
| 9005 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9006 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9007 | |
| 9008 | VkPipelineObj pipe(m_device); |
| 9009 | pipe.AddColorAttachment(); |
| 9010 | pipe.AddShader(&vs); |
| 9011 | pipe.AddShader(&fs); |
| 9012 | |
| 9013 | VkDescriptorSetObj descriptorSet(m_device); |
| 9014 | descriptorSet.AppendDummy(); |
| 9015 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9016 | |
| 9017 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9018 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9019 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9020 | } |
| 9021 | |
| 9022 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9023 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9024 | "location 0.0 which is not written by vertex shader"); |
| 9025 | |
| 9026 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9027 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9028 | |
| 9029 | char const *vsSource = |
| 9030 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9031 | "\n" |
| 9032 | "out block { layout(location=1) float x; } outs;\n" |
| 9033 | "out gl_PerVertex {\n" |
| 9034 | " vec4 gl_Position;\n" |
| 9035 | "};\n" |
| 9036 | "void main(){\n" |
| 9037 | " outs.x = 0;\n" |
| 9038 | " gl_Position = vec4(1);\n" |
| 9039 | "}\n"; |
| 9040 | char const *fsSource = |
| 9041 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9042 | "\n" |
| 9043 | "in block { layout(location=0) float x; } ins;\n" |
| 9044 | "layout(location=0) out vec4 color;\n" |
| 9045 | "void main(){\n" |
| 9046 | " color = vec4(ins.x);\n" |
| 9047 | "}\n"; |
| 9048 | |
| 9049 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9050 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9051 | |
| 9052 | VkPipelineObj pipe(m_device); |
| 9053 | pipe.AddColorAttachment(); |
| 9054 | pipe.AddShader(&vs); |
| 9055 | pipe.AddShader(&fs); |
| 9056 | |
| 9057 | VkDescriptorSetObj descriptorSet(m_device); |
| 9058 | descriptorSet.AppendDummy(); |
| 9059 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9060 | |
| 9061 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9062 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9063 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9064 | } |
| 9065 | |
| 9066 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9067 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9068 | "location 0.1 which is not written by vertex shader"); |
| 9069 | |
| 9070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9071 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9072 | |
| 9073 | char const *vsSource = |
| 9074 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9075 | "\n" |
| 9076 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9077 | "out gl_PerVertex {\n" |
| 9078 | " vec4 gl_Position;\n" |
| 9079 | "};\n" |
| 9080 | "void main(){\n" |
| 9081 | " outs.x = 0;\n" |
| 9082 | " gl_Position = vec4(1);\n" |
| 9083 | "}\n"; |
| 9084 | char const *fsSource = |
| 9085 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9086 | "\n" |
| 9087 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9088 | "layout(location=0) out vec4 color;\n" |
| 9089 | "void main(){\n" |
| 9090 | " color = vec4(ins.x);\n" |
| 9091 | "}\n"; |
| 9092 | |
| 9093 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9094 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9095 | |
| 9096 | VkPipelineObj pipe(m_device); |
| 9097 | pipe.AddColorAttachment(); |
| 9098 | pipe.AddShader(&vs); |
| 9099 | pipe.AddShader(&fs); |
| 9100 | |
| 9101 | VkDescriptorSetObj descriptorSet(m_device); |
| 9102 | descriptorSet.AppendDummy(); |
| 9103 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9104 | |
| 9105 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9106 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9107 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9108 | } |
| 9109 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9110 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9111 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9112 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9113 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9114 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9115 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9116 | |
| 9117 | VkVertexInputBindingDescription input_binding; |
| 9118 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9119 | |
| 9120 | VkVertexInputAttributeDescription input_attrib; |
| 9121 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9122 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9123 | |
| 9124 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9125 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9126 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9127 | "out gl_PerVertex {\n" |
| 9128 | " vec4 gl_Position;\n" |
| 9129 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9130 | "void main(){\n" |
| 9131 | " gl_Position = vec4(1);\n" |
| 9132 | "}\n"; |
| 9133 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9134 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9135 | "\n" |
| 9136 | "layout(location=0) out vec4 color;\n" |
| 9137 | "void main(){\n" |
| 9138 | " color = vec4(1);\n" |
| 9139 | "}\n"; |
| 9140 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9141 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9142 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9143 | |
| 9144 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9145 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9146 | pipe.AddShader(&vs); |
| 9147 | pipe.AddShader(&fs); |
| 9148 | |
| 9149 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9150 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9151 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9152 | VkDescriptorSetObj descriptorSet(m_device); |
| 9153 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9154 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9155 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9156 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9157 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9158 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9159 | } |
| 9160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9161 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9163 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9164 | |
| 9165 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9166 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9167 | |
| 9168 | VkVertexInputBindingDescription input_binding; |
| 9169 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9170 | |
| 9171 | VkVertexInputAttributeDescription input_attrib; |
| 9172 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9173 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9174 | |
| 9175 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9176 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9177 | "\n" |
| 9178 | "layout(location=1) in float x;\n" |
| 9179 | "out gl_PerVertex {\n" |
| 9180 | " vec4 gl_Position;\n" |
| 9181 | "};\n" |
| 9182 | "void main(){\n" |
| 9183 | " gl_Position = vec4(x);\n" |
| 9184 | "}\n"; |
| 9185 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9186 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9187 | "\n" |
| 9188 | "layout(location=0) out vec4 color;\n" |
| 9189 | "void main(){\n" |
| 9190 | " color = vec4(1);\n" |
| 9191 | "}\n"; |
| 9192 | |
| 9193 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9194 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9195 | |
| 9196 | VkPipelineObj pipe(m_device); |
| 9197 | pipe.AddColorAttachment(); |
| 9198 | pipe.AddShader(&vs); |
| 9199 | pipe.AddShader(&fs); |
| 9200 | |
| 9201 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9202 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9203 | |
| 9204 | VkDescriptorSetObj descriptorSet(m_device); |
| 9205 | descriptorSet.AppendDummy(); |
| 9206 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9207 | |
| 9208 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9209 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9210 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9211 | } |
| 9212 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9213 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9214 | m_errorMonitor->SetDesiredFailureMsg( |
| 9215 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9216 | "VS consumes input at location 0 but not provided"); |
| 9217 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9218 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9219 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9220 | |
| 9221 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9222 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9223 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9224 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9225 | "out gl_PerVertex {\n" |
| 9226 | " vec4 gl_Position;\n" |
| 9227 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9228 | "void main(){\n" |
| 9229 | " gl_Position = x;\n" |
| 9230 | "}\n"; |
| 9231 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9232 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9233 | "\n" |
| 9234 | "layout(location=0) out vec4 color;\n" |
| 9235 | "void main(){\n" |
| 9236 | " color = vec4(1);\n" |
| 9237 | "}\n"; |
| 9238 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9239 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9240 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9241 | |
| 9242 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9243 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9244 | pipe.AddShader(&vs); |
| 9245 | pipe.AddShader(&fs); |
| 9246 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9247 | VkDescriptorSetObj descriptorSet(m_device); |
| 9248 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9249 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9250 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9251 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9252 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9253 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9254 | } |
| 9255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9256 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9257 | m_errorMonitor->SetDesiredFailureMsg( |
| 9258 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9259 | "location 0 does not match VS input type"); |
| 9260 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9261 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9262 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9263 | |
| 9264 | VkVertexInputBindingDescription input_binding; |
| 9265 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9266 | |
| 9267 | VkVertexInputAttributeDescription input_attrib; |
| 9268 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9269 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9270 | |
| 9271 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9272 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9273 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9274 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9275 | "out gl_PerVertex {\n" |
| 9276 | " vec4 gl_Position;\n" |
| 9277 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9278 | "void main(){\n" |
| 9279 | " gl_Position = vec4(x);\n" |
| 9280 | "}\n"; |
| 9281 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9282 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9283 | "\n" |
| 9284 | "layout(location=0) out vec4 color;\n" |
| 9285 | "void main(){\n" |
| 9286 | " color = vec4(1);\n" |
| 9287 | "}\n"; |
| 9288 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9289 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9290 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9291 | |
| 9292 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9293 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9294 | pipe.AddShader(&vs); |
| 9295 | pipe.AddShader(&fs); |
| 9296 | |
| 9297 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9298 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9299 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9300 | VkDescriptorSetObj descriptorSet(m_device); |
| 9301 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9302 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9303 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9304 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9305 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9306 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9307 | } |
| 9308 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9309 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9310 | m_errorMonitor->SetDesiredFailureMsg( |
| 9311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9312 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9313 | |
| 9314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9315 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9316 | |
| 9317 | char const *vsSource = |
| 9318 | "#version 450\n" |
| 9319 | "\n" |
| 9320 | "out gl_PerVertex {\n" |
| 9321 | " vec4 gl_Position;\n" |
| 9322 | "};\n" |
| 9323 | "void main(){\n" |
| 9324 | " gl_Position = vec4(1);\n" |
| 9325 | "}\n"; |
| 9326 | char const *fsSource = |
| 9327 | "#version 450\n" |
| 9328 | "\n" |
| 9329 | "layout(location=0) out vec4 color;\n" |
| 9330 | "void main(){\n" |
| 9331 | " color = vec4(1);\n" |
| 9332 | "}\n"; |
| 9333 | |
| 9334 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9335 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9336 | |
| 9337 | VkPipelineObj pipe(m_device); |
| 9338 | pipe.AddColorAttachment(); |
| 9339 | pipe.AddShader(&vs); |
| 9340 | pipe.AddShader(&vs); |
| 9341 | pipe.AddShader(&fs); |
| 9342 | |
| 9343 | VkDescriptorSetObj descriptorSet(m_device); |
| 9344 | descriptorSet.AppendDummy(); |
| 9345 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9346 | |
| 9347 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9348 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9349 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9350 | } |
| 9351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9352 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9353 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9354 | |
| 9355 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9356 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9357 | |
| 9358 | VkVertexInputBindingDescription input_binding; |
| 9359 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9360 | |
| 9361 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9362 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9363 | |
| 9364 | for (int i = 0; i < 2; i++) { |
| 9365 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9366 | input_attribs[i].location = i; |
| 9367 | } |
| 9368 | |
| 9369 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9370 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9371 | "\n" |
| 9372 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9373 | "out gl_PerVertex {\n" |
| 9374 | " vec4 gl_Position;\n" |
| 9375 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9376 | "void main(){\n" |
| 9377 | " gl_Position = x[0] + x[1];\n" |
| 9378 | "}\n"; |
| 9379 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9380 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9381 | "\n" |
| 9382 | "layout(location=0) out vec4 color;\n" |
| 9383 | "void main(){\n" |
| 9384 | " color = vec4(1);\n" |
| 9385 | "}\n"; |
| 9386 | |
| 9387 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9388 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9389 | |
| 9390 | VkPipelineObj pipe(m_device); |
| 9391 | pipe.AddColorAttachment(); |
| 9392 | pipe.AddShader(&vs); |
| 9393 | pipe.AddShader(&fs); |
| 9394 | |
| 9395 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9396 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9397 | |
| 9398 | VkDescriptorSetObj descriptorSet(m_device); |
| 9399 | descriptorSet.AppendDummy(); |
| 9400 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9401 | |
| 9402 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9403 | |
| 9404 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9405 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9406 | } |
| 9407 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9408 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9409 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9410 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9411 | |
| 9412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9413 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9414 | |
| 9415 | VkVertexInputBindingDescription input_binding; |
| 9416 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9417 | |
| 9418 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9419 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9420 | |
| 9421 | for (int i = 0; i < 2; i++) { |
| 9422 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9423 | input_attribs[i].location = i; |
| 9424 | } |
| 9425 | |
| 9426 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9427 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9428 | "\n" |
| 9429 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9430 | "out gl_PerVertex {\n" |
| 9431 | " vec4 gl_Position;\n" |
| 9432 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9433 | "void main(){\n" |
| 9434 | " gl_Position = x[0] + x[1];\n" |
| 9435 | "}\n"; |
| 9436 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9437 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9438 | "\n" |
| 9439 | "layout(location=0) out vec4 color;\n" |
| 9440 | "void main(){\n" |
| 9441 | " color = vec4(1);\n" |
| 9442 | "}\n"; |
| 9443 | |
| 9444 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9445 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9446 | |
| 9447 | VkPipelineObj pipe(m_device); |
| 9448 | pipe.AddColorAttachment(); |
| 9449 | pipe.AddShader(&vs); |
| 9450 | pipe.AddShader(&fs); |
| 9451 | |
| 9452 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9453 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9454 | |
| 9455 | VkDescriptorSetObj descriptorSet(m_device); |
| 9456 | descriptorSet.AppendDummy(); |
| 9457 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9458 | |
| 9459 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9460 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9461 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9462 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9463 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9464 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9465 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9466 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9467 | |
| 9468 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9469 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9470 | |
| 9471 | char const *vsSource = |
| 9472 | "#version 450\n" |
| 9473 | "out gl_PerVertex {\n" |
| 9474 | " vec4 gl_Position;\n" |
| 9475 | "};\n" |
| 9476 | "void main(){\n" |
| 9477 | " gl_Position = vec4(0);\n" |
| 9478 | "}\n"; |
| 9479 | char const *fsSource = |
| 9480 | "#version 450\n" |
| 9481 | "\n" |
| 9482 | "layout(location=0) out vec4 color;\n" |
| 9483 | "void main(){\n" |
| 9484 | " color = vec4(1);\n" |
| 9485 | "}\n"; |
| 9486 | |
| 9487 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9488 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9489 | |
| 9490 | VkPipelineObj pipe(m_device); |
| 9491 | pipe.AddColorAttachment(); |
| 9492 | pipe.AddShader(&vs); |
| 9493 | pipe.AddShader(&fs); |
| 9494 | |
| 9495 | VkDescriptorSetObj descriptorSet(m_device); |
| 9496 | descriptorSet.AppendDummy(); |
| 9497 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9498 | |
| 9499 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9500 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9501 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9502 | } |
| 9503 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9504 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9505 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9506 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9507 | |
| 9508 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9509 | |
| 9510 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9511 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9512 | |
| 9513 | char const *vsSource = |
| 9514 | "#version 450\n" |
| 9515 | "out gl_PerVertex {\n" |
| 9516 | " vec4 gl_Position;\n" |
| 9517 | "};\n" |
| 9518 | "layout(location=0) out vec3 x;\n" |
| 9519 | "layout(location=1) out ivec3 y;\n" |
| 9520 | "layout(location=2) out vec3 z;\n" |
| 9521 | "void main(){\n" |
| 9522 | " gl_Position = vec4(0);\n" |
| 9523 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9524 | "}\n"; |
| 9525 | char const *fsSource = |
| 9526 | "#version 450\n" |
| 9527 | "\n" |
| 9528 | "layout(location=0) out vec4 color;\n" |
| 9529 | "layout(location=0) in float x;\n" |
| 9530 | "layout(location=1) flat in int y;\n" |
| 9531 | "layout(location=2) in vec2 z;\n" |
| 9532 | "void main(){\n" |
| 9533 | " color = vec4(1 + x + y + z.x);\n" |
| 9534 | "}\n"; |
| 9535 | |
| 9536 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9537 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9538 | |
| 9539 | VkPipelineObj pipe(m_device); |
| 9540 | pipe.AddColorAttachment(); |
| 9541 | pipe.AddShader(&vs); |
| 9542 | pipe.AddShader(&fs); |
| 9543 | |
| 9544 | VkDescriptorSetObj descriptorSet(m_device); |
| 9545 | descriptorSet.AppendDummy(); |
| 9546 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9547 | |
| 9548 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9549 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9550 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9551 | } |
| 9552 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9553 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9554 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9555 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9556 | |
| 9557 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9558 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9559 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9560 | if (!m_device->phy().features().tessellationShader) { |
| 9561 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9562 | return; |
| 9563 | } |
| 9564 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9565 | char const *vsSource = |
| 9566 | "#version 450\n" |
| 9567 | "void main(){}\n"; |
| 9568 | char const *tcsSource = |
| 9569 | "#version 450\n" |
| 9570 | "layout(location=0) out int x[];\n" |
| 9571 | "layout(vertices=3) out;\n" |
| 9572 | "void main(){\n" |
| 9573 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9574 | " gl_TessLevelInner[0] = 1;\n" |
| 9575 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9576 | "}\n"; |
| 9577 | char const *tesSource = |
| 9578 | "#version 450\n" |
| 9579 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9580 | "layout(location=0) in int x[];\n" |
| 9581 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9582 | "void main(){\n" |
| 9583 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9584 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9585 | "}\n"; |
| 9586 | char const *fsSource = |
| 9587 | "#version 450\n" |
| 9588 | "layout(location=0) out vec4 color;\n" |
| 9589 | "void main(){\n" |
| 9590 | " color = vec4(1);\n" |
| 9591 | "}\n"; |
| 9592 | |
| 9593 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9594 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9595 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9596 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9597 | |
| 9598 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9599 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9600 | nullptr, |
| 9601 | 0, |
| 9602 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9603 | VK_FALSE}; |
| 9604 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9605 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9606 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9607 | nullptr, |
| 9608 | 0, |
| 9609 | 3}; |
| 9610 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9611 | VkPipelineObj pipe(m_device); |
| 9612 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9613 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9614 | pipe.AddColorAttachment(); |
| 9615 | pipe.AddShader(&vs); |
| 9616 | pipe.AddShader(&tcs); |
| 9617 | pipe.AddShader(&tes); |
| 9618 | pipe.AddShader(&fs); |
| 9619 | |
| 9620 | VkDescriptorSetObj descriptorSet(m_device); |
| 9621 | descriptorSet.AppendDummy(); |
| 9622 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9623 | |
| 9624 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9625 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9626 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9627 | } |
| 9628 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9629 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9630 | { |
| 9631 | m_errorMonitor->ExpectSuccess(); |
| 9632 | |
| 9633 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9634 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9635 | |
| 9636 | if (!m_device->phy().features().geometryShader) { |
| 9637 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9638 | return; |
| 9639 | } |
| 9640 | |
| 9641 | char const *vsSource = |
| 9642 | "#version 450\n" |
| 9643 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9644 | "void main(){\n" |
| 9645 | " vs_out.x = vec4(1);\n" |
| 9646 | "}\n"; |
| 9647 | char const *gsSource = |
| 9648 | "#version 450\n" |
| 9649 | "layout(triangles) in;\n" |
| 9650 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9651 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9652 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9653 | "void main() {\n" |
| 9654 | " gl_Position = gs_in[0].x;\n" |
| 9655 | " EmitVertex();\n" |
| 9656 | "}\n"; |
| 9657 | char const *fsSource = |
| 9658 | "#version 450\n" |
| 9659 | "layout(location=0) out vec4 color;\n" |
| 9660 | "void main(){\n" |
| 9661 | " color = vec4(1);\n" |
| 9662 | "}\n"; |
| 9663 | |
| 9664 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9665 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9666 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9667 | |
| 9668 | VkPipelineObj pipe(m_device); |
| 9669 | pipe.AddColorAttachment(); |
| 9670 | pipe.AddShader(&vs); |
| 9671 | pipe.AddShader(&gs); |
| 9672 | pipe.AddShader(&fs); |
| 9673 | |
| 9674 | VkDescriptorSetObj descriptorSet(m_device); |
| 9675 | descriptorSet.AppendDummy(); |
| 9676 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9677 | |
| 9678 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9679 | |
| 9680 | m_errorMonitor->VerifyNotFound(); |
| 9681 | } |
| 9682 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9683 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9684 | { |
| 9685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9686 | "is per-vertex in tessellation control shader stage " |
| 9687 | "but per-patch in tessellation evaluation shader stage"); |
| 9688 | |
| 9689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9690 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9691 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9692 | if (!m_device->phy().features().tessellationShader) { |
| 9693 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9694 | return; |
| 9695 | } |
| 9696 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9697 | char const *vsSource = |
| 9698 | "#version 450\n" |
| 9699 | "void main(){}\n"; |
| 9700 | char const *tcsSource = |
| 9701 | "#version 450\n" |
| 9702 | "layout(location=0) out int x[];\n" |
| 9703 | "layout(vertices=3) out;\n" |
| 9704 | "void main(){\n" |
| 9705 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9706 | " gl_TessLevelInner[0] = 1;\n" |
| 9707 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9708 | "}\n"; |
| 9709 | char const *tesSource = |
| 9710 | "#version 450\n" |
| 9711 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9712 | "layout(location=0) patch in int x;\n" |
| 9713 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9714 | "void main(){\n" |
| 9715 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9716 | " gl_Position.w = x;\n" |
| 9717 | "}\n"; |
| 9718 | char const *fsSource = |
| 9719 | "#version 450\n" |
| 9720 | "layout(location=0) out vec4 color;\n" |
| 9721 | "void main(){\n" |
| 9722 | " color = vec4(1);\n" |
| 9723 | "}\n"; |
| 9724 | |
| 9725 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9726 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9727 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9728 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9729 | |
| 9730 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9731 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9732 | nullptr, |
| 9733 | 0, |
| 9734 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9735 | VK_FALSE}; |
| 9736 | |
| 9737 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9738 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9739 | nullptr, |
| 9740 | 0, |
| 9741 | 3}; |
| 9742 | |
| 9743 | VkPipelineObj pipe(m_device); |
| 9744 | pipe.SetInputAssembly(&iasci); |
| 9745 | pipe.SetTessellation(&tsci); |
| 9746 | pipe.AddColorAttachment(); |
| 9747 | pipe.AddShader(&vs); |
| 9748 | pipe.AddShader(&tcs); |
| 9749 | pipe.AddShader(&tes); |
| 9750 | pipe.AddShader(&fs); |
| 9751 | |
| 9752 | VkDescriptorSetObj descriptorSet(m_device); |
| 9753 | descriptorSet.AppendDummy(); |
| 9754 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9755 | |
| 9756 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9758 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9759 | } |
| 9760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9761 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9762 | m_errorMonitor->SetDesiredFailureMsg( |
| 9763 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9764 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9765 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9766 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9767 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9768 | |
| 9769 | /* Two binding descriptions for binding 0 */ |
| 9770 | VkVertexInputBindingDescription input_bindings[2]; |
| 9771 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9772 | |
| 9773 | VkVertexInputAttributeDescription input_attrib; |
| 9774 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9775 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9776 | |
| 9777 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9778 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9779 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9780 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9781 | "out gl_PerVertex {\n" |
| 9782 | " vec4 gl_Position;\n" |
| 9783 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9784 | "void main(){\n" |
| 9785 | " gl_Position = vec4(x);\n" |
| 9786 | "}\n"; |
| 9787 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9788 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9789 | "\n" |
| 9790 | "layout(location=0) out vec4 color;\n" |
| 9791 | "void main(){\n" |
| 9792 | " color = vec4(1);\n" |
| 9793 | "}\n"; |
| 9794 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9795 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9796 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9797 | |
| 9798 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9799 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9800 | pipe.AddShader(&vs); |
| 9801 | pipe.AddShader(&fs); |
| 9802 | |
| 9803 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9804 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9805 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9806 | VkDescriptorSetObj descriptorSet(m_device); |
| 9807 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9808 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9809 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9810 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9811 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9812 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9813 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9814 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9815 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9816 | m_errorMonitor->ExpectSuccess(); |
| 9817 | |
| 9818 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9819 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9820 | |
| 9821 | if (!m_device->phy().features().tessellationShader) { |
| 9822 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9823 | return; |
| 9824 | } |
| 9825 | |
| 9826 | VkVertexInputBindingDescription input_bindings[1]; |
| 9827 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9828 | |
| 9829 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9830 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9831 | input_attribs[0].location = 0; |
| 9832 | input_attribs[0].offset = 0; |
| 9833 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9834 | input_attribs[1].location = 2; |
| 9835 | input_attribs[1].offset = 32; |
| 9836 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9837 | input_attribs[2].location = 4; |
| 9838 | input_attribs[2].offset = 64; |
| 9839 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9840 | input_attribs[3].location = 6; |
| 9841 | input_attribs[3].offset = 96; |
| 9842 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9843 | |
| 9844 | char const *vsSource = |
| 9845 | "#version 450\n" |
| 9846 | "\n" |
| 9847 | "layout(location=0) in dmat4 x;\n" |
| 9848 | "out gl_PerVertex {\n" |
| 9849 | " vec4 gl_Position;\n" |
| 9850 | "};\n" |
| 9851 | "void main(){\n" |
| 9852 | " gl_Position = vec4(x[0][0]);\n" |
| 9853 | "}\n"; |
| 9854 | char const *fsSource = |
| 9855 | "#version 450\n" |
| 9856 | "\n" |
| 9857 | "layout(location=0) out vec4 color;\n" |
| 9858 | "void main(){\n" |
| 9859 | " color = vec4(1);\n" |
| 9860 | "}\n"; |
| 9861 | |
| 9862 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9863 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9864 | |
| 9865 | VkPipelineObj pipe(m_device); |
| 9866 | pipe.AddColorAttachment(); |
| 9867 | pipe.AddShader(&vs); |
| 9868 | pipe.AddShader(&fs); |
| 9869 | |
| 9870 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9871 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9872 | |
| 9873 | VkDescriptorSetObj descriptorSet(m_device); |
| 9874 | descriptorSet.AppendDummy(); |
| 9875 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9876 | |
| 9877 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9878 | |
| 9879 | m_errorMonitor->VerifyNotFound(); |
| 9880 | } |
| 9881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9882 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9883 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9884 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9885 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9887 | |
| 9888 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9889 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9890 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9891 | "out gl_PerVertex {\n" |
| 9892 | " vec4 gl_Position;\n" |
| 9893 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9894 | "void main(){\n" |
| 9895 | " gl_Position = vec4(1);\n" |
| 9896 | "}\n"; |
| 9897 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9898 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9899 | "\n" |
| 9900 | "void main(){\n" |
| 9901 | "}\n"; |
| 9902 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9903 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9904 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9905 | |
| 9906 | VkPipelineObj pipe(m_device); |
| 9907 | pipe.AddShader(&vs); |
| 9908 | pipe.AddShader(&fs); |
| 9909 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9910 | /* set up CB 0, not written */ |
| 9911 | pipe.AddColorAttachment(); |
| 9912 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9913 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9914 | VkDescriptorSetObj descriptorSet(m_device); |
| 9915 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9916 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9917 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9918 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9919 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9920 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9921 | } |
| 9922 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9923 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9924 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9925 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9926 | "FS writes to output location 1 with no matching attachment"); |
| 9927 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9928 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9929 | |
| 9930 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9931 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9932 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9933 | "out gl_PerVertex {\n" |
| 9934 | " vec4 gl_Position;\n" |
| 9935 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9936 | "void main(){\n" |
| 9937 | " gl_Position = vec4(1);\n" |
| 9938 | "}\n"; |
| 9939 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9940 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9941 | "\n" |
| 9942 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9943 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9944 | "void main(){\n" |
| 9945 | " x = vec4(1);\n" |
| 9946 | " y = vec4(1);\n" |
| 9947 | "}\n"; |
| 9948 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9949 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9950 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9951 | |
| 9952 | VkPipelineObj pipe(m_device); |
| 9953 | pipe.AddShader(&vs); |
| 9954 | pipe.AddShader(&fs); |
| 9955 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9956 | /* set up CB 0, not written */ |
| 9957 | pipe.AddColorAttachment(); |
| 9958 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9959 | /* FS writes CB 1, but we don't configure it */ |
| 9960 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9961 | VkDescriptorSetObj descriptorSet(m_device); |
| 9962 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9963 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9964 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9965 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9966 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9967 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9968 | } |
| 9969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9970 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9972 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9973 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9974 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9975 | |
| 9976 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9977 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9978 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9979 | "out gl_PerVertex {\n" |
| 9980 | " vec4 gl_Position;\n" |
| 9981 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9982 | "void main(){\n" |
| 9983 | " gl_Position = vec4(1);\n" |
| 9984 | "}\n"; |
| 9985 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9986 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9987 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9988 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9989 | "void main(){\n" |
| 9990 | " x = ivec4(1);\n" |
| 9991 | "}\n"; |
| 9992 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9993 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9994 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9995 | |
| 9996 | VkPipelineObj pipe(m_device); |
| 9997 | pipe.AddShader(&vs); |
| 9998 | pipe.AddShader(&fs); |
| 9999 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10000 | /* set up CB 0; type is UNORM by default */ |
| 10001 | pipe.AddColorAttachment(); |
| 10002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10003 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10004 | VkDescriptorSetObj descriptorSet(m_device); |
| 10005 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10006 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10007 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10008 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10009 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10010 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10011 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10012 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10013 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10015 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10016 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10017 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10018 | |
| 10019 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10020 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10021 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10022 | "out gl_PerVertex {\n" |
| 10023 | " vec4 gl_Position;\n" |
| 10024 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10025 | "void main(){\n" |
| 10026 | " gl_Position = vec4(1);\n" |
| 10027 | "}\n"; |
| 10028 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10029 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10030 | "\n" |
| 10031 | "layout(location=0) out vec4 x;\n" |
| 10032 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10033 | "void main(){\n" |
| 10034 | " x = vec4(bar.y);\n" |
| 10035 | "}\n"; |
| 10036 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10037 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10038 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10039 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10040 | VkPipelineObj pipe(m_device); |
| 10041 | pipe.AddShader(&vs); |
| 10042 | pipe.AddShader(&fs); |
| 10043 | |
| 10044 | /* set up CB 0; type is UNORM by default */ |
| 10045 | pipe.AddColorAttachment(); |
| 10046 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10047 | |
| 10048 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10049 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10050 | |
| 10051 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10052 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10053 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10054 | } |
| 10055 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10056 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10057 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10058 | "not declared in layout"); |
| 10059 | |
| 10060 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10061 | |
| 10062 | char const *vsSource = |
| 10063 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10064 | "\n" |
| 10065 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10066 | "out gl_PerVertex {\n" |
| 10067 | " vec4 gl_Position;\n" |
| 10068 | "};\n" |
| 10069 | "void main(){\n" |
| 10070 | " gl_Position = vec4(consts.x);\n" |
| 10071 | "}\n"; |
| 10072 | char const *fsSource = |
| 10073 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10074 | "\n" |
| 10075 | "layout(location=0) out vec4 x;\n" |
| 10076 | "void main(){\n" |
| 10077 | " x = vec4(1);\n" |
| 10078 | "}\n"; |
| 10079 | |
| 10080 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10081 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10082 | |
| 10083 | VkPipelineObj pipe(m_device); |
| 10084 | pipe.AddShader(&vs); |
| 10085 | pipe.AddShader(&fs); |
| 10086 | |
| 10087 | /* set up CB 0; type is UNORM by default */ |
| 10088 | pipe.AddColorAttachment(); |
| 10089 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10090 | |
| 10091 | VkDescriptorSetObj descriptorSet(m_device); |
| 10092 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10093 | |
| 10094 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10095 | |
| 10096 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10097 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10098 | } |
| 10099 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10100 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10101 | m_errorMonitor->SetDesiredFailureMsg( |
| 10102 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10103 | "Shader uses descriptor slot 0.0"); |
| 10104 | |
| 10105 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10106 | |
| 10107 | char const *csSource = |
| 10108 | "#version 450\n" |
| 10109 | "\n" |
| 10110 | "layout(local_size_x=1) in;\n" |
| 10111 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10112 | "void main(){\n" |
| 10113 | " x = vec4(1);\n" |
| 10114 | "}\n"; |
| 10115 | |
| 10116 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10117 | |
| 10118 | VkDescriptorSetObj descriptorSet(m_device); |
| 10119 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10120 | |
| 10121 | VkComputePipelineCreateInfo cpci = { |
| 10122 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10123 | nullptr, 0, { |
| 10124 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10125 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10126 | cs.handle(), "main", nullptr |
| 10127 | }, |
| 10128 | descriptorSet.GetPipelineLayout(), |
| 10129 | VK_NULL_HANDLE, -1 |
| 10130 | }; |
| 10131 | |
| 10132 | VkPipeline pipe; |
| 10133 | VkResult err = vkCreateComputePipelines( |
| 10134 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10135 | |
| 10136 | m_errorMonitor->VerifyFound(); |
| 10137 | |
| 10138 | if (err == VK_SUCCESS) { |
| 10139 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10140 | } |
| 10141 | } |
| 10142 | |
| 10143 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10144 | m_errorMonitor->ExpectSuccess(); |
| 10145 | |
| 10146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10147 | |
| 10148 | char const *csSource = |
| 10149 | "#version 450\n" |
| 10150 | "\n" |
| 10151 | "layout(local_size_x=1) in;\n" |
| 10152 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10153 | "void main(){\n" |
| 10154 | " // x is not used.\n" |
| 10155 | "}\n"; |
| 10156 | |
| 10157 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10158 | |
| 10159 | VkDescriptorSetObj descriptorSet(m_device); |
| 10160 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10161 | |
| 10162 | VkComputePipelineCreateInfo cpci = { |
| 10163 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10164 | nullptr, 0, { |
| 10165 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10166 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10167 | cs.handle(), "main", nullptr |
| 10168 | }, |
| 10169 | descriptorSet.GetPipelineLayout(), |
| 10170 | VK_NULL_HANDLE, -1 |
| 10171 | }; |
| 10172 | |
| 10173 | VkPipeline pipe; |
| 10174 | VkResult err = vkCreateComputePipelines( |
| 10175 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10176 | |
| 10177 | m_errorMonitor->VerifyNotFound(); |
| 10178 | |
| 10179 | if (err == VK_SUCCESS) { |
| 10180 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10181 | } |
| 10182 | } |
| 10183 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10184 | #endif // SHADER_CHECKER_TESTS |
| 10185 | |
| 10186 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10187 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10188 | m_errorMonitor->SetDesiredFailureMsg( |
| 10189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10190 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10191 | |
| 10192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10193 | |
| 10194 | // Create an image |
| 10195 | VkImage image; |
| 10196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10197 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10198 | const int32_t tex_width = 32; |
| 10199 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10200 | |
| 10201 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10202 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10203 | image_create_info.pNext = NULL; |
| 10204 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10205 | image_create_info.format = tex_format; |
| 10206 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10207 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10208 | image_create_info.extent.depth = 1; |
| 10209 | image_create_info.mipLevels = 1; |
| 10210 | image_create_info.arrayLayers = 1; |
| 10211 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10212 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10213 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10214 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10215 | |
| 10216 | // Introduce error by sending down a bogus width extent |
| 10217 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10218 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10219 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10220 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10221 | } |
| 10222 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10223 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10224 | m_errorMonitor->SetDesiredFailureMsg( |
| 10225 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10226 | "CreateImage extents is 0 for at least one required dimension"); |
| 10227 | |
| 10228 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10229 | |
| 10230 | // Create an image |
| 10231 | VkImage image; |
| 10232 | |
| 10233 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10234 | const int32_t tex_width = 32; |
| 10235 | const int32_t tex_height = 32; |
| 10236 | |
| 10237 | VkImageCreateInfo image_create_info = {}; |
| 10238 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10239 | image_create_info.pNext = NULL; |
| 10240 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10241 | image_create_info.format = tex_format; |
| 10242 | image_create_info.extent.width = tex_width; |
| 10243 | image_create_info.extent.height = tex_height; |
| 10244 | image_create_info.extent.depth = 1; |
| 10245 | image_create_info.mipLevels = 1; |
| 10246 | image_create_info.arrayLayers = 1; |
| 10247 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10248 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10249 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10250 | image_create_info.flags = 0; |
| 10251 | |
| 10252 | // Introduce error by sending down a bogus width extent |
| 10253 | image_create_info.extent.width = 0; |
| 10254 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10255 | |
| 10256 | m_errorMonitor->VerifyFound(); |
| 10257 | } |
| 10258 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10259 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 10260 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10261 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10262 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10263 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10264 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10265 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10266 | |
| 10267 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10268 | vk_testing::Buffer buffer; |
| 10269 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10270 | |
| 10271 | BeginCommandBuffer(); |
| 10272 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10273 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10274 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10275 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10276 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10277 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10278 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10279 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10280 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10281 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10282 | EndCommandBuffer(); |
| 10283 | } |
| 10284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10285 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10286 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10287 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10288 | |
| 10289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10290 | |
| 10291 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10292 | vk_testing::Buffer buffer; |
| 10293 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10294 | |
| 10295 | BeginCommandBuffer(); |
| 10296 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10297 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10298 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10299 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10300 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10301 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10302 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10303 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10304 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10305 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10306 | m_errorMonitor->VerifyFound(); |
| 10307 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10308 | EndCommandBuffer(); |
| 10309 | } |
| 10310 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10311 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10312 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10313 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10314 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10315 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10317 | m_errorMonitor->SetDesiredFailureMsg( |
| 10318 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10319 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10320 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10321 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10322 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10323 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10324 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10326 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10327 | const int32_t tex_width = 32; |
| 10328 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10329 | |
| 10330 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10331 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10332 | image_create_info.pNext = NULL; |
| 10333 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10334 | image_create_info.format = tex_format; |
| 10335 | image_create_info.extent.width = tex_width; |
| 10336 | image_create_info.extent.height = tex_height; |
| 10337 | image_create_info.extent.depth = 1; |
| 10338 | image_create_info.mipLevels = 1; |
| 10339 | image_create_info.arrayLayers = 1; |
| 10340 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10341 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10342 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10343 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10344 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10345 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10346 | ASSERT_VK_SUCCESS(err); |
| 10347 | |
| 10348 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10349 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10350 | image_view_create_info.image = image; |
| 10351 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10352 | image_view_create_info.format = tex_format; |
| 10353 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10354 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10355 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10356 | image_view_create_info.subresourceRange.aspectMask = |
| 10357 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10358 | |
| 10359 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10360 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10361 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10362 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10363 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10364 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10365 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10367 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10368 | TEST_DESCRIPTION( |
| 10369 | "Create an image and try to create a view with an invalid aspectMask"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10370 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10371 | "vkCreateImageView: Color image " |
| 10372 | "formats must have ONLY the " |
| 10373 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10374 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10377 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10378 | VkImageObj image(m_device); |
| 10379 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10380 | VK_IMAGE_TILING_LINEAR, 0); |
| 10381 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10382 | |
| 10383 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10384 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10385 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10386 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10387 | image_view_create_info.format = tex_format; |
| 10388 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10389 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10390 | // Cause an error by setting an invalid image aspect |
| 10391 | image_view_create_info.subresourceRange.aspectMask = |
| 10392 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10393 | |
| 10394 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10395 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10396 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10397 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10398 | } |
| 10399 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10400 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10401 | VkResult err; |
| 10402 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10403 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10404 | m_errorMonitor->SetDesiredFailureMsg( |
| 10405 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10406 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10407 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10408 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10409 | |
| 10410 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10411 | VkImage srcImage; |
| 10412 | VkImage dstImage; |
| 10413 | VkDeviceMemory srcMem; |
| 10414 | VkDeviceMemory destMem; |
| 10415 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10416 | |
| 10417 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10418 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10419 | image_create_info.pNext = NULL; |
| 10420 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10421 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10422 | image_create_info.extent.width = 32; |
| 10423 | image_create_info.extent.height = 32; |
| 10424 | image_create_info.extent.depth = 1; |
| 10425 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10426 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10427 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10428 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10429 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10430 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10432 | err = |
| 10433 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10434 | ASSERT_VK_SUCCESS(err); |
| 10435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10436 | err = |
| 10437 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10438 | ASSERT_VK_SUCCESS(err); |
| 10439 | |
| 10440 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10441 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10442 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10443 | memAlloc.pNext = NULL; |
| 10444 | memAlloc.allocationSize = 0; |
| 10445 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10446 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10447 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10448 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10449 | pass = |
| 10450 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10451 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10452 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10453 | ASSERT_VK_SUCCESS(err); |
| 10454 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10455 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10456 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10457 | pass = |
| 10458 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10459 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10460 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10461 | ASSERT_VK_SUCCESS(err); |
| 10462 | |
| 10463 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10464 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10465 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10466 | ASSERT_VK_SUCCESS(err); |
| 10467 | |
| 10468 | BeginCommandBuffer(); |
| 10469 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10470 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10471 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10472 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10473 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10474 | copyRegion.srcOffset.x = 0; |
| 10475 | copyRegion.srcOffset.y = 0; |
| 10476 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10477 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10478 | copyRegion.dstSubresource.mipLevel = 0; |
| 10479 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10480 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10481 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10482 | copyRegion.dstOffset.x = 0; |
| 10483 | copyRegion.dstOffset.y = 0; |
| 10484 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10485 | copyRegion.extent.width = 1; |
| 10486 | copyRegion.extent.height = 1; |
| 10487 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10488 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10489 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10490 | EndCommandBuffer(); |
| 10491 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10492 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10493 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10494 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10495 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10496 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10497 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10498 | } |
| 10499 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10500 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10501 | |
| 10502 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10503 | |
| 10504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10505 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10506 | VkImageObj image(m_device); |
| 10507 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10508 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10509 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10510 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10511 | ASSERT_TRUE(image.initialized()); |
| 10512 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10513 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10514 | VkImageCreateInfo image_create_info; |
| 10515 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10516 | image_create_info.pNext = NULL; |
| 10517 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10518 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10519 | image_create_info.extent.width = 32; |
| 10520 | image_create_info.extent.height = 32; |
| 10521 | image_create_info.extent.depth = 1; |
| 10522 | image_create_info.mipLevels = 1; |
| 10523 | image_create_info.arrayLayers = 1; |
| 10524 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10525 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10526 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10527 | image_create_info.flags = 0; |
| 10528 | |
| 10529 | m_errorMonitor->SetDesiredFailureMsg( |
| 10530 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10531 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10532 | |
| 10533 | VkImage localImage; |
| 10534 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10535 | m_errorMonitor->VerifyFound(); |
| 10536 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10537 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10538 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10539 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10540 | VkFormat format = static_cast<VkFormat>(f); |
| 10541 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10542 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10543 | fProps.optimalTilingFeatures == 0) { |
| 10544 | unsupported = format; |
| 10545 | break; |
| 10546 | } |
| 10547 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10548 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10549 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10550 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10551 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10552 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10553 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10554 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10555 | m_errorMonitor->VerifyFound(); |
| 10556 | } |
| 10557 | } |
| 10558 | |
| 10559 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10560 | VkResult ret; |
| 10561 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10562 | |
| 10563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10564 | |
| 10565 | VkImageObj image(m_device); |
| 10566 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10567 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10568 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10569 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10570 | ASSERT_TRUE(image.initialized()); |
| 10571 | |
| 10572 | VkImageView imgView; |
| 10573 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10574 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10575 | imgViewInfo.image = image.handle(); |
| 10576 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10577 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10578 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10579 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10580 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10581 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10582 | |
| 10583 | m_errorMonitor->SetDesiredFailureMsg( |
| 10584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10585 | "vkCreateImageView called with baseMipLevel"); |
| 10586 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10587 | // VIEW_CREATE_ERROR |
| 10588 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10589 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10590 | m_errorMonitor->VerifyFound(); |
| 10591 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10592 | |
| 10593 | m_errorMonitor->SetDesiredFailureMsg( |
| 10594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10595 | "vkCreateImageView called with baseArrayLayer"); |
| 10596 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10597 | // VIEW_CREATE_ERROR |
| 10598 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10599 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10600 | m_errorMonitor->VerifyFound(); |
| 10601 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10602 | |
| 10603 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10604 | "vkCreateImageView called with 0 in " |
| 10605 | "pCreateInfo->subresourceRange." |
| 10606 | "levelCount"); |
| 10607 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10608 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10609 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10610 | m_errorMonitor->VerifyFound(); |
| 10611 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10612 | |
| 10613 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10614 | "vkCreateImageView called with 0 in " |
| 10615 | "pCreateInfo->subresourceRange." |
| 10616 | "layerCount"); |
| 10617 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10618 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10619 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10620 | m_errorMonitor->VerifyFound(); |
| 10621 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10622 | |
| 10623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10624 | "but both must be color formats"); |
| 10625 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10626 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10627 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10628 | m_errorMonitor->VerifyFound(); |
| 10629 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10630 | |
| 10631 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10632 | "Formats MUST be IDENTICAL unless " |
| 10633 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10634 | "was set on image creation."); |
| 10635 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10636 | // VIEW_CREATE_ERROR |
| 10637 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10638 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10639 | m_errorMonitor->VerifyFound(); |
| 10640 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10641 | |
| 10642 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10643 | "can support ImageViews with " |
| 10644 | "differing formats but they must be " |
| 10645 | "in the same compatibility class."); |
| 10646 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10647 | // VIEW_CREATE_ERROR |
| 10648 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10649 | VkImage mutImage; |
| 10650 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10651 | assert( |
| 10652 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10653 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10654 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10655 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10656 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10657 | ASSERT_VK_SUCCESS(ret); |
| 10658 | imgViewInfo.image = mutImage; |
| 10659 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10660 | m_errorMonitor->VerifyFound(); |
| 10661 | imgViewInfo.image = image.handle(); |
| 10662 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10663 | } |
| 10664 | |
| 10665 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10666 | |
| 10667 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10668 | |
| 10669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10670 | |
| 10671 | VkImageObj image(m_device); |
| 10672 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10673 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10674 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10675 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10676 | ASSERT_TRUE(image.initialized()); |
| 10677 | |
| 10678 | m_errorMonitor->SetDesiredFailureMsg( |
| 10679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10680 | "number of layers in image subresource is zero"); |
| 10681 | vk_testing::Buffer buffer; |
| 10682 | VkMemoryPropertyFlags reqs = 0; |
| 10683 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10684 | VkBufferImageCopy region = {}; |
| 10685 | region.bufferRowLength = 128; |
| 10686 | region.bufferImageHeight = 128; |
| 10687 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10688 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10689 | region.imageSubresource.layerCount = 0; |
| 10690 | region.imageExtent.height = 4; |
| 10691 | region.imageExtent.width = 4; |
| 10692 | region.imageExtent.depth = 1; |
| 10693 | m_commandBuffer->BeginCommandBuffer(); |
| 10694 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10695 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10696 | 1, ®ion); |
| 10697 | m_errorMonitor->VerifyFound(); |
| 10698 | region.imageSubresource.layerCount = 1; |
| 10699 | |
| 10700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10701 | "aspectMasks for each region must " |
| 10702 | "specify only COLOR or DEPTH or " |
| 10703 | "STENCIL"); |
| 10704 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10705 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10706 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10707 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10708 | 1, ®ion); |
| 10709 | m_errorMonitor->VerifyFound(); |
| 10710 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10711 | |
| 10712 | m_errorMonitor->SetDesiredFailureMsg( |
| 10713 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10714 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10715 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10716 | // Expect INVALID_FILTER |
| 10717 | VkImageObj intImage1(m_device); |
| 10718 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10719 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10720 | 0); |
| 10721 | VkImageObj intImage2(m_device); |
| 10722 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10723 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10724 | 0); |
| 10725 | VkImageBlit blitRegion = {}; |
| 10726 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10727 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10728 | blitRegion.srcSubresource.layerCount = 1; |
| 10729 | blitRegion.srcSubresource.mipLevel = 0; |
| 10730 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10731 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10732 | blitRegion.dstSubresource.layerCount = 1; |
| 10733 | blitRegion.dstSubresource.mipLevel = 0; |
| 10734 | |
| 10735 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10736 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10737 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10738 | m_errorMonitor->VerifyFound(); |
| 10739 | |
| 10740 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10741 | "called with 0 in ppMemoryBarriers"); |
| 10742 | VkImageMemoryBarrier img_barrier; |
| 10743 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10744 | img_barrier.pNext = NULL; |
| 10745 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10746 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10747 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10748 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10749 | img_barrier.image = image.handle(); |
| 10750 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10751 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10752 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10753 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10754 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10755 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10756 | img_barrier.subresourceRange.layerCount = 0; |
| 10757 | img_barrier.subresourceRange.levelCount = 1; |
| 10758 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10759 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10760 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10761 | nullptr, 1, &img_barrier); |
| 10762 | m_errorMonitor->VerifyFound(); |
| 10763 | img_barrier.subresourceRange.layerCount = 1; |
| 10764 | } |
| 10765 | |
| 10766 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10767 | |
| 10768 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10769 | |
| 10770 | m_errorMonitor->SetDesiredFailureMsg( |
| 10771 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10772 | "CreateImage extents exceed allowable limits for format"); |
| 10773 | VkImageCreateInfo image_create_info = {}; |
| 10774 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10775 | image_create_info.pNext = NULL; |
| 10776 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10777 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10778 | image_create_info.extent.width = 32; |
| 10779 | image_create_info.extent.height = 32; |
| 10780 | image_create_info.extent.depth = 1; |
| 10781 | image_create_info.mipLevels = 1; |
| 10782 | image_create_info.arrayLayers = 1; |
| 10783 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10784 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10785 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10786 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10787 | image_create_info.flags = 0; |
| 10788 | |
| 10789 | VkImage nullImg; |
| 10790 | VkImageFormatProperties imgFmtProps; |
| 10791 | vkGetPhysicalDeviceImageFormatProperties( |
| 10792 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10793 | image_create_info.tiling, image_create_info.usage, |
| 10794 | image_create_info.flags, &imgFmtProps); |
| 10795 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10796 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10797 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10798 | m_errorMonitor->VerifyFound(); |
| 10799 | image_create_info.extent.depth = 1; |
| 10800 | |
| 10801 | m_errorMonitor->SetDesiredFailureMsg( |
| 10802 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10803 | "exceeds allowable maximum supported by format of"); |
| 10804 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10805 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10806 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10807 | m_errorMonitor->VerifyFound(); |
| 10808 | image_create_info.mipLevels = 1; |
| 10809 | |
| 10810 | m_errorMonitor->SetDesiredFailureMsg( |
| 10811 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10812 | "exceeds allowable maximum supported by format of"); |
| 10813 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10814 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10815 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10816 | m_errorMonitor->VerifyFound(); |
| 10817 | image_create_info.arrayLayers = 1; |
| 10818 | |
| 10819 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10820 | "is not supported by format"); |
| 10821 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10822 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10823 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10824 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10825 | m_errorMonitor->VerifyFound(); |
| 10826 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10827 | |
| 10828 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10829 | "pCreateInfo->initialLayout, must be " |
| 10830 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10831 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10832 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10833 | // Expect INVALID_LAYOUT |
| 10834 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10835 | m_errorMonitor->VerifyFound(); |
| 10836 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10837 | } |
| 10838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10839 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10840 | VkResult err; |
| 10841 | bool pass; |
| 10842 | |
| 10843 | // Create color images with different format sizes and try to copy between them |
| 10844 | m_errorMonitor->SetDesiredFailureMsg( |
| 10845 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10846 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10847 | |
| 10848 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10849 | |
| 10850 | // Create two images of different types and try to copy between them |
| 10851 | VkImage srcImage; |
| 10852 | VkImage dstImage; |
| 10853 | VkDeviceMemory srcMem; |
| 10854 | VkDeviceMemory destMem; |
| 10855 | VkMemoryRequirements memReqs; |
| 10856 | |
| 10857 | VkImageCreateInfo image_create_info = {}; |
| 10858 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10859 | image_create_info.pNext = NULL; |
| 10860 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10861 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10862 | image_create_info.extent.width = 32; |
| 10863 | image_create_info.extent.height = 32; |
| 10864 | image_create_info.extent.depth = 1; |
| 10865 | image_create_info.mipLevels = 1; |
| 10866 | image_create_info.arrayLayers = 1; |
| 10867 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10868 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10869 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10870 | image_create_info.flags = 0; |
| 10871 | |
| 10872 | err = |
| 10873 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10874 | ASSERT_VK_SUCCESS(err); |
| 10875 | |
| 10876 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10877 | // Introduce failure by creating second image with a different-sized format. |
| 10878 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10879 | |
| 10880 | err = |
| 10881 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10882 | ASSERT_VK_SUCCESS(err); |
| 10883 | |
| 10884 | // Allocate memory |
| 10885 | VkMemoryAllocateInfo memAlloc = {}; |
| 10886 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10887 | memAlloc.pNext = NULL; |
| 10888 | memAlloc.allocationSize = 0; |
| 10889 | memAlloc.memoryTypeIndex = 0; |
| 10890 | |
| 10891 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10892 | memAlloc.allocationSize = memReqs.size; |
| 10893 | pass = |
| 10894 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10895 | ASSERT_TRUE(pass); |
| 10896 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10897 | ASSERT_VK_SUCCESS(err); |
| 10898 | |
| 10899 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10900 | memAlloc.allocationSize = memReqs.size; |
| 10901 | pass = |
| 10902 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10903 | ASSERT_TRUE(pass); |
| 10904 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10905 | ASSERT_VK_SUCCESS(err); |
| 10906 | |
| 10907 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10908 | ASSERT_VK_SUCCESS(err); |
| 10909 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10910 | ASSERT_VK_SUCCESS(err); |
| 10911 | |
| 10912 | BeginCommandBuffer(); |
| 10913 | VkImageCopy copyRegion; |
| 10914 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10915 | copyRegion.srcSubresource.mipLevel = 0; |
| 10916 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10917 | copyRegion.srcSubresource.layerCount = 0; |
| 10918 | copyRegion.srcOffset.x = 0; |
| 10919 | copyRegion.srcOffset.y = 0; |
| 10920 | copyRegion.srcOffset.z = 0; |
| 10921 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10922 | copyRegion.dstSubresource.mipLevel = 0; |
| 10923 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10924 | copyRegion.dstSubresource.layerCount = 0; |
| 10925 | copyRegion.dstOffset.x = 0; |
| 10926 | copyRegion.dstOffset.y = 0; |
| 10927 | copyRegion.dstOffset.z = 0; |
| 10928 | copyRegion.extent.width = 1; |
| 10929 | copyRegion.extent.height = 1; |
| 10930 | copyRegion.extent.depth = 1; |
| 10931 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10932 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10933 | EndCommandBuffer(); |
| 10934 | |
| 10935 | m_errorMonitor->VerifyFound(); |
| 10936 | |
| 10937 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10938 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10939 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10940 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10941 | } |
| 10942 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10943 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10944 | VkResult err; |
| 10945 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10946 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10947 | // 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] | 10948 | m_errorMonitor->SetDesiredFailureMsg( |
| 10949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10950 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10951 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10952 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10953 | |
| 10954 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10955 | VkImage srcImage; |
| 10956 | VkImage dstImage; |
| 10957 | VkDeviceMemory srcMem; |
| 10958 | VkDeviceMemory destMem; |
| 10959 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10960 | |
| 10961 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10962 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10963 | image_create_info.pNext = NULL; |
| 10964 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10965 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10966 | image_create_info.extent.width = 32; |
| 10967 | image_create_info.extent.height = 32; |
| 10968 | image_create_info.extent.depth = 1; |
| 10969 | image_create_info.mipLevels = 1; |
| 10970 | image_create_info.arrayLayers = 1; |
| 10971 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10972 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10973 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10974 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10976 | err = |
| 10977 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10978 | ASSERT_VK_SUCCESS(err); |
| 10979 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10980 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10981 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10982 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10983 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10984 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10985 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10986 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10987 | err = |
| 10988 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10989 | ASSERT_VK_SUCCESS(err); |
| 10990 | |
| 10991 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10992 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10993 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10994 | memAlloc.pNext = NULL; |
| 10995 | memAlloc.allocationSize = 0; |
| 10996 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10997 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10998 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10999 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11000 | pass = |
| 11001 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11002 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11003 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11004 | ASSERT_VK_SUCCESS(err); |
| 11005 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11006 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11007 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11008 | pass = |
| 11009 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11010 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11011 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11012 | ASSERT_VK_SUCCESS(err); |
| 11013 | |
| 11014 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11015 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11016 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11017 | ASSERT_VK_SUCCESS(err); |
| 11018 | |
| 11019 | BeginCommandBuffer(); |
| 11020 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11021 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11022 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11023 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11024 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11025 | copyRegion.srcOffset.x = 0; |
| 11026 | copyRegion.srcOffset.y = 0; |
| 11027 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11028 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11029 | copyRegion.dstSubresource.mipLevel = 0; |
| 11030 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11031 | copyRegion.dstSubresource.layerCount = 0; |
| 11032 | copyRegion.dstOffset.x = 0; |
| 11033 | copyRegion.dstOffset.y = 0; |
| 11034 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11035 | copyRegion.extent.width = 1; |
| 11036 | copyRegion.extent.height = 1; |
| 11037 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11038 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11039 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11040 | EndCommandBuffer(); |
| 11041 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11042 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11043 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11044 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11045 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11046 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11047 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11048 | } |
| 11049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11050 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11051 | VkResult err; |
| 11052 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11054 | m_errorMonitor->SetDesiredFailureMsg( |
| 11055 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11056 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11057 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11058 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11059 | |
| 11060 | // 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] | 11061 | VkImage srcImage; |
| 11062 | VkImage dstImage; |
| 11063 | VkDeviceMemory srcMem; |
| 11064 | VkDeviceMemory destMem; |
| 11065 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11066 | |
| 11067 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11068 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11069 | image_create_info.pNext = NULL; |
| 11070 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11071 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11072 | image_create_info.extent.width = 32; |
| 11073 | image_create_info.extent.height = 1; |
| 11074 | image_create_info.extent.depth = 1; |
| 11075 | image_create_info.mipLevels = 1; |
| 11076 | image_create_info.arrayLayers = 1; |
| 11077 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11078 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11079 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11080 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11081 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11082 | err = |
| 11083 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11084 | ASSERT_VK_SUCCESS(err); |
| 11085 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11086 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11087 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11088 | err = |
| 11089 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11090 | ASSERT_VK_SUCCESS(err); |
| 11091 | |
| 11092 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11093 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11094 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11095 | memAlloc.pNext = NULL; |
| 11096 | memAlloc.allocationSize = 0; |
| 11097 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11098 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11099 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11100 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11101 | pass = |
| 11102 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11103 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11104 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11105 | ASSERT_VK_SUCCESS(err); |
| 11106 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11107 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11108 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11109 | pass = |
| 11110 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11111 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11112 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11113 | ASSERT_VK_SUCCESS(err); |
| 11114 | |
| 11115 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11116 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11117 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11118 | ASSERT_VK_SUCCESS(err); |
| 11119 | |
| 11120 | BeginCommandBuffer(); |
| 11121 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11122 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11123 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11124 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11125 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11126 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11127 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11128 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11129 | resolveRegion.srcOffset.x = 0; |
| 11130 | resolveRegion.srcOffset.y = 0; |
| 11131 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11132 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11133 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11134 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11135 | resolveRegion.dstSubresource.layerCount = 0; |
| 11136 | resolveRegion.dstOffset.x = 0; |
| 11137 | resolveRegion.dstOffset.y = 0; |
| 11138 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11139 | resolveRegion.extent.width = 1; |
| 11140 | resolveRegion.extent.height = 1; |
| 11141 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11142 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11143 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11144 | EndCommandBuffer(); |
| 11145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11146 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11147 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11148 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11149 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11150 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11151 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11152 | } |
| 11153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11154 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11155 | VkResult err; |
| 11156 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11158 | m_errorMonitor->SetDesiredFailureMsg( |
| 11159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11160 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11161 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11163 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11164 | // 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] | 11165 | VkImage srcImage; |
| 11166 | VkImage dstImage; |
| 11167 | VkDeviceMemory srcMem; |
| 11168 | VkDeviceMemory destMem; |
| 11169 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11170 | |
| 11171 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11172 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11173 | image_create_info.pNext = NULL; |
| 11174 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11175 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11176 | image_create_info.extent.width = 32; |
| 11177 | image_create_info.extent.height = 1; |
| 11178 | image_create_info.extent.depth = 1; |
| 11179 | image_create_info.mipLevels = 1; |
| 11180 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11181 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11182 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11183 | // Note: Some implementations expect color attachment usage for any |
| 11184 | // multisample surface |
| 11185 | image_create_info.usage = |
| 11186 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11187 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11189 | err = |
| 11190 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11191 | ASSERT_VK_SUCCESS(err); |
| 11192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11193 | // Note: Some implementations expect color attachment usage for any |
| 11194 | // multisample surface |
| 11195 | image_create_info.usage = |
| 11196 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11198 | err = |
| 11199 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11200 | ASSERT_VK_SUCCESS(err); |
| 11201 | |
| 11202 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11203 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11204 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11205 | memAlloc.pNext = NULL; |
| 11206 | memAlloc.allocationSize = 0; |
| 11207 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11208 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11209 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11210 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11211 | pass = |
| 11212 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11213 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11214 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11215 | ASSERT_VK_SUCCESS(err); |
| 11216 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11217 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11218 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11219 | pass = |
| 11220 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11221 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11222 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11223 | ASSERT_VK_SUCCESS(err); |
| 11224 | |
| 11225 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11226 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11227 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11228 | ASSERT_VK_SUCCESS(err); |
| 11229 | |
| 11230 | BeginCommandBuffer(); |
| 11231 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11232 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11233 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11234 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11235 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11236 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11237 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11238 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11239 | resolveRegion.srcOffset.x = 0; |
| 11240 | resolveRegion.srcOffset.y = 0; |
| 11241 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11242 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11243 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11244 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11245 | resolveRegion.dstSubresource.layerCount = 0; |
| 11246 | resolveRegion.dstOffset.x = 0; |
| 11247 | resolveRegion.dstOffset.y = 0; |
| 11248 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11249 | resolveRegion.extent.width = 1; |
| 11250 | resolveRegion.extent.height = 1; |
| 11251 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11252 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11253 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11254 | EndCommandBuffer(); |
| 11255 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11256 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11257 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11258 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11259 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11260 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11261 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11262 | } |
| 11263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11264 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11265 | VkResult err; |
| 11266 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11268 | m_errorMonitor->SetDesiredFailureMsg( |
| 11269 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11270 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11271 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11273 | |
| 11274 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11275 | VkImage srcImage; |
| 11276 | VkImage dstImage; |
| 11277 | VkDeviceMemory srcMem; |
| 11278 | VkDeviceMemory destMem; |
| 11279 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11280 | |
| 11281 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11282 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11283 | image_create_info.pNext = NULL; |
| 11284 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11285 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11286 | image_create_info.extent.width = 32; |
| 11287 | image_create_info.extent.height = 1; |
| 11288 | image_create_info.extent.depth = 1; |
| 11289 | image_create_info.mipLevels = 1; |
| 11290 | image_create_info.arrayLayers = 1; |
| 11291 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11292 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11293 | // Note: Some implementations expect color attachment usage for any |
| 11294 | // multisample surface |
| 11295 | image_create_info.usage = |
| 11296 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11297 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11299 | err = |
| 11300 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11301 | ASSERT_VK_SUCCESS(err); |
| 11302 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11303 | // Set format to something other than source image |
| 11304 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11305 | // Note: Some implementations expect color attachment usage for any |
| 11306 | // multisample surface |
| 11307 | image_create_info.usage = |
| 11308 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11309 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11310 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11311 | err = |
| 11312 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11313 | ASSERT_VK_SUCCESS(err); |
| 11314 | |
| 11315 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11316 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11317 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11318 | memAlloc.pNext = NULL; |
| 11319 | memAlloc.allocationSize = 0; |
| 11320 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11321 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11322 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11323 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11324 | pass = |
| 11325 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11326 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11327 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11328 | ASSERT_VK_SUCCESS(err); |
| 11329 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11330 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11331 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11332 | pass = |
| 11333 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11334 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11335 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11336 | ASSERT_VK_SUCCESS(err); |
| 11337 | |
| 11338 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11339 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11340 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11341 | ASSERT_VK_SUCCESS(err); |
| 11342 | |
| 11343 | BeginCommandBuffer(); |
| 11344 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11345 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11346 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11347 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11348 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11349 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11350 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11351 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11352 | resolveRegion.srcOffset.x = 0; |
| 11353 | resolveRegion.srcOffset.y = 0; |
| 11354 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11355 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11356 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11357 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11358 | resolveRegion.dstSubresource.layerCount = 0; |
| 11359 | resolveRegion.dstOffset.x = 0; |
| 11360 | resolveRegion.dstOffset.y = 0; |
| 11361 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11362 | resolveRegion.extent.width = 1; |
| 11363 | resolveRegion.extent.height = 1; |
| 11364 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11365 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11366 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11367 | EndCommandBuffer(); |
| 11368 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11369 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11370 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11371 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11372 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11373 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11374 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11375 | } |
| 11376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11377 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11378 | VkResult err; |
| 11379 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11381 | m_errorMonitor->SetDesiredFailureMsg( |
| 11382 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11383 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11384 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11386 | |
| 11387 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11388 | VkImage srcImage; |
| 11389 | VkImage dstImage; |
| 11390 | VkDeviceMemory srcMem; |
| 11391 | VkDeviceMemory destMem; |
| 11392 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11393 | |
| 11394 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11395 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11396 | image_create_info.pNext = NULL; |
| 11397 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11398 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11399 | image_create_info.extent.width = 32; |
| 11400 | image_create_info.extent.height = 1; |
| 11401 | image_create_info.extent.depth = 1; |
| 11402 | image_create_info.mipLevels = 1; |
| 11403 | image_create_info.arrayLayers = 1; |
| 11404 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11405 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11406 | // Note: Some implementations expect color attachment usage for any |
| 11407 | // multisample surface |
| 11408 | image_create_info.usage = |
| 11409 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11410 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11411 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11412 | err = |
| 11413 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11414 | ASSERT_VK_SUCCESS(err); |
| 11415 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11416 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11417 | // Note: Some implementations expect color attachment usage for any |
| 11418 | // multisample surface |
| 11419 | image_create_info.usage = |
| 11420 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11421 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11422 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11423 | err = |
| 11424 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11425 | ASSERT_VK_SUCCESS(err); |
| 11426 | |
| 11427 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11428 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11429 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11430 | memAlloc.pNext = NULL; |
| 11431 | memAlloc.allocationSize = 0; |
| 11432 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11433 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11434 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11435 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11436 | pass = |
| 11437 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11438 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11439 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11440 | ASSERT_VK_SUCCESS(err); |
| 11441 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11442 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11443 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11444 | pass = |
| 11445 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11446 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11447 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11448 | ASSERT_VK_SUCCESS(err); |
| 11449 | |
| 11450 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11451 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11452 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11453 | ASSERT_VK_SUCCESS(err); |
| 11454 | |
| 11455 | BeginCommandBuffer(); |
| 11456 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11457 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11458 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11459 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11460 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11461 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11462 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11463 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11464 | resolveRegion.srcOffset.x = 0; |
| 11465 | resolveRegion.srcOffset.y = 0; |
| 11466 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11467 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11468 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11469 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11470 | resolveRegion.dstSubresource.layerCount = 0; |
| 11471 | resolveRegion.dstOffset.x = 0; |
| 11472 | resolveRegion.dstOffset.y = 0; |
| 11473 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11474 | resolveRegion.extent.width = 1; |
| 11475 | resolveRegion.extent.height = 1; |
| 11476 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11477 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11478 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11479 | EndCommandBuffer(); |
| 11480 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11481 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11482 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11483 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11484 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11485 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11486 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11487 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11488 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11489 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11490 | // 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] | 11491 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11492 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11493 | // The image format check comes 2nd in validation so we trigger it first, |
| 11494 | // 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] | 11495 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11497 | m_errorMonitor->SetDesiredFailureMsg( |
| 11498 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11499 | "Combination depth/stencil image formats can have only the "); |
| 11500 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11501 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11502 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11503 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11504 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11505 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11506 | |
| 11507 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11508 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11509 | ds_pool_ci.pNext = NULL; |
| 11510 | ds_pool_ci.maxSets = 1; |
| 11511 | ds_pool_ci.poolSizeCount = 1; |
| 11512 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11513 | |
| 11514 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11515 | err = |
| 11516 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11517 | ASSERT_VK_SUCCESS(err); |
| 11518 | |
| 11519 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11520 | dsl_binding.binding = 0; |
| 11521 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11522 | dsl_binding.descriptorCount = 1; |
| 11523 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11524 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11525 | |
| 11526 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11527 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11528 | ds_layout_ci.pNext = NULL; |
| 11529 | ds_layout_ci.bindingCount = 1; |
| 11530 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11531 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11532 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11533 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11534 | ASSERT_VK_SUCCESS(err); |
| 11535 | |
| 11536 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11537 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11538 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11539 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11540 | alloc_info.descriptorPool = ds_pool; |
| 11541 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11542 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11543 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11544 | ASSERT_VK_SUCCESS(err); |
| 11545 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11546 | VkImage image_bad; |
| 11547 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11548 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11549 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11550 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11551 | const int32_t tex_width = 32; |
| 11552 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11553 | |
| 11554 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11555 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11556 | image_create_info.pNext = NULL; |
| 11557 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11558 | image_create_info.format = tex_format_bad; |
| 11559 | image_create_info.extent.width = tex_width; |
| 11560 | image_create_info.extent.height = tex_height; |
| 11561 | image_create_info.extent.depth = 1; |
| 11562 | image_create_info.mipLevels = 1; |
| 11563 | image_create_info.arrayLayers = 1; |
| 11564 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11565 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11566 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11567 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11568 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11570 | err = |
| 11571 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11572 | ASSERT_VK_SUCCESS(err); |
| 11573 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11574 | image_create_info.usage = |
| 11575 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11576 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11577 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11578 | ASSERT_VK_SUCCESS(err); |
| 11579 | |
| 11580 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11581 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11582 | image_view_create_info.image = image_bad; |
| 11583 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11584 | image_view_create_info.format = tex_format_bad; |
| 11585 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11586 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11587 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11588 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11589 | image_view_create_info.subresourceRange.aspectMask = |
| 11590 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11591 | |
| 11592 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11593 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11594 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11595 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11596 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11597 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11598 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11599 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11600 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11601 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11602 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11603 | |
| 11604 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11605 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11606 | "ClearDepthStencilImage with a color image."); |
| 11607 | |
| 11608 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11609 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11610 | |
| 11611 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11612 | BeginCommandBuffer(); |
| 11613 | m_commandBuffer->EndRenderPass(); |
| 11614 | |
| 11615 | // Color image |
| 11616 | VkClearColorValue clear_color; |
| 11617 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11618 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11619 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11620 | const int32_t img_width = 32; |
| 11621 | const int32_t img_height = 32; |
| 11622 | VkImageCreateInfo image_create_info = {}; |
| 11623 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11624 | image_create_info.pNext = NULL; |
| 11625 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11626 | image_create_info.format = color_format; |
| 11627 | image_create_info.extent.width = img_width; |
| 11628 | image_create_info.extent.height = img_height; |
| 11629 | image_create_info.extent.depth = 1; |
| 11630 | image_create_info.mipLevels = 1; |
| 11631 | image_create_info.arrayLayers = 1; |
| 11632 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11633 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11634 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11635 | |
| 11636 | vk_testing::Image color_image; |
| 11637 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11638 | reqs); |
| 11639 | |
| 11640 | const VkImageSubresourceRange color_range = |
| 11641 | vk_testing::Image::subresource_range(image_create_info, |
| 11642 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11643 | |
| 11644 | // Depth/Stencil image |
| 11645 | VkClearDepthStencilValue clear_value = {0}; |
| 11646 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11647 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11648 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11649 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11650 | ds_image_create_info.extent.width = 64; |
| 11651 | ds_image_create_info.extent.height = 64; |
| 11652 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11653 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11654 | |
| 11655 | vk_testing::Image ds_image; |
| 11656 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11657 | reqs); |
| 11658 | |
| 11659 | const VkImageSubresourceRange ds_range = |
| 11660 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11661 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11662 | |
| 11663 | m_errorMonitor->SetDesiredFailureMsg( |
| 11664 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11665 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11666 | |
| 11667 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11668 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11669 | &color_range); |
| 11670 | |
| 11671 | m_errorMonitor->VerifyFound(); |
| 11672 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 11673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11674 | "vkCmdClearColorImage called with " |
| 11675 | "image created without " |
| 11676 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 11677 | |
| 11678 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11679 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11680 | &color_range); |
| 11681 | |
| 11682 | m_errorMonitor->VerifyFound(); |
| 11683 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11684 | // Call CmdClearDepthStencilImage with color image |
| 11685 | m_errorMonitor->SetDesiredFailureMsg( |
| 11686 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11687 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11688 | |
| 11689 | vkCmdClearDepthStencilImage( |
| 11690 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11691 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11692 | &ds_range); |
| 11693 | |
| 11694 | m_errorMonitor->VerifyFound(); |
| 11695 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11696 | #endif // IMAGE_TESTS |
| 11697 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11698 | int main(int argc, char **argv) { |
| 11699 | int result; |
| 11700 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11701 | #ifdef ANDROID |
| 11702 | int vulkanSupport = InitVulkan(); |
| 11703 | if (vulkanSupport == 0) |
| 11704 | return 1; |
| 11705 | #endif |
| 11706 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11707 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11708 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11709 | |
| 11710 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11711 | |
| 11712 | result = RUN_ALL_TESTS(); |
| 11713 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11714 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11715 | return result; |
| 11716 | } |