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 | |
| 2732 | if ((m_device->queue_props.empty()) || |
| 2733 | (m_device->queue_props[0].queueCount < 2)) |
| 2734 | return; |
| 2735 | |
| 2736 | m_errorMonitor->ExpectSuccess(); |
| 2737 | |
| 2738 | VkEvent event; |
| 2739 | VkEventCreateInfo event_create_info{}; |
| 2740 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2741 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2742 | |
| 2743 | VkCommandPool command_pool; |
| 2744 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2745 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2746 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2747 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2748 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2749 | &command_pool); |
| 2750 | |
| 2751 | VkCommandBuffer command_buffer; |
| 2752 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2753 | command_buffer_allocate_info.sType = |
| 2754 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2755 | command_buffer_allocate_info.commandPool = command_pool; |
| 2756 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2757 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2758 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2759 | &command_buffer); |
| 2760 | |
| 2761 | VkQueue queue = VK_NULL_HANDLE; |
| 2762 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2763 | 1, &queue); |
| 2764 | |
| 2765 | { |
| 2766 | VkCommandBufferBeginInfo begin_info{}; |
| 2767 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2768 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2769 | |
| 2770 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2771 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2772 | nullptr, 0, nullptr); |
| 2773 | vkCmdResetEvent(command_buffer, event, |
| 2774 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2775 | vkEndCommandBuffer(command_buffer); |
| 2776 | } |
| 2777 | { |
| 2778 | VkSubmitInfo submit_info{}; |
| 2779 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2780 | submit_info.commandBufferCount = 1; |
| 2781 | submit_info.pCommandBuffers = &command_buffer; |
| 2782 | submit_info.signalSemaphoreCount = 0; |
| 2783 | submit_info.pSignalSemaphores = nullptr; |
| 2784 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2785 | } |
| 2786 | { vkSetEvent(m_device->device(), event); } |
| 2787 | |
| 2788 | vkQueueWaitIdle(queue); |
| 2789 | |
| 2790 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2791 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2792 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2793 | |
| 2794 | m_errorMonitor->VerifyNotFound(); |
| 2795 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2796 | // This is a positive test. No errors should be generated. |
| 2797 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2798 | TEST_DESCRIPTION( |
| 2799 | "Issue a query and copy from it on a second command buffer."); |
| 2800 | |
| 2801 | if ((m_device->queue_props.empty()) || |
| 2802 | (m_device->queue_props[0].queueCount < 2)) |
| 2803 | return; |
| 2804 | |
| 2805 | m_errorMonitor->ExpectSuccess(); |
| 2806 | |
| 2807 | VkQueryPool query_pool; |
| 2808 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2809 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2810 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2811 | query_pool_create_info.queryCount = 1; |
| 2812 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2813 | &query_pool); |
| 2814 | |
| 2815 | VkCommandPool command_pool; |
| 2816 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2817 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2818 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2819 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2820 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2821 | &command_pool); |
| 2822 | |
| 2823 | VkCommandBuffer command_buffer[2]; |
| 2824 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2825 | command_buffer_allocate_info.sType = |
| 2826 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2827 | command_buffer_allocate_info.commandPool = command_pool; |
| 2828 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2829 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2830 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2831 | command_buffer); |
| 2832 | |
| 2833 | VkQueue queue = VK_NULL_HANDLE; |
| 2834 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2835 | 1, &queue); |
| 2836 | |
| 2837 | uint32_t qfi = 0; |
| 2838 | VkBufferCreateInfo buff_create_info = {}; |
| 2839 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2840 | buff_create_info.size = 1024; |
| 2841 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2842 | buff_create_info.queueFamilyIndexCount = 1; |
| 2843 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2844 | |
| 2845 | VkResult err; |
| 2846 | VkBuffer buffer; |
| 2847 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2848 | ASSERT_VK_SUCCESS(err); |
| 2849 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2850 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2851 | mem_alloc.pNext = NULL; |
| 2852 | mem_alloc.allocationSize = 1024; |
| 2853 | mem_alloc.memoryTypeIndex = 0; |
| 2854 | |
| 2855 | VkMemoryRequirements memReqs; |
| 2856 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2857 | bool pass = |
| 2858 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2859 | if (!pass) { |
| 2860 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2861 | return; |
| 2862 | } |
| 2863 | |
| 2864 | VkDeviceMemory mem; |
| 2865 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2866 | ASSERT_VK_SUCCESS(err); |
| 2867 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2868 | ASSERT_VK_SUCCESS(err); |
| 2869 | |
| 2870 | { |
| 2871 | VkCommandBufferBeginInfo begin_info{}; |
| 2872 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2873 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2874 | |
| 2875 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2876 | vkCmdWriteTimestamp(command_buffer[0], |
| 2877 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2878 | |
| 2879 | vkEndCommandBuffer(command_buffer[0]); |
| 2880 | |
| 2881 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2882 | |
| 2883 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 2884 | 0, 0, 0); |
| 2885 | |
| 2886 | vkEndCommandBuffer(command_buffer[1]); |
| 2887 | } |
| 2888 | { |
| 2889 | VkSubmitInfo submit_info{}; |
| 2890 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2891 | submit_info.commandBufferCount = 2; |
| 2892 | submit_info.pCommandBuffers = command_buffer; |
| 2893 | submit_info.signalSemaphoreCount = 0; |
| 2894 | submit_info.pSignalSemaphores = nullptr; |
| 2895 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2896 | } |
| 2897 | |
| 2898 | vkQueueWaitIdle(queue); |
| 2899 | |
| 2900 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 2901 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 2902 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2903 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2904 | vkFreeMemory(m_device->device(), mem, NULL); |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2905 | |
| 2906 | m_errorMonitor->VerifyNotFound(); |
| 2907 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2908 | |
| 2909 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 2910 | TEST_DESCRIPTION( |
| 2911 | "Reset an event then set it after the reset has been submitted."); |
| 2912 | |
| 2913 | if ((m_device->queue_props.empty()) || |
| 2914 | (m_device->queue_props[0].queueCount < 2)) |
| 2915 | return; |
| 2916 | |
| 2917 | m_errorMonitor->ExpectSuccess(); |
| 2918 | |
| 2919 | VkEvent event; |
| 2920 | VkEventCreateInfo event_create_info{}; |
| 2921 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2922 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2923 | |
| 2924 | VkCommandPool command_pool; |
| 2925 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2926 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2927 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2928 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2929 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2930 | &command_pool); |
| 2931 | |
| 2932 | VkCommandBuffer command_buffer; |
| 2933 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2934 | command_buffer_allocate_info.sType = |
| 2935 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2936 | command_buffer_allocate_info.commandPool = command_pool; |
| 2937 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2938 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2939 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2940 | &command_buffer); |
| 2941 | |
| 2942 | VkQueue queue = VK_NULL_HANDLE; |
| 2943 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2944 | 1, &queue); |
| 2945 | |
| 2946 | { |
| 2947 | VkCommandBufferBeginInfo begin_info{}; |
| 2948 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2949 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2950 | |
| 2951 | vkCmdResetEvent(command_buffer, event, |
| 2952 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2953 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 2954 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2955 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2956 | nullptr, 0, nullptr); |
| 2957 | vkEndCommandBuffer(command_buffer); |
| 2958 | } |
| 2959 | { |
| 2960 | VkSubmitInfo submit_info{}; |
| 2961 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2962 | submit_info.commandBufferCount = 1; |
| 2963 | submit_info.pCommandBuffers = &command_buffer; |
| 2964 | submit_info.signalSemaphoreCount = 0; |
| 2965 | submit_info.pSignalSemaphores = nullptr; |
| 2966 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2967 | } |
| 2968 | { |
| 2969 | m_errorMonitor->SetDesiredFailureMsg( |
| 2970 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 2971 | "0x1 that is already in use by a " |
| 2972 | "command buffer."); |
| 2973 | vkSetEvent(m_device->device(), event); |
| 2974 | m_errorMonitor->VerifyFound(); |
| 2975 | } |
| 2976 | |
| 2977 | vkQueueWaitIdle(queue); |
| 2978 | |
| 2979 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2980 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2981 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2982 | } |
| 2983 | |
| 2984 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 2985 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 2986 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 2987 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 2988 | "previously revealed a bug so running this positive test " |
| 2989 | "to prevent a regression."); |
| 2990 | m_errorMonitor->ExpectSuccess(); |
| 2991 | |
| 2992 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2993 | VkQueue queue = VK_NULL_HANDLE; |
| 2994 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2995 | 0, &queue); |
| 2996 | |
| 2997 | static const uint32_t NUM_OBJECTS = 2; |
| 2998 | static const uint32_t NUM_FRAMES = 3; |
| 2999 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 3000 | VkFence fences[NUM_OBJECTS] = {}; |
| 3001 | |
| 3002 | VkCommandPool cmd_pool; |
| 3003 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 3004 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3005 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3006 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3007 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 3008 | nullptr, &cmd_pool); |
| 3009 | ASSERT_VK_SUCCESS(err); |
| 3010 | |
| 3011 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3012 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3013 | cmd_buf_info.commandPool = cmd_pool; |
| 3014 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3015 | cmd_buf_info.commandBufferCount = 1; |
| 3016 | |
| 3017 | VkFenceCreateInfo fence_ci = {}; |
| 3018 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3019 | fence_ci.pNext = nullptr; |
| 3020 | fence_ci.flags = 0; |
| 3021 | |
| 3022 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3023 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3024 | &cmd_buffers[i]); |
| 3025 | ASSERT_VK_SUCCESS(err); |
| 3026 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3027 | ASSERT_VK_SUCCESS(err); |
| 3028 | } |
| 3029 | |
| 3030 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3031 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3032 | // Create empty cmd buffer |
| 3033 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3034 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3035 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3036 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3037 | ASSERT_VK_SUCCESS(err); |
| 3038 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3039 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3040 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3041 | VkSubmitInfo submit_info = {}; |
| 3042 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3043 | submit_info.commandBufferCount = 1; |
| 3044 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3045 | // Submit cmd buffer and wait for fence |
| 3046 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3047 | ASSERT_VK_SUCCESS(err); |
| 3048 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3049 | UINT64_MAX); |
| 3050 | ASSERT_VK_SUCCESS(err); |
| 3051 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3052 | ASSERT_VK_SUCCESS(err); |
| 3053 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3054 | } |
| 3055 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3056 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
| 3057 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3058 | vkDestroyFence(m_device->device(), fences[i], nullptr); |
| 3059 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3060 | } |
| 3061 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3062 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3063 | |
| 3064 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3065 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3066 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3067 | if ((m_device->queue_props.empty()) || |
| 3068 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3069 | return; |
| 3070 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3071 | m_errorMonitor->ExpectSuccess(); |
| 3072 | |
| 3073 | VkSemaphore semaphore; |
| 3074 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3075 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3076 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3077 | &semaphore); |
| 3078 | |
| 3079 | VkCommandPool command_pool; |
| 3080 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3081 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3082 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3083 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3084 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3085 | &command_pool); |
| 3086 | |
| 3087 | VkCommandBuffer command_buffer[2]; |
| 3088 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3089 | command_buffer_allocate_info.sType = |
| 3090 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3091 | command_buffer_allocate_info.commandPool = command_pool; |
| 3092 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3093 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3094 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3095 | command_buffer); |
| 3096 | |
| 3097 | VkQueue queue = VK_NULL_HANDLE; |
| 3098 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3099 | 1, &queue); |
| 3100 | |
| 3101 | { |
| 3102 | VkCommandBufferBeginInfo begin_info{}; |
| 3103 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3104 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3105 | |
| 3106 | vkCmdPipelineBarrier(command_buffer[0], |
| 3107 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3108 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3109 | 0, nullptr, 0, nullptr); |
| 3110 | |
| 3111 | VkViewport viewport{}; |
| 3112 | viewport.maxDepth = 1.0f; |
| 3113 | viewport.minDepth = 0.0f; |
| 3114 | viewport.width = 512; |
| 3115 | viewport.height = 512; |
| 3116 | viewport.x = 0; |
| 3117 | viewport.y = 0; |
| 3118 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3119 | vkEndCommandBuffer(command_buffer[0]); |
| 3120 | } |
| 3121 | { |
| 3122 | VkCommandBufferBeginInfo begin_info{}; |
| 3123 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3124 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3125 | |
| 3126 | VkViewport viewport{}; |
| 3127 | viewport.maxDepth = 1.0f; |
| 3128 | viewport.minDepth = 0.0f; |
| 3129 | viewport.width = 512; |
| 3130 | viewport.height = 512; |
| 3131 | viewport.x = 0; |
| 3132 | viewport.y = 0; |
| 3133 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3134 | vkEndCommandBuffer(command_buffer[1]); |
| 3135 | } |
| 3136 | { |
| 3137 | VkSubmitInfo submit_info{}; |
| 3138 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3139 | submit_info.commandBufferCount = 1; |
| 3140 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3141 | submit_info.signalSemaphoreCount = 1; |
| 3142 | submit_info.pSignalSemaphores = &semaphore; |
| 3143 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3144 | } |
| 3145 | { |
| 3146 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3147 | VkSubmitInfo submit_info{}; |
| 3148 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3149 | submit_info.commandBufferCount = 1; |
| 3150 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3151 | submit_info.waitSemaphoreCount = 1; |
| 3152 | submit_info.pWaitSemaphores = &semaphore; |
| 3153 | submit_info.pWaitDstStageMask = flags; |
| 3154 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3155 | } |
| 3156 | |
| 3157 | vkQueueWaitIdle(m_device->m_queue); |
| 3158 | |
| 3159 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3160 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3161 | &command_buffer[0]); |
| 3162 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3163 | |
| 3164 | m_errorMonitor->VerifyNotFound(); |
| 3165 | } |
| 3166 | |
| 3167 | // This is a positive test. No errors should be generated. |
| 3168 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3169 | |
| 3170 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3171 | "submitted on separate queues, the second having a fence" |
| 3172 | "followed by a QueueWaitIdle."); |
| 3173 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3174 | if ((m_device->queue_props.empty()) || |
| 3175 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3176 | return; |
| 3177 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3178 | m_errorMonitor->ExpectSuccess(); |
| 3179 | |
| 3180 | VkFence fence; |
| 3181 | VkFenceCreateInfo fence_create_info{}; |
| 3182 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3183 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3184 | |
| 3185 | VkSemaphore semaphore; |
| 3186 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3187 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3188 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3189 | &semaphore); |
| 3190 | |
| 3191 | VkCommandPool command_pool; |
| 3192 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3193 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3194 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3195 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3196 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3197 | &command_pool); |
| 3198 | |
| 3199 | VkCommandBuffer command_buffer[2]; |
| 3200 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3201 | command_buffer_allocate_info.sType = |
| 3202 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3203 | command_buffer_allocate_info.commandPool = command_pool; |
| 3204 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3205 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3206 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3207 | command_buffer); |
| 3208 | |
| 3209 | VkQueue queue = VK_NULL_HANDLE; |
| 3210 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3211 | 1, &queue); |
| 3212 | |
| 3213 | { |
| 3214 | VkCommandBufferBeginInfo begin_info{}; |
| 3215 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3216 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3217 | |
| 3218 | vkCmdPipelineBarrier(command_buffer[0], |
| 3219 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3220 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3221 | 0, nullptr, 0, nullptr); |
| 3222 | |
| 3223 | VkViewport viewport{}; |
| 3224 | viewport.maxDepth = 1.0f; |
| 3225 | viewport.minDepth = 0.0f; |
| 3226 | viewport.width = 512; |
| 3227 | viewport.height = 512; |
| 3228 | viewport.x = 0; |
| 3229 | viewport.y = 0; |
| 3230 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3231 | vkEndCommandBuffer(command_buffer[0]); |
| 3232 | } |
| 3233 | { |
| 3234 | VkCommandBufferBeginInfo begin_info{}; |
| 3235 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3236 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3237 | |
| 3238 | VkViewport viewport{}; |
| 3239 | viewport.maxDepth = 1.0f; |
| 3240 | viewport.minDepth = 0.0f; |
| 3241 | viewport.width = 512; |
| 3242 | viewport.height = 512; |
| 3243 | viewport.x = 0; |
| 3244 | viewport.y = 0; |
| 3245 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3246 | vkEndCommandBuffer(command_buffer[1]); |
| 3247 | } |
| 3248 | { |
| 3249 | VkSubmitInfo submit_info{}; |
| 3250 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3251 | submit_info.commandBufferCount = 1; |
| 3252 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3253 | submit_info.signalSemaphoreCount = 1; |
| 3254 | submit_info.pSignalSemaphores = &semaphore; |
| 3255 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3256 | } |
| 3257 | { |
| 3258 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3259 | VkSubmitInfo submit_info{}; |
| 3260 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3261 | submit_info.commandBufferCount = 1; |
| 3262 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3263 | submit_info.waitSemaphoreCount = 1; |
| 3264 | submit_info.pWaitSemaphores = &semaphore; |
| 3265 | submit_info.pWaitDstStageMask = flags; |
| 3266 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3267 | } |
| 3268 | |
| 3269 | vkQueueWaitIdle(m_device->m_queue); |
| 3270 | |
| 3271 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3272 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3273 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3274 | &command_buffer[0]); |
| 3275 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3276 | |
| 3277 | m_errorMonitor->VerifyNotFound(); |
| 3278 | } |
| 3279 | |
| 3280 | // This is a positive test. No errors should be generated. |
| 3281 | TEST_F(VkLayerTest, |
| 3282 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3283 | |
| 3284 | TEST_DESCRIPTION( |
| 3285 | "Two command buffers, each in a separate QueueSubmit call " |
| 3286 | "submitted on separate queues, the second having a fence" |
| 3287 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3288 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3289 | if ((m_device->queue_props.empty()) || |
| 3290 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3291 | return; |
| 3292 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3293 | m_errorMonitor->ExpectSuccess(); |
| 3294 | |
| 3295 | VkFence fence; |
| 3296 | VkFenceCreateInfo fence_create_info{}; |
| 3297 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3298 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3299 | |
| 3300 | VkSemaphore semaphore; |
| 3301 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3302 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3303 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3304 | &semaphore); |
| 3305 | |
| 3306 | VkCommandPool command_pool; |
| 3307 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3308 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3309 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3310 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3311 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3312 | &command_pool); |
| 3313 | |
| 3314 | VkCommandBuffer command_buffer[2]; |
| 3315 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3316 | command_buffer_allocate_info.sType = |
| 3317 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3318 | command_buffer_allocate_info.commandPool = command_pool; |
| 3319 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3320 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3321 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3322 | command_buffer); |
| 3323 | |
| 3324 | VkQueue queue = VK_NULL_HANDLE; |
| 3325 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3326 | 1, &queue); |
| 3327 | |
| 3328 | { |
| 3329 | VkCommandBufferBeginInfo begin_info{}; |
| 3330 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3331 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3332 | |
| 3333 | vkCmdPipelineBarrier(command_buffer[0], |
| 3334 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3335 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3336 | 0, nullptr, 0, nullptr); |
| 3337 | |
| 3338 | VkViewport viewport{}; |
| 3339 | viewport.maxDepth = 1.0f; |
| 3340 | viewport.minDepth = 0.0f; |
| 3341 | viewport.width = 512; |
| 3342 | viewport.height = 512; |
| 3343 | viewport.x = 0; |
| 3344 | viewport.y = 0; |
| 3345 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3346 | vkEndCommandBuffer(command_buffer[0]); |
| 3347 | } |
| 3348 | { |
| 3349 | VkCommandBufferBeginInfo begin_info{}; |
| 3350 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3351 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3352 | |
| 3353 | VkViewport viewport{}; |
| 3354 | viewport.maxDepth = 1.0f; |
| 3355 | viewport.minDepth = 0.0f; |
| 3356 | viewport.width = 512; |
| 3357 | viewport.height = 512; |
| 3358 | viewport.x = 0; |
| 3359 | viewport.y = 0; |
| 3360 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3361 | vkEndCommandBuffer(command_buffer[1]); |
| 3362 | } |
| 3363 | { |
| 3364 | VkSubmitInfo submit_info{}; |
| 3365 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3366 | submit_info.commandBufferCount = 1; |
| 3367 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3368 | submit_info.signalSemaphoreCount = 1; |
| 3369 | submit_info.pSignalSemaphores = &semaphore; |
| 3370 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3371 | } |
| 3372 | { |
| 3373 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3374 | VkSubmitInfo submit_info{}; |
| 3375 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3376 | submit_info.commandBufferCount = 1; |
| 3377 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3378 | submit_info.waitSemaphoreCount = 1; |
| 3379 | submit_info.pWaitSemaphores = &semaphore; |
| 3380 | submit_info.pWaitDstStageMask = flags; |
| 3381 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3382 | } |
| 3383 | |
| 3384 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3385 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3386 | |
| 3387 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3388 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3389 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3390 | &command_buffer[0]); |
| 3391 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3392 | |
| 3393 | m_errorMonitor->VerifyNotFound(); |
| 3394 | } |
| 3395 | |
| 3396 | // This is a positive test. No errors should be generated. |
| 3397 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3398 | |
| 3399 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3400 | "submitted on separate queues, the second having a fence, " |
| 3401 | "followed by a WaitForFences call."); |
| 3402 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3403 | if ((m_device->queue_props.empty()) || |
| 3404 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3405 | return; |
| 3406 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3407 | m_errorMonitor->ExpectSuccess(); |
| 3408 | |
| 3409 | VkFence fence; |
| 3410 | VkFenceCreateInfo fence_create_info{}; |
| 3411 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3412 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3413 | |
| 3414 | VkSemaphore semaphore; |
| 3415 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3416 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3417 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3418 | &semaphore); |
| 3419 | |
| 3420 | VkCommandPool command_pool; |
| 3421 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3422 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3423 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3424 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3425 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3426 | &command_pool); |
| 3427 | |
| 3428 | VkCommandBuffer command_buffer[2]; |
| 3429 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3430 | command_buffer_allocate_info.sType = |
| 3431 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3432 | command_buffer_allocate_info.commandPool = command_pool; |
| 3433 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3434 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3435 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3436 | command_buffer); |
| 3437 | |
| 3438 | VkQueue queue = VK_NULL_HANDLE; |
| 3439 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3440 | 1, &queue); |
| 3441 | |
| 3442 | |
| 3443 | { |
| 3444 | VkCommandBufferBeginInfo begin_info{}; |
| 3445 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3446 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3447 | |
| 3448 | vkCmdPipelineBarrier(command_buffer[0], |
| 3449 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3450 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3451 | 0, nullptr, 0, nullptr); |
| 3452 | |
| 3453 | VkViewport viewport{}; |
| 3454 | viewport.maxDepth = 1.0f; |
| 3455 | viewport.minDepth = 0.0f; |
| 3456 | viewport.width = 512; |
| 3457 | viewport.height = 512; |
| 3458 | viewport.x = 0; |
| 3459 | viewport.y = 0; |
| 3460 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3461 | vkEndCommandBuffer(command_buffer[0]); |
| 3462 | } |
| 3463 | { |
| 3464 | VkCommandBufferBeginInfo begin_info{}; |
| 3465 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3466 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3467 | |
| 3468 | VkViewport viewport{}; |
| 3469 | viewport.maxDepth = 1.0f; |
| 3470 | viewport.minDepth = 0.0f; |
| 3471 | viewport.width = 512; |
| 3472 | viewport.height = 512; |
| 3473 | viewport.x = 0; |
| 3474 | viewport.y = 0; |
| 3475 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3476 | vkEndCommandBuffer(command_buffer[1]); |
| 3477 | } |
| 3478 | { |
| 3479 | VkSubmitInfo submit_info{}; |
| 3480 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3481 | submit_info.commandBufferCount = 1; |
| 3482 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3483 | submit_info.signalSemaphoreCount = 1; |
| 3484 | submit_info.pSignalSemaphores = &semaphore; |
| 3485 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3486 | } |
| 3487 | { |
| 3488 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3489 | VkSubmitInfo submit_info{}; |
| 3490 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3491 | submit_info.commandBufferCount = 1; |
| 3492 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3493 | submit_info.waitSemaphoreCount = 1; |
| 3494 | submit_info.pWaitSemaphores = &semaphore; |
| 3495 | submit_info.pWaitDstStageMask = flags; |
| 3496 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3497 | } |
| 3498 | |
| 3499 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3500 | |
| 3501 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3502 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3503 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3504 | &command_buffer[0]); |
| 3505 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3506 | |
| 3507 | m_errorMonitor->VerifyNotFound(); |
| 3508 | } |
| 3509 | |
| 3510 | // This is a positive test. No errors should be generated. |
| 3511 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3512 | |
| 3513 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3514 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3515 | "second having a fence, " |
| 3516 | "followed by a WaitForFences call."); |
| 3517 | |
| 3518 | m_errorMonitor->ExpectSuccess(); |
| 3519 | |
| 3520 | VkFence fence; |
| 3521 | VkFenceCreateInfo fence_create_info{}; |
| 3522 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3523 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3524 | |
| 3525 | VkSemaphore semaphore; |
| 3526 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3527 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3528 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3529 | &semaphore); |
| 3530 | |
| 3531 | VkCommandPool command_pool; |
| 3532 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3533 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3534 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3535 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3536 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3537 | &command_pool); |
| 3538 | |
| 3539 | VkCommandBuffer command_buffer[2]; |
| 3540 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3541 | command_buffer_allocate_info.sType = |
| 3542 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3543 | command_buffer_allocate_info.commandPool = command_pool; |
| 3544 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3545 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3546 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3547 | command_buffer); |
| 3548 | |
| 3549 | { |
| 3550 | VkCommandBufferBeginInfo begin_info{}; |
| 3551 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3552 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3553 | |
| 3554 | vkCmdPipelineBarrier(command_buffer[0], |
| 3555 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3556 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3557 | 0, nullptr, 0, nullptr); |
| 3558 | |
| 3559 | VkViewport viewport{}; |
| 3560 | viewport.maxDepth = 1.0f; |
| 3561 | viewport.minDepth = 0.0f; |
| 3562 | viewport.width = 512; |
| 3563 | viewport.height = 512; |
| 3564 | viewport.x = 0; |
| 3565 | viewport.y = 0; |
| 3566 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3567 | vkEndCommandBuffer(command_buffer[0]); |
| 3568 | } |
| 3569 | { |
| 3570 | VkCommandBufferBeginInfo begin_info{}; |
| 3571 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3572 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3573 | |
| 3574 | VkViewport viewport{}; |
| 3575 | viewport.maxDepth = 1.0f; |
| 3576 | viewport.minDepth = 0.0f; |
| 3577 | viewport.width = 512; |
| 3578 | viewport.height = 512; |
| 3579 | viewport.x = 0; |
| 3580 | viewport.y = 0; |
| 3581 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3582 | vkEndCommandBuffer(command_buffer[1]); |
| 3583 | } |
| 3584 | { |
| 3585 | VkSubmitInfo submit_info{}; |
| 3586 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3587 | submit_info.commandBufferCount = 1; |
| 3588 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3589 | submit_info.signalSemaphoreCount = 1; |
| 3590 | submit_info.pSignalSemaphores = &semaphore; |
| 3591 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3592 | } |
| 3593 | { |
| 3594 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3595 | VkSubmitInfo submit_info{}; |
| 3596 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3597 | submit_info.commandBufferCount = 1; |
| 3598 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3599 | submit_info.waitSemaphoreCount = 1; |
| 3600 | submit_info.pWaitSemaphores = &semaphore; |
| 3601 | submit_info.pWaitDstStageMask = flags; |
| 3602 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3603 | } |
| 3604 | |
| 3605 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3606 | |
| 3607 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3608 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3609 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3610 | &command_buffer[0]); |
| 3611 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3612 | |
| 3613 | m_errorMonitor->VerifyNotFound(); |
| 3614 | } |
| 3615 | |
| 3616 | // This is a positive test. No errors should be generated. |
| 3617 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3618 | |
| 3619 | TEST_DESCRIPTION( |
| 3620 | "Two command buffers, each in a separate QueueSubmit call " |
| 3621 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3622 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3623 | |
| 3624 | m_errorMonitor->ExpectSuccess(); |
| 3625 | |
| 3626 | VkFence fence; |
| 3627 | VkFenceCreateInfo fence_create_info{}; |
| 3628 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3629 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3630 | |
| 3631 | VkCommandPool command_pool; |
| 3632 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3633 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3634 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3635 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3636 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3637 | &command_pool); |
| 3638 | |
| 3639 | VkCommandBuffer command_buffer[2]; |
| 3640 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3641 | command_buffer_allocate_info.sType = |
| 3642 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3643 | command_buffer_allocate_info.commandPool = command_pool; |
| 3644 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3645 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3646 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3647 | command_buffer); |
| 3648 | |
| 3649 | { |
| 3650 | VkCommandBufferBeginInfo begin_info{}; |
| 3651 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3652 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3653 | |
| 3654 | vkCmdPipelineBarrier(command_buffer[0], |
| 3655 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3656 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3657 | 0, nullptr, 0, nullptr); |
| 3658 | |
| 3659 | VkViewport viewport{}; |
| 3660 | viewport.maxDepth = 1.0f; |
| 3661 | viewport.minDepth = 0.0f; |
| 3662 | viewport.width = 512; |
| 3663 | viewport.height = 512; |
| 3664 | viewport.x = 0; |
| 3665 | viewport.y = 0; |
| 3666 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3667 | vkEndCommandBuffer(command_buffer[0]); |
| 3668 | } |
| 3669 | { |
| 3670 | VkCommandBufferBeginInfo begin_info{}; |
| 3671 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3672 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3673 | |
| 3674 | VkViewport viewport{}; |
| 3675 | viewport.maxDepth = 1.0f; |
| 3676 | viewport.minDepth = 0.0f; |
| 3677 | viewport.width = 512; |
| 3678 | viewport.height = 512; |
| 3679 | viewport.x = 0; |
| 3680 | viewport.y = 0; |
| 3681 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3682 | vkEndCommandBuffer(command_buffer[1]); |
| 3683 | } |
| 3684 | { |
| 3685 | VkSubmitInfo submit_info{}; |
| 3686 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3687 | submit_info.commandBufferCount = 1; |
| 3688 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3689 | submit_info.signalSemaphoreCount = 0; |
| 3690 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3691 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3692 | } |
| 3693 | { |
| 3694 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3695 | VkSubmitInfo submit_info{}; |
| 3696 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3697 | submit_info.commandBufferCount = 1; |
| 3698 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3699 | submit_info.waitSemaphoreCount = 0; |
| 3700 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3701 | submit_info.pWaitDstStageMask = flags; |
| 3702 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3703 | } |
| 3704 | |
| 3705 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3706 | |
| 3707 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3708 | |
| 3709 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3710 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3711 | &command_buffer[0]); |
| 3712 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3713 | |
| 3714 | m_errorMonitor->VerifyNotFound(); |
| 3715 | } |
| 3716 | |
| 3717 | // This is a positive test. No errors should be generated. |
| 3718 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3719 | |
| 3720 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3721 | "on the same queue, the second having a fence, followed " |
| 3722 | "by a WaitForFences call."); |
| 3723 | |
| 3724 | m_errorMonitor->ExpectSuccess(); |
| 3725 | |
| 3726 | VkFence fence; |
| 3727 | VkFenceCreateInfo fence_create_info{}; |
| 3728 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3729 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3730 | |
| 3731 | VkCommandPool command_pool; |
| 3732 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3733 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3734 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3735 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3736 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3737 | &command_pool); |
| 3738 | |
| 3739 | VkCommandBuffer command_buffer[2]; |
| 3740 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3741 | command_buffer_allocate_info.sType = |
| 3742 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3743 | command_buffer_allocate_info.commandPool = command_pool; |
| 3744 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3745 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3746 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3747 | command_buffer); |
| 3748 | |
| 3749 | { |
| 3750 | VkCommandBufferBeginInfo begin_info{}; |
| 3751 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3752 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3753 | |
| 3754 | vkCmdPipelineBarrier(command_buffer[0], |
| 3755 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3756 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3757 | 0, nullptr, 0, nullptr); |
| 3758 | |
| 3759 | VkViewport viewport{}; |
| 3760 | viewport.maxDepth = 1.0f; |
| 3761 | viewport.minDepth = 0.0f; |
| 3762 | viewport.width = 512; |
| 3763 | viewport.height = 512; |
| 3764 | viewport.x = 0; |
| 3765 | viewport.y = 0; |
| 3766 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3767 | vkEndCommandBuffer(command_buffer[0]); |
| 3768 | } |
| 3769 | { |
| 3770 | VkCommandBufferBeginInfo begin_info{}; |
| 3771 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3772 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3773 | |
| 3774 | VkViewport viewport{}; |
| 3775 | viewport.maxDepth = 1.0f; |
| 3776 | viewport.minDepth = 0.0f; |
| 3777 | viewport.width = 512; |
| 3778 | viewport.height = 512; |
| 3779 | viewport.x = 0; |
| 3780 | viewport.y = 0; |
| 3781 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3782 | vkEndCommandBuffer(command_buffer[1]); |
| 3783 | } |
| 3784 | { |
| 3785 | VkSubmitInfo submit_info{}; |
| 3786 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3787 | submit_info.commandBufferCount = 1; |
| 3788 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3789 | submit_info.signalSemaphoreCount = 0; |
| 3790 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3791 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3792 | } |
| 3793 | { |
| 3794 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3795 | VkSubmitInfo submit_info{}; |
| 3796 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3797 | submit_info.commandBufferCount = 1; |
| 3798 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3799 | submit_info.waitSemaphoreCount = 0; |
| 3800 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3801 | submit_info.pWaitDstStageMask = flags; |
| 3802 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3803 | } |
| 3804 | |
| 3805 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3806 | |
| 3807 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3808 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3809 | &command_buffer[0]); |
| 3810 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3811 | |
| 3812 | m_errorMonitor->VerifyNotFound(); |
| 3813 | } |
| 3814 | |
| 3815 | // This is a positive test. No errors should be generated. |
| 3816 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3817 | |
| 3818 | TEST_DESCRIPTION( |
| 3819 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3820 | "QueueSubmit call followed by a WaitForFences call."); |
| 3821 | |
| 3822 | m_errorMonitor->ExpectSuccess(); |
| 3823 | |
| 3824 | VkFence fence; |
| 3825 | VkFenceCreateInfo fence_create_info{}; |
| 3826 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3827 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3828 | |
| 3829 | VkSemaphore semaphore; |
| 3830 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3831 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3832 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3833 | &semaphore); |
| 3834 | |
| 3835 | VkCommandPool command_pool; |
| 3836 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3837 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3838 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3839 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3840 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3841 | &command_pool); |
| 3842 | |
| 3843 | VkCommandBuffer command_buffer[2]; |
| 3844 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3845 | command_buffer_allocate_info.sType = |
| 3846 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3847 | command_buffer_allocate_info.commandPool = command_pool; |
| 3848 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3849 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3850 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3851 | command_buffer); |
| 3852 | |
| 3853 | { |
| 3854 | VkCommandBufferBeginInfo begin_info{}; |
| 3855 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3856 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3857 | |
| 3858 | vkCmdPipelineBarrier(command_buffer[0], |
| 3859 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3860 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3861 | 0, nullptr, 0, nullptr); |
| 3862 | |
| 3863 | VkViewport viewport{}; |
| 3864 | viewport.maxDepth = 1.0f; |
| 3865 | viewport.minDepth = 0.0f; |
| 3866 | viewport.width = 512; |
| 3867 | viewport.height = 512; |
| 3868 | viewport.x = 0; |
| 3869 | viewport.y = 0; |
| 3870 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3871 | vkEndCommandBuffer(command_buffer[0]); |
| 3872 | } |
| 3873 | { |
| 3874 | VkCommandBufferBeginInfo begin_info{}; |
| 3875 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3876 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3877 | |
| 3878 | VkViewport viewport{}; |
| 3879 | viewport.maxDepth = 1.0f; |
| 3880 | viewport.minDepth = 0.0f; |
| 3881 | viewport.width = 512; |
| 3882 | viewport.height = 512; |
| 3883 | viewport.x = 0; |
| 3884 | viewport.y = 0; |
| 3885 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3886 | vkEndCommandBuffer(command_buffer[1]); |
| 3887 | } |
| 3888 | { |
| 3889 | VkSubmitInfo submit_info[2]; |
| 3890 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3891 | |
| 3892 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3893 | submit_info[0].pNext = NULL; |
| 3894 | submit_info[0].commandBufferCount = 1; |
| 3895 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3896 | submit_info[0].signalSemaphoreCount = 1; |
| 3897 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3898 | submit_info[0].waitSemaphoreCount = 0; |
| 3899 | submit_info[0].pWaitSemaphores = NULL; |
| 3900 | submit_info[0].pWaitDstStageMask = 0; |
| 3901 | |
| 3902 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3903 | submit_info[1].pNext = NULL; |
| 3904 | submit_info[1].commandBufferCount = 1; |
| 3905 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3906 | submit_info[1].waitSemaphoreCount = 1; |
| 3907 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3908 | submit_info[1].pWaitDstStageMask = flags; |
| 3909 | submit_info[1].signalSemaphoreCount = 0; |
| 3910 | submit_info[1].pSignalSemaphores = NULL; |
| 3911 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3912 | } |
| 3913 | |
| 3914 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3915 | |
| 3916 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3917 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3918 | &command_buffer[0]); |
| 3919 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3920 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3921 | |
| 3922 | m_errorMonitor->VerifyNotFound(); |
| 3923 | } |
| 3924 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3925 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3926 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3927 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 3928 | "state is required but not correctly bound."); |
| 3929 | |
| 3930 | // Dynamic depth bias |
| 3931 | m_errorMonitor->SetDesiredFailureMsg( |
| 3932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3933 | "Dynamic depth bias state not set for this command buffer"); |
| 3934 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3935 | BsoFailDepthBias); |
| 3936 | m_errorMonitor->VerifyFound(); |
| 3937 | } |
| 3938 | |
| 3939 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 3940 | TEST_DESCRIPTION( |
| 3941 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 3942 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3943 | |
| 3944 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3945 | m_errorMonitor->SetDesiredFailureMsg( |
| 3946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3947 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3949 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3950 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 3954 | TEST_DESCRIPTION( |
| 3955 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 3956 | "state is required but not correctly bound."); |
| 3957 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3958 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3959 | m_errorMonitor->SetDesiredFailureMsg( |
| 3960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3961 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3962 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3963 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3964 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3965 | } |
| 3966 | |
| 3967 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 3968 | TEST_DESCRIPTION( |
| 3969 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 3970 | "state is required but not correctly bound."); |
| 3971 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3972 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3973 | m_errorMonitor->SetDesiredFailureMsg( |
| 3974 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3975 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3976 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3977 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3978 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3979 | } |
| 3980 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3981 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3982 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3983 | "Run a simple draw calls to validate failure when Blend Constants " |
| 3984 | "dynamic state is required but not correctly bound."); |
| 3985 | // Dynamic blend constant state |
| 3986 | m_errorMonitor->SetDesiredFailureMsg( |
| 3987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3988 | "Dynamic blend constants state not set for this command buffer"); |
| 3989 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3990 | BsoFailBlend); |
| 3991 | m_errorMonitor->VerifyFound(); |
| 3992 | } |
| 3993 | |
| 3994 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 3995 | TEST_DESCRIPTION( |
| 3996 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3997 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3998 | if (!m_device->phy().features().depthBounds) { |
| 3999 | printf("Device does not support depthBounds test; skipped.\n"); |
| 4000 | return; |
| 4001 | } |
| 4002 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4003 | m_errorMonitor->SetDesiredFailureMsg( |
| 4004 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4005 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4006 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4007 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4008 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4009 | } |
| 4010 | |
| 4011 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 4012 | TEST_DESCRIPTION( |
| 4013 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4014 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4015 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4016 | m_errorMonitor->SetDesiredFailureMsg( |
| 4017 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4018 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4019 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4020 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4021 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4022 | } |
| 4023 | |
| 4024 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4025 | TEST_DESCRIPTION( |
| 4026 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4027 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4028 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4029 | m_errorMonitor->SetDesiredFailureMsg( |
| 4030 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4031 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4032 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4033 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4034 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4035 | } |
| 4036 | |
| 4037 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4038 | TEST_DESCRIPTION( |
| 4039 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4040 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4041 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4042 | m_errorMonitor->SetDesiredFailureMsg( |
| 4043 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4044 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4045 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4046 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4047 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4048 | } |
| 4049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4050 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4051 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | m_errorMonitor->SetDesiredFailureMsg( |
| 4054 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4055 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4056 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4057 | |
| 4058 | VkFenceCreateInfo fenceInfo = {}; |
| 4059 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4060 | fenceInfo.pNext = NULL; |
| 4061 | fenceInfo.flags = 0; |
| 4062 | |
| 4063 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4064 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4065 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4067 | // We luck out b/c by default the framework creates CB w/ the |
| 4068 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4069 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4071 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4072 | EndCommandBuffer(); |
| 4073 | |
| 4074 | testFence.init(*m_device, fenceInfo); |
| 4075 | |
| 4076 | // Bypass framework since it does the waits automatically |
| 4077 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4078 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4079 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4080 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4081 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4082 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4083 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4084 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4085 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4086 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4087 | submit_info.pSignalSemaphores = NULL; |
| 4088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4089 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 4090 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4091 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4092 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4093 | // submitted once |
| 4094 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4096 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4097 | } |
| 4098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4099 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4100 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4101 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4102 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4103 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4104 | "Unable to allocate 1 descriptors of " |
| 4105 | "type " |
| 4106 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4107 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4108 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4109 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4110 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4111 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4112 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4113 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4114 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4115 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4116 | |
| 4117 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4119 | ds_pool_ci.pNext = NULL; |
| 4120 | ds_pool_ci.flags = 0; |
| 4121 | ds_pool_ci.maxSets = 1; |
| 4122 | ds_pool_ci.poolSizeCount = 1; |
| 4123 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4124 | |
| 4125 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4126 | err = |
| 4127 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4128 | ASSERT_VK_SUCCESS(err); |
| 4129 | |
| 4130 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4131 | dsl_binding.binding = 0; |
| 4132 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4133 | dsl_binding.descriptorCount = 1; |
| 4134 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4135 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4136 | |
| 4137 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4139 | ds_layout_ci.pNext = NULL; |
| 4140 | ds_layout_ci.bindingCount = 1; |
| 4141 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4142 | |
| 4143 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4144 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4145 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4146 | ASSERT_VK_SUCCESS(err); |
| 4147 | |
| 4148 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4149 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4150 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4151 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4152 | alloc_info.descriptorPool = ds_pool; |
| 4153 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4154 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4155 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4156 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4157 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4158 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4159 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4160 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4161 | } |
| 4162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4163 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4164 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4166 | m_errorMonitor->SetDesiredFailureMsg( |
| 4167 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4168 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4169 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4170 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4171 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4172 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4173 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4174 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4175 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4176 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4177 | |
| 4178 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4179 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4180 | ds_pool_ci.pNext = NULL; |
| 4181 | ds_pool_ci.maxSets = 1; |
| 4182 | ds_pool_ci.poolSizeCount = 1; |
| 4183 | ds_pool_ci.flags = 0; |
| 4184 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4185 | // app can only call vkResetDescriptorPool on this pool.; |
| 4186 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4187 | |
| 4188 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4189 | err = |
| 4190 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4191 | ASSERT_VK_SUCCESS(err); |
| 4192 | |
| 4193 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4194 | dsl_binding.binding = 0; |
| 4195 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4196 | dsl_binding.descriptorCount = 1; |
| 4197 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4198 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4199 | |
| 4200 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4201 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4202 | ds_layout_ci.pNext = NULL; |
| 4203 | ds_layout_ci.bindingCount = 1; |
| 4204 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4205 | |
| 4206 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4208 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4209 | ASSERT_VK_SUCCESS(err); |
| 4210 | |
| 4211 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4212 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4213 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4214 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4215 | alloc_info.descriptorPool = ds_pool; |
| 4216 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4217 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4218 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4219 | ASSERT_VK_SUCCESS(err); |
| 4220 | |
| 4221 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4222 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4223 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4224 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4225 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4226 | } |
| 4227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4228 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4229 | // Attempt to clear Descriptor Pool with bad object. |
| 4230 | // ObjectTracker should catch this. |
| 4231 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4232 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4233 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4234 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4235 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4236 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4237 | } |
| 4238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4240 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4241 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4242 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4243 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4244 | |
| 4245 | uint64_t fake_set_handle = 0xbaad6001; |
| 4246 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4247 | VkResult err; |
| 4248 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4249 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4250 | |
| 4251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4252 | |
| 4253 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4254 | layout_bindings[0].binding = 0; |
| 4255 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4256 | layout_bindings[0].descriptorCount = 1; |
| 4257 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4258 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4259 | |
| 4260 | VkDescriptorSetLayout descriptor_set_layout; |
| 4261 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4262 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4263 | dslci.pNext = NULL; |
| 4264 | dslci.bindingCount = 1; |
| 4265 | dslci.pBindings = layout_bindings; |
| 4266 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4267 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4268 | |
| 4269 | VkPipelineLayout pipeline_layout; |
| 4270 | VkPipelineLayoutCreateInfo plci = {}; |
| 4271 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4272 | plci.pNext = NULL; |
| 4273 | plci.setLayoutCount = 1; |
| 4274 | plci.pSetLayouts = &descriptor_set_layout; |
| 4275 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4276 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4277 | |
| 4278 | BeginCommandBuffer(); |
| 4279 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4280 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4281 | m_errorMonitor->VerifyFound(); |
| 4282 | EndCommandBuffer(); |
| 4283 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4284 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4285 | } |
| 4286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4287 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4288 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4289 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4290 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4291 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4292 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4293 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4294 | |
| 4295 | VkPipelineLayout pipeline_layout; |
| 4296 | VkPipelineLayoutCreateInfo plci = {}; |
| 4297 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4298 | plci.pNext = NULL; |
| 4299 | plci.setLayoutCount = 1; |
| 4300 | plci.pSetLayouts = &bad_layout; |
| 4301 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4302 | |
| 4303 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4304 | } |
| 4305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4306 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4307 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4308 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4309 | // Create a valid cmd buffer |
| 4310 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4311 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4312 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4313 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4314 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4316 | BeginCommandBuffer(); |
| 4317 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4318 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4319 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4320 | // Now issue a draw call with no pipeline bound |
| 4321 | m_errorMonitor->SetDesiredFailureMsg( |
| 4322 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4323 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4324 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4325 | BeginCommandBuffer(); |
| 4326 | Draw(1, 0, 0, 0); |
| 4327 | m_errorMonitor->VerifyFound(); |
| 4328 | // Finally same check once more but with Dispatch/Compute |
| 4329 | m_errorMonitor->SetDesiredFailureMsg( |
| 4330 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4331 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4332 | BeginCommandBuffer(); |
| 4333 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4334 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4335 | } |
| 4336 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4338 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4339 | // CommandBuffer |
| 4340 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4341 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4342 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4343 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4344 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4345 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4346 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4348 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4349 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4350 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4351 | |
| 4352 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4353 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4354 | ds_pool_ci.pNext = NULL; |
| 4355 | ds_pool_ci.maxSets = 1; |
| 4356 | ds_pool_ci.poolSizeCount = 1; |
| 4357 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4358 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4359 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | err = |
| 4361 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4362 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4363 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4364 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4365 | dsl_binding.binding = 0; |
| 4366 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4367 | dsl_binding.descriptorCount = 1; |
| 4368 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4369 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4370 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4371 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4372 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4373 | ds_layout_ci.pNext = NULL; |
| 4374 | ds_layout_ci.bindingCount = 1; |
| 4375 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4376 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4377 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4378 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4379 | ASSERT_VK_SUCCESS(err); |
| 4380 | |
| 4381 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4382 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4383 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4384 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4385 | alloc_info.descriptorPool = ds_pool; |
| 4386 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4387 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4388 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4389 | ASSERT_VK_SUCCESS(err); |
| 4390 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4391 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4392 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4393 | pipeline_layout_ci.pNext = NULL; |
| 4394 | pipeline_layout_ci.setLayoutCount = 1; |
| 4395 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4396 | |
| 4397 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4399 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4400 | ASSERT_VK_SUCCESS(err); |
| 4401 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4402 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4403 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4404 | // 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] | 4405 | // on more devices |
| 4406 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4407 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4408 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4409 | VkPipelineObj pipe(m_device); |
| 4410 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4411 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4412 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4413 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4414 | |
| 4415 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4416 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4417 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4418 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4419 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4420 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4422 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4424 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4425 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4426 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4427 | } |
| 4428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4429 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4430 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4433 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4434 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4435 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4436 | |
| 4437 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4438 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4439 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4440 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4441 | |
| 4442 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4443 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4444 | ds_pool_ci.pNext = NULL; |
| 4445 | ds_pool_ci.maxSets = 1; |
| 4446 | ds_pool_ci.poolSizeCount = 1; |
| 4447 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4448 | |
| 4449 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | err = |
| 4451 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4452 | ASSERT_VK_SUCCESS(err); |
| 4453 | |
| 4454 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | dsl_binding.binding = 0; |
| 4456 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4457 | dsl_binding.descriptorCount = 1; |
| 4458 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4459 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4460 | |
| 4461 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4462 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4463 | ds_layout_ci.pNext = NULL; |
| 4464 | ds_layout_ci.bindingCount = 1; |
| 4465 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4466 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4467 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4468 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4469 | ASSERT_VK_SUCCESS(err); |
| 4470 | |
| 4471 | VkDescriptorSet descriptorSet; |
| 4472 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4473 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4474 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4475 | alloc_info.descriptorPool = ds_pool; |
| 4476 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4478 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4479 | ASSERT_VK_SUCCESS(err); |
| 4480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4481 | VkBufferView view = |
| 4482 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4483 | VkWriteDescriptorSet descriptor_write; |
| 4484 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4485 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4486 | descriptor_write.dstSet = descriptorSet; |
| 4487 | descriptor_write.dstBinding = 0; |
| 4488 | descriptor_write.descriptorCount = 1; |
| 4489 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4490 | descriptor_write.pTexelBufferView = &view; |
| 4491 | |
| 4492 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4493 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4494 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4495 | |
| 4496 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4497 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4498 | } |
| 4499 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4500 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4501 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4502 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4503 | // 1. No dynamicOffset supplied |
| 4504 | // 2. Too many dynamicOffsets supplied |
| 4505 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4506 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4507 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4508 | " requires 1 dynamicOffsets, but only " |
| 4509 | "0 dynamicOffsets are left in " |
| 4510 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4511 | |
| 4512 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4513 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4515 | |
| 4516 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4517 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4518 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4519 | |
| 4520 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4521 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4522 | ds_pool_ci.pNext = NULL; |
| 4523 | ds_pool_ci.maxSets = 1; |
| 4524 | ds_pool_ci.poolSizeCount = 1; |
| 4525 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4526 | |
| 4527 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4528 | err = |
| 4529 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4530 | ASSERT_VK_SUCCESS(err); |
| 4531 | |
| 4532 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4533 | dsl_binding.binding = 0; |
| 4534 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4535 | dsl_binding.descriptorCount = 1; |
| 4536 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4537 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4538 | |
| 4539 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4540 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4541 | ds_layout_ci.pNext = NULL; |
| 4542 | ds_layout_ci.bindingCount = 1; |
| 4543 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4544 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4545 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4546 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4547 | ASSERT_VK_SUCCESS(err); |
| 4548 | |
| 4549 | VkDescriptorSet descriptorSet; |
| 4550 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4551 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4552 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4553 | alloc_info.descriptorPool = ds_pool; |
| 4554 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4555 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4556 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4557 | ASSERT_VK_SUCCESS(err); |
| 4558 | |
| 4559 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4560 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4561 | pipeline_layout_ci.pNext = NULL; |
| 4562 | pipeline_layout_ci.setLayoutCount = 1; |
| 4563 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4564 | |
| 4565 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4566 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4567 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4568 | ASSERT_VK_SUCCESS(err); |
| 4569 | |
| 4570 | // Create a buffer to update the descriptor with |
| 4571 | uint32_t qfi = 0; |
| 4572 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4573 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4574 | buffCI.size = 1024; |
| 4575 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4576 | buffCI.queueFamilyIndexCount = 1; |
| 4577 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4578 | |
| 4579 | VkBuffer dyub; |
| 4580 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4581 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4582 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4583 | // error |
| 4584 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4585 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4586 | mem_alloc.pNext = NULL; |
| 4587 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4588 | mem_alloc.memoryTypeIndex = 0; |
| 4589 | |
| 4590 | VkMemoryRequirements memReqs; |
| 4591 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4592 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4593 | 0); |
| 4594 | if (!pass) { |
| 4595 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4596 | return; |
| 4597 | } |
| 4598 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4599 | VkDeviceMemory mem; |
| 4600 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4601 | ASSERT_VK_SUCCESS(err); |
| 4602 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4603 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4604 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4605 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4606 | buffInfo.buffer = dyub; |
| 4607 | buffInfo.offset = 0; |
| 4608 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4609 | |
| 4610 | VkWriteDescriptorSet descriptor_write; |
| 4611 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4612 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4613 | descriptor_write.dstSet = descriptorSet; |
| 4614 | descriptor_write.dstBinding = 0; |
| 4615 | descriptor_write.descriptorCount = 1; |
| 4616 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4617 | descriptor_write.pBufferInfo = &buffInfo; |
| 4618 | |
| 4619 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4620 | |
| 4621 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4622 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4623 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4624 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4625 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4626 | uint32_t pDynOff[2] = {512, 756}; |
| 4627 | // 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] | 4628 | m_errorMonitor->SetDesiredFailureMsg( |
| 4629 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4630 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4631 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4632 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4633 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4634 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4635 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4636 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4637 | " dynamic offset 512 combined with " |
| 4638 | "offset 0 and range 1024 that " |
| 4639 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4640 | // Create PSO to be used for draw-time errors below |
| 4641 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4642 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4643 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4644 | "out gl_PerVertex { \n" |
| 4645 | " vec4 gl_Position;\n" |
| 4646 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4647 | "void main(){\n" |
| 4648 | " gl_Position = vec4(1);\n" |
| 4649 | "}\n"; |
| 4650 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4651 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4652 | "\n" |
| 4653 | "layout(location=0) out vec4 x;\n" |
| 4654 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4655 | "void main(){\n" |
| 4656 | " x = vec4(bar.y);\n" |
| 4657 | "}\n"; |
| 4658 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4659 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4660 | VkPipelineObj pipe(m_device); |
| 4661 | pipe.AddShader(&vs); |
| 4662 | pipe.AddShader(&fs); |
| 4663 | pipe.AddColorAttachment(); |
| 4664 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4666 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4667 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4668 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4669 | // /w range 1024 & size 1024 |
| 4670 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4671 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4672 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4673 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4674 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4675 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4676 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4677 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4678 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4679 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4680 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4681 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4682 | } |
| 4683 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4684 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4685 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4687 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4688 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4689 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4690 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4691 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4692 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4693 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4694 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4695 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4696 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4697 | // |
| 4698 | // Check for invalid push constant ranges in pipeline layouts. |
| 4699 | // |
| 4700 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4701 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4702 | char const *msg; |
| 4703 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4704 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4705 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4706 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4707 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4708 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4709 | "size 0."}, |
| 4710 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4711 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4712 | "size 1."}, |
| 4713 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4714 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4715 | "size 1."}, |
| 4716 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4717 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4718 | "size 0."}, |
| 4719 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4720 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4721 | "offset 1. Offset must"}, |
| 4722 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4723 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4724 | "with offset "}, |
| 4725 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4726 | "vkCreatePipelineLayout() call has push constants " |
| 4727 | "index 0 with offset "}, |
| 4728 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4729 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4730 | "with offset "}, |
| 4731 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4732 | "vkCreatePipelineLayout() call has push " |
| 4733 | "constants index 0 with offset "}, |
| 4734 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4735 | "vkCreatePipelineLayout() call has push " |
| 4736 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4737 | }}; |
| 4738 | |
| 4739 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4740 | for (const auto &iter : range_tests) { |
| 4741 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4742 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4743 | iter.msg); |
| 4744 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4745 | NULL, &pipeline_layout); |
| 4746 | m_errorMonitor->VerifyFound(); |
| 4747 | if (VK_SUCCESS == err) { |
| 4748 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4749 | } |
| 4750 | } |
| 4751 | |
| 4752 | // Check for invalid stage flag |
| 4753 | pc_range.offset = 0; |
| 4754 | pc_range.size = 16; |
| 4755 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4756 | m_errorMonitor->SetDesiredFailureMsg( |
| 4757 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4758 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4759 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4760 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4761 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4762 | if (VK_SUCCESS == err) { |
| 4763 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4764 | } |
| 4765 | |
| 4766 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4767 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4768 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4769 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4770 | char const *msg; |
| 4771 | }; |
| 4772 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4773 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4774 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4775 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4776 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4777 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4778 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4779 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4780 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4781 | { |
| 4782 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4783 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4784 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4785 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4786 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4787 | "vkCreatePipelineLayout() call has push constants with " |
| 4788 | "overlapping " |
| 4789 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4790 | }, |
| 4791 | { |
| 4792 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4793 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4794 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4795 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4796 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4797 | "vkCreatePipelineLayout() call has push constants with " |
| 4798 | "overlapping " |
| 4799 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4800 | }, |
| 4801 | { |
| 4802 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4803 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4804 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4805 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4806 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4807 | "vkCreatePipelineLayout() call has push constants with " |
| 4808 | "overlapping " |
| 4809 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4810 | }, |
| 4811 | { |
| 4812 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4813 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4814 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4815 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4816 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4817 | "vkCreatePipelineLayout() call has push constants with " |
| 4818 | "overlapping " |
| 4819 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4820 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4821 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4822 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4823 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4824 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4825 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4826 | iter.msg); |
| 4827 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4828 | NULL, &pipeline_layout); |
| 4829 | m_errorMonitor->VerifyFound(); |
| 4830 | if (VK_SUCCESS == err) { |
| 4831 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4832 | } |
| 4833 | } |
| 4834 | |
| 4835 | // 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] | 4836 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4837 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4838 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4839 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4840 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4841 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4842 | ""}, |
| 4843 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4844 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4845 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4846 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4847 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4848 | ""}}}; |
| 4849 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4850 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4851 | m_errorMonitor->ExpectSuccess(); |
| 4852 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4853 | NULL, &pipeline_layout); |
| 4854 | m_errorMonitor->VerifyNotFound(); |
| 4855 | if (VK_SUCCESS == err) { |
| 4856 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4857 | } |
| 4858 | } |
| 4859 | |
| 4860 | // |
| 4861 | // CmdPushConstants tests |
| 4862 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4863 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4864 | |
| 4865 | // 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] | 4866 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4867 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4868 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4869 | "must be greater than zero and a multiple of 4."}, |
| 4870 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4871 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4872 | "must be greater than zero and a multiple of 4."}, |
| 4873 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4874 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4875 | "must be greater than zero and a multiple of 4."}, |
| 4876 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4877 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4878 | "Offset must be a multiple of 4."}, |
| 4879 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4880 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4881 | "Offset must be a multiple of 4."}, |
| 4882 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4883 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4884 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4885 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4886 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4887 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4888 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4889 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4890 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4891 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4892 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4893 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4894 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4895 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4896 | "any of the ranges in pipeline layout"}, |
| 4897 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4898 | 0, 16}, |
| 4899 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4900 | "any of the ranges in pipeline layout"}, |
| 4901 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4902 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4903 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4904 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4905 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4906 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4907 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4908 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4909 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4910 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4911 | }}; |
| 4912 | |
| 4913 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4914 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4915 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4916 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4917 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4918 | pipeline_layout_ci.pushConstantRangeCount = |
| 4919 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4920 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4921 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4922 | &pipeline_layout); |
| 4923 | ASSERT_VK_SUCCESS(err); |
| 4924 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4925 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4926 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4927 | iter.msg); |
| 4928 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4929 | iter.range.stageFlags, iter.range.offset, |
| 4930 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4931 | m_errorMonitor->VerifyFound(); |
| 4932 | } |
| 4933 | |
| 4934 | // Check for invalid stage flag |
| 4935 | m_errorMonitor->SetDesiredFailureMsg( |
| 4936 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4937 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4938 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4939 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4940 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4941 | EndCommandBuffer(); |
| 4942 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4943 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4944 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4945 | // overlapping range tests with cmd |
| 4946 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4947 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4948 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4949 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4950 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4951 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4952 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4953 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4954 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4955 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4956 | }}; |
| 4957 | const VkPushConstantRange pc_range3[] = { |
| 4958 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4959 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4960 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4961 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4962 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4963 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4964 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4965 | }; |
| 4966 | pipeline_layout_ci.pushConstantRangeCount = |
| 4967 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4968 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4969 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4970 | &pipeline_layout); |
| 4971 | ASSERT_VK_SUCCESS(err); |
| 4972 | BeginCommandBuffer(); |
| 4973 | for (const auto &iter : cmd_overlap_tests) { |
| 4974 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4975 | iter.msg); |
| 4976 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4977 | iter.range.stageFlags, iter.range.offset, |
| 4978 | iter.range.size, dummy_values); |
| 4979 | m_errorMonitor->VerifyFound(); |
| 4980 | } |
| 4981 | EndCommandBuffer(); |
| 4982 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4983 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4984 | |
| 4985 | // positive overlapping range tests with cmd |
| 4986 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4987 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4988 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4989 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4990 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4991 | }}; |
| 4992 | const VkPushConstantRange pc_range4[] = { |
| 4993 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4994 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4995 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4996 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4997 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4998 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4999 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 5000 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 5001 | }; |
| 5002 | pipeline_layout_ci.pushConstantRangeCount = |
| 5003 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 5004 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 5005 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5006 | &pipeline_layout); |
| 5007 | ASSERT_VK_SUCCESS(err); |
| 5008 | BeginCommandBuffer(); |
| 5009 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 5010 | m_errorMonitor->ExpectSuccess(); |
| 5011 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 5012 | iter.range.stageFlags, iter.range.offset, |
| 5013 | iter.range.size, dummy_values); |
| 5014 | m_errorMonitor->VerifyNotFound(); |
| 5015 | } |
| 5016 | EndCommandBuffer(); |
| 5017 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5018 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5019 | } |
| 5020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5022 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5023 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5024 | |
| 5025 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5026 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5027 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5028 | |
| 5029 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5030 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5031 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5032 | ds_type_count[0].descriptorCount = 10; |
| 5033 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5034 | ds_type_count[1].descriptorCount = 2; |
| 5035 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5036 | ds_type_count[2].descriptorCount = 2; |
| 5037 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5038 | ds_type_count[3].descriptorCount = 5; |
| 5039 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5040 | // type |
| 5041 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5042 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5043 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5044 | |
| 5045 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5046 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5047 | ds_pool_ci.pNext = NULL; |
| 5048 | ds_pool_ci.maxSets = 5; |
| 5049 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5050 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5051 | |
| 5052 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5053 | err = |
| 5054 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5055 | ASSERT_VK_SUCCESS(err); |
| 5056 | |
| 5057 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5058 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5059 | dsl_binding[0].binding = 0; |
| 5060 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5061 | dsl_binding[0].descriptorCount = 5; |
| 5062 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5063 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5064 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5065 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5066 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5067 | dsl_fs_stage_only.binding = 0; |
| 5068 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5069 | dsl_fs_stage_only.descriptorCount = 5; |
| 5070 | dsl_fs_stage_only.stageFlags = |
| 5071 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5072 | // bind time |
| 5073 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5074 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5075 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5076 | ds_layout_ci.pNext = NULL; |
| 5077 | ds_layout_ci.bindingCount = 1; |
| 5078 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5079 | static const uint32_t NUM_LAYOUTS = 4; |
| 5080 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5081 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5082 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5083 | // layout for error case |
| 5084 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5085 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5086 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5087 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5088 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5089 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5090 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5091 | dsl_binding[0].binding = 0; |
| 5092 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5093 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5094 | dsl_binding[1].binding = 1; |
| 5095 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5096 | dsl_binding[1].descriptorCount = 2; |
| 5097 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5098 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5099 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5100 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5101 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5102 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5103 | ASSERT_VK_SUCCESS(err); |
| 5104 | dsl_binding[0].binding = 0; |
| 5105 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5106 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5107 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5108 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5109 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5110 | ASSERT_VK_SUCCESS(err); |
| 5111 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5112 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5113 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5114 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5115 | ASSERT_VK_SUCCESS(err); |
| 5116 | |
| 5117 | static const uint32_t NUM_SETS = 4; |
| 5118 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5119 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5120 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5121 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5122 | alloc_info.descriptorPool = ds_pool; |
| 5123 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5125 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5126 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5127 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5128 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5129 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5130 | err = |
| 5131 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5132 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5133 | |
| 5134 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5135 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5136 | pipeline_layout_ci.pNext = NULL; |
| 5137 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5138 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5139 | |
| 5140 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5141 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5142 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5143 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5144 | // Create pipelineLayout with only one setLayout |
| 5145 | pipeline_layout_ci.setLayoutCount = 1; |
| 5146 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5147 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5148 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5149 | ASSERT_VK_SUCCESS(err); |
| 5150 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5151 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5152 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5153 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5154 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5155 | ASSERT_VK_SUCCESS(err); |
| 5156 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5157 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5158 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5160 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5161 | ASSERT_VK_SUCCESS(err); |
| 5162 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5163 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5164 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5165 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5166 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5167 | ASSERT_VK_SUCCESS(err); |
| 5168 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5169 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5170 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5171 | pl_bad_s0[1] = ds_layout[1]; |
| 5172 | pipeline_layout_ci.setLayoutCount = 2; |
| 5173 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5174 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5175 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5176 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5177 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5178 | |
| 5179 | // Create a buffer to update the descriptor with |
| 5180 | uint32_t qfi = 0; |
| 5181 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5182 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5183 | buffCI.size = 1024; |
| 5184 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5185 | buffCI.queueFamilyIndexCount = 1; |
| 5186 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5187 | |
| 5188 | VkBuffer dyub; |
| 5189 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5190 | ASSERT_VK_SUCCESS(err); |
| 5191 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5192 | static const uint32_t NUM_BUFFS = 5; |
| 5193 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5194 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5195 | buffInfo[i].buffer = dyub; |
| 5196 | buffInfo[i].offset = 0; |
| 5197 | buffInfo[i].range = 1024; |
| 5198 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5199 | VkImage image; |
| 5200 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5201 | const int32_t tex_width = 32; |
| 5202 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5203 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5204 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5205 | image_create_info.pNext = NULL; |
| 5206 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5207 | image_create_info.format = tex_format; |
| 5208 | image_create_info.extent.width = tex_width; |
| 5209 | image_create_info.extent.height = tex_height; |
| 5210 | image_create_info.extent.depth = 1; |
| 5211 | image_create_info.mipLevels = 1; |
| 5212 | image_create_info.arrayLayers = 1; |
| 5213 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5214 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5215 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5216 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5217 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5218 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5220 | VkMemoryRequirements memReqs; |
| 5221 | VkDeviceMemory imageMem; |
| 5222 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5223 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5224 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5225 | memAlloc.pNext = NULL; |
| 5226 | memAlloc.allocationSize = 0; |
| 5227 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5228 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5229 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5230 | pass = |
| 5231 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5232 | ASSERT_TRUE(pass); |
| 5233 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5234 | ASSERT_VK_SUCCESS(err); |
| 5235 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5236 | ASSERT_VK_SUCCESS(err); |
| 5237 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5238 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5240 | image_view_create_info.image = image; |
| 5241 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5242 | image_view_create_info.format = tex_format; |
| 5243 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5244 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5245 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5246 | image_view_create_info.subresourceRange.aspectMask = |
| 5247 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5248 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5249 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5250 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5251 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5252 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5253 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5254 | imageInfo[0].imageView = view; |
| 5255 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5256 | imageInfo[1].imageView = view; |
| 5257 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5258 | imageInfo[2].imageView = view; |
| 5259 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5260 | imageInfo[3].imageView = view; |
| 5261 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5262 | |
| 5263 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5264 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5265 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5266 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5267 | descriptor_write[0].dstBinding = 0; |
| 5268 | descriptor_write[0].descriptorCount = 5; |
| 5269 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5270 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5271 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5272 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5273 | descriptor_write[1].dstBinding = 0; |
| 5274 | descriptor_write[1].descriptorCount = 2; |
| 5275 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5276 | descriptor_write[1].pImageInfo = imageInfo; |
| 5277 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5278 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5279 | descriptor_write[2].dstBinding = 1; |
| 5280 | descriptor_write[2].descriptorCount = 2; |
| 5281 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5282 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5283 | |
| 5284 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5285 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5286 | // Create PSO to be used for draw-time errors below |
| 5287 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5288 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5289 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5290 | "out gl_PerVertex {\n" |
| 5291 | " vec4 gl_Position;\n" |
| 5292 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5293 | "void main(){\n" |
| 5294 | " gl_Position = vec4(1);\n" |
| 5295 | "}\n"; |
| 5296 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5297 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5298 | "\n" |
| 5299 | "layout(location=0) out vec4 x;\n" |
| 5300 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5301 | "void main(){\n" |
| 5302 | " x = vec4(bar.y);\n" |
| 5303 | "}\n"; |
| 5304 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5305 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5306 | VkPipelineObj pipe(m_device); |
| 5307 | pipe.AddShader(&vs); |
| 5308 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5309 | pipe.AddColorAttachment(); |
| 5310 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5311 | |
| 5312 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5314 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5315 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5316 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5317 | // of PSO |
| 5318 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5319 | // cmd_pipeline.c |
| 5320 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5321 | // cmd_bind_graphics_pipeline() |
| 5322 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5323 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5324 | // First cause various verify_layout_compatibility() fails |
| 5325 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5326 | // verify_set_layout_compatibility fail cases: |
| 5327 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5329 | " due to: invalid VkPipelineLayout "); |
| 5330 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5331 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5332 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5333 | &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 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5337 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5338 | " attempting to bind set to index 1"); |
| 5339 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5340 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5341 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5342 | m_errorMonitor->VerifyFound(); |
| 5343 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5344 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5345 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5346 | // descriptors |
| 5347 | m_errorMonitor->SetDesiredFailureMsg( |
| 5348 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5349 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | vkCmdBindDescriptorSets( |
| 5351 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5352 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5353 | m_errorMonitor->VerifyFound(); |
| 5354 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5355 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5356 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | m_errorMonitor->SetDesiredFailureMsg( |
| 5358 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5359 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5360 | vkCmdBindDescriptorSets( |
| 5361 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5362 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5363 | m_errorMonitor->VerifyFound(); |
| 5364 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5365 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5366 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5367 | m_errorMonitor->SetDesiredFailureMsg( |
| 5368 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5369 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | vkCmdBindDescriptorSets( |
| 5371 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5372 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5373 | m_errorMonitor->VerifyFound(); |
| 5374 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5375 | // Cause INFO messages due to disturbing previously bound Sets |
| 5376 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5377 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5378 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5379 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5380 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5382 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5383 | " previously bound as set #0 was disturbed "); |
| 5384 | vkCmdBindDescriptorSets( |
| 5385 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5386 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5387 | m_errorMonitor->VerifyFound(); |
| 5388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5389 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5390 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5391 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5392 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5393 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5394 | " newly bound as set #0 so set #1 and " |
| 5395 | "any subsequent sets were disturbed "); |
| 5396 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5397 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5398 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5399 | m_errorMonitor->VerifyFound(); |
| 5400 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5401 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5402 | // 1. Error due to not binding required set (we actually use same code as |
| 5403 | // above to disturb set0) |
| 5404 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5405 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5406 | 2, &descriptorSet[0], 0, NULL); |
| 5407 | vkCmdBindDescriptorSets( |
| 5408 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5409 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5410 | m_errorMonitor->SetDesiredFailureMsg( |
| 5411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5412 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5413 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5414 | m_errorMonitor->VerifyFound(); |
| 5415 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5416 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5417 | // 2. Error due to bound set not being compatible with PSO's |
| 5418 | // VkPipelineLayout (diff stageFlags in this case) |
| 5419 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5420 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5421 | 2, &descriptorSet[0], 0, NULL); |
| 5422 | m_errorMonitor->SetDesiredFailureMsg( |
| 5423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5424 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5425 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5426 | m_errorMonitor->VerifyFound(); |
| 5427 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5428 | // Remaining clean-up |
| 5429 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5430 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5431 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5432 | } |
| 5433 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5434 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5435 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5436 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5437 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5438 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5439 | vkFreeMemory(m_device->device(), imageMem, NULL); |
| 5440 | vkDestroyImage(m_device->device(), image, NULL); |
| 5441 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5442 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5444 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | m_errorMonitor->SetDesiredFailureMsg( |
| 5447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5448 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5449 | |
| 5450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5451 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5452 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5453 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5454 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5455 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5456 | } |
| 5457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5459 | VkResult err; |
| 5460 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5461 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5462 | m_errorMonitor->SetDesiredFailureMsg( |
| 5463 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5464 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5465 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5466 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5467 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5468 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5469 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5470 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5471 | cmd.commandPool = m_commandPool; |
| 5472 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5473 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5474 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5475 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5476 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5477 | |
| 5478 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5479 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5480 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5481 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5482 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5483 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5484 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5485 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5486 | |
| 5487 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5488 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5489 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5490 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5491 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5492 | } |
| 5493 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5494 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5495 | // Cause error due to Begin while recording CB |
| 5496 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5497 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5498 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5499 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5500 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5501 | |
| 5502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5503 | |
| 5504 | // Calls AllocateCommandBuffers |
| 5505 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5506 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5507 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5508 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5509 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5510 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5511 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5512 | cmd_buf_info.pNext = NULL; |
| 5513 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5514 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5515 | |
| 5516 | // Begin CB to transition to recording state |
| 5517 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5518 | // Can't re-begin. This should trigger error |
| 5519 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5520 | m_errorMonitor->VerifyFound(); |
| 5521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5522 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5523 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5524 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5525 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5526 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5527 | m_errorMonitor->VerifyFound(); |
| 5528 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5529 | m_errorMonitor->SetDesiredFailureMsg( |
| 5530 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5531 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5532 | // Transition CB to RECORDED state |
| 5533 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5534 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5535 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5536 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5537 | } |
| 5538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5540 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5541 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5542 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5543 | m_errorMonitor->SetDesiredFailureMsg( |
| 5544 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5545 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5546 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5548 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5549 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5550 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5551 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5552 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5553 | |
| 5554 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5555 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5556 | ds_pool_ci.pNext = NULL; |
| 5557 | ds_pool_ci.maxSets = 1; |
| 5558 | ds_pool_ci.poolSizeCount = 1; |
| 5559 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5560 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5561 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5562 | err = |
| 5563 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5564 | ASSERT_VK_SUCCESS(err); |
| 5565 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5566 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5567 | dsl_binding.binding = 0; |
| 5568 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5569 | dsl_binding.descriptorCount = 1; |
| 5570 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5571 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5572 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5573 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5575 | ds_layout_ci.pNext = NULL; |
| 5576 | ds_layout_ci.bindingCount = 1; |
| 5577 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5578 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5579 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5580 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5581 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5582 | ASSERT_VK_SUCCESS(err); |
| 5583 | |
| 5584 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5585 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5586 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5587 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5588 | alloc_info.descriptorPool = ds_pool; |
| 5589 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5590 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5591 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5592 | ASSERT_VK_SUCCESS(err); |
| 5593 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5594 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5595 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5596 | pipeline_layout_ci.setLayoutCount = 1; |
| 5597 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5598 | |
| 5599 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5601 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5602 | ASSERT_VK_SUCCESS(err); |
| 5603 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5604 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5605 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5606 | |
| 5607 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5608 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5609 | vp_state_ci.scissorCount = 1; |
| 5610 | vp_state_ci.pScissors = ≻ |
| 5611 | vp_state_ci.viewportCount = 1; |
| 5612 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5613 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5614 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5615 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5616 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5617 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5618 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5619 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5620 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5621 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5622 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5623 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5624 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5625 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5626 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5627 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5628 | gp_ci.layout = pipeline_layout; |
| 5629 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5630 | |
| 5631 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5632 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5633 | pc_ci.initialDataSize = 0; |
| 5634 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5635 | |
| 5636 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5637 | VkPipelineCache pipelineCache; |
| 5638 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5639 | err = |
| 5640 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5641 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5642 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5643 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5644 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5645 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5646 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5647 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5648 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5649 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5650 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5651 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5652 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5653 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5654 | { |
| 5655 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5656 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5657 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5658 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5660 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5661 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5662 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5663 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5664 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5665 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5666 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5667 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5668 | |
| 5669 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5670 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5671 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5672 | ds_pool_ci.poolSizeCount = 1; |
| 5673 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5674 | |
| 5675 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5676 | err = vkCreateDescriptorPool(m_device->device(), |
| 5677 | 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] | 5678 | ASSERT_VK_SUCCESS(err); |
| 5679 | |
| 5680 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5681 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5682 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5683 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5684 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5685 | dsl_binding.pImmutableSamplers = NULL; |
| 5686 | |
| 5687 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5688 | ds_layout_ci.sType = |
| 5689 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5690 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5691 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5692 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5693 | |
| 5694 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5695 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5696 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5697 | ASSERT_VK_SUCCESS(err); |
| 5698 | |
| 5699 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5700 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5701 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5702 | ASSERT_VK_SUCCESS(err); |
| 5703 | |
| 5704 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5705 | pipeline_layout_ci.sType = |
| 5706 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5707 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5708 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5709 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5710 | |
| 5711 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5712 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5713 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5714 | ASSERT_VK_SUCCESS(err); |
| 5715 | |
| 5716 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5717 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5718 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5719 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5720 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5721 | // 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] | 5722 | VkShaderObj |
| 5723 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5724 | this); |
| 5725 | VkShaderObj |
| 5726 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5727 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5729 | shaderStages[0].sType = |
| 5730 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5731 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5732 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5733 | shaderStages[1].sType = |
| 5734 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5735 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5736 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5737 | shaderStages[2].sType = |
| 5738 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5739 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5740 | shaderStages[2].shader = te.handle(); |
| 5741 | |
| 5742 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5743 | iaCI.sType = |
| 5744 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5745 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5746 | |
| 5747 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5748 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5749 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5750 | |
| 5751 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5752 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5753 | gp_ci.pNext = NULL; |
| 5754 | gp_ci.stageCount = 3; |
| 5755 | gp_ci.pStages = shaderStages; |
| 5756 | gp_ci.pVertexInputState = NULL; |
| 5757 | gp_ci.pInputAssemblyState = &iaCI; |
| 5758 | gp_ci.pTessellationState = &tsCI; |
| 5759 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5760 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5761 | gp_ci.pMultisampleState = NULL; |
| 5762 | gp_ci.pDepthStencilState = NULL; |
| 5763 | gp_ci.pColorBlendState = NULL; |
| 5764 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5765 | gp_ci.layout = pipeline_layout; |
| 5766 | gp_ci.renderPass = renderPass(); |
| 5767 | |
| 5768 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5769 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5770 | pc_ci.pNext = NULL; |
| 5771 | pc_ci.initialSize = 0; |
| 5772 | pc_ci.initialData = 0; |
| 5773 | pc_ci.maxSize = 0; |
| 5774 | |
| 5775 | VkPipeline pipeline; |
| 5776 | VkPipelineCache pipelineCache; |
| 5777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5779 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5780 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5781 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5782 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5783 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5784 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5785 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5786 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5787 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5788 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5789 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5790 | } |
| 5791 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5792 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5793 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5794 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5795 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5796 | m_errorMonitor->SetDesiredFailureMsg( |
| 5797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5798 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5799 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5800 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5801 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5802 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5803 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5804 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5805 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5806 | |
| 5807 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5808 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5809 | ds_pool_ci.maxSets = 1; |
| 5810 | ds_pool_ci.poolSizeCount = 1; |
| 5811 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5812 | |
| 5813 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5814 | err = |
| 5815 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5816 | ASSERT_VK_SUCCESS(err); |
| 5817 | |
| 5818 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5819 | dsl_binding.binding = 0; |
| 5820 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5821 | dsl_binding.descriptorCount = 1; |
| 5822 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5823 | |
| 5824 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5825 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5826 | ds_layout_ci.bindingCount = 1; |
| 5827 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5828 | |
| 5829 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5830 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5831 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5832 | ASSERT_VK_SUCCESS(err); |
| 5833 | |
| 5834 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5835 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5836 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5837 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5838 | alloc_info.descriptorPool = ds_pool; |
| 5839 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5840 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5841 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5842 | ASSERT_VK_SUCCESS(err); |
| 5843 | |
| 5844 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5845 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5846 | pipeline_layout_ci.setLayoutCount = 1; |
| 5847 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5848 | |
| 5849 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5850 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5851 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5852 | ASSERT_VK_SUCCESS(err); |
| 5853 | |
| 5854 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5855 | |
| 5856 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5857 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5858 | vp_state_ci.scissorCount = 0; |
| 5859 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5860 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5861 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5862 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5863 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5864 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5865 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5866 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5867 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5868 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5869 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5870 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5871 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5872 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5874 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5875 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5876 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5877 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5878 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5879 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5880 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5881 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5882 | |
| 5883 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5884 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5885 | gp_ci.stageCount = 2; |
| 5886 | gp_ci.pStages = shaderStages; |
| 5887 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5888 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5889 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5890 | gp_ci.layout = pipeline_layout; |
| 5891 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5892 | |
| 5893 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5894 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5895 | |
| 5896 | VkPipeline pipeline; |
| 5897 | VkPipelineCache pipelineCache; |
| 5898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | err = |
| 5900 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5901 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5902 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5903 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5904 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5905 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5906 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5907 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5908 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5909 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5910 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5911 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5912 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5913 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5914 | // 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] | 5915 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5916 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5917 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5918 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5919 | m_errorMonitor->SetDesiredFailureMsg( |
| 5920 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5921 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5922 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5925 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5926 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5927 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5928 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5929 | |
| 5930 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5931 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5932 | ds_pool_ci.maxSets = 1; |
| 5933 | ds_pool_ci.poolSizeCount = 1; |
| 5934 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5935 | |
| 5936 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | err = |
| 5938 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5939 | ASSERT_VK_SUCCESS(err); |
| 5940 | |
| 5941 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5942 | dsl_binding.binding = 0; |
| 5943 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5944 | dsl_binding.descriptorCount = 1; |
| 5945 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5946 | |
| 5947 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5948 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5949 | ds_layout_ci.bindingCount = 1; |
| 5950 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5951 | |
| 5952 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5954 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5955 | ASSERT_VK_SUCCESS(err); |
| 5956 | |
| 5957 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5958 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5959 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5960 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5961 | alloc_info.descriptorPool = ds_pool; |
| 5962 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5963 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5964 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5965 | ASSERT_VK_SUCCESS(err); |
| 5966 | |
| 5967 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5968 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5969 | pipeline_layout_ci.setLayoutCount = 1; |
| 5970 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5971 | |
| 5972 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5973 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5974 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5975 | ASSERT_VK_SUCCESS(err); |
| 5976 | |
| 5977 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5978 | // Set scissor as dynamic to avoid second error |
| 5979 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5980 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5981 | dyn_state_ci.dynamicStateCount = 1; |
| 5982 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5983 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5984 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5985 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5986 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5987 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5988 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5989 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5990 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5991 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5992 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5993 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5994 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5995 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5996 | |
| 5997 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5998 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5999 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 6000 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 6001 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 6002 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 6003 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 6004 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 6005 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6006 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6007 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6008 | gp_ci.stageCount = 2; |
| 6009 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6010 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 6012 | // should cause validation error |
| 6013 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6014 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6015 | gp_ci.layout = pipeline_layout; |
| 6016 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6017 | |
| 6018 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6019 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6020 | |
| 6021 | VkPipeline pipeline; |
| 6022 | VkPipelineCache pipelineCache; |
| 6023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6024 | err = |
| 6025 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6026 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6028 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6029 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6030 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6031 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6032 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6033 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6034 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6035 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6036 | } |
| 6037 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6038 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6039 | // count |
| 6040 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6041 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6043 | m_errorMonitor->SetDesiredFailureMsg( |
| 6044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6045 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6046 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6049 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6050 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6051 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6052 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6053 | |
| 6054 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6055 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6056 | ds_pool_ci.maxSets = 1; |
| 6057 | ds_pool_ci.poolSizeCount = 1; |
| 6058 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6059 | |
| 6060 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | err = |
| 6062 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6063 | ASSERT_VK_SUCCESS(err); |
| 6064 | |
| 6065 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6066 | dsl_binding.binding = 0; |
| 6067 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6068 | dsl_binding.descriptorCount = 1; |
| 6069 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6070 | |
| 6071 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6072 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6073 | ds_layout_ci.bindingCount = 1; |
| 6074 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6075 | |
| 6076 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6077 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6078 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6079 | ASSERT_VK_SUCCESS(err); |
| 6080 | |
| 6081 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6082 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6083 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6084 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6085 | alloc_info.descriptorPool = ds_pool; |
| 6086 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6087 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6088 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6089 | ASSERT_VK_SUCCESS(err); |
| 6090 | |
| 6091 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6092 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6093 | pipeline_layout_ci.setLayoutCount = 1; |
| 6094 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6095 | |
| 6096 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6097 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6098 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6099 | ASSERT_VK_SUCCESS(err); |
| 6100 | |
| 6101 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6102 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6103 | vp_state_ci.viewportCount = 1; |
| 6104 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6105 | vp_state_ci.scissorCount = 1; |
| 6106 | vp_state_ci.pScissors = |
| 6107 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6108 | |
| 6109 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6110 | // Set scissor as dynamic to avoid that error |
| 6111 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6112 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6113 | dyn_state_ci.dynamicStateCount = 1; |
| 6114 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6115 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6116 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6117 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6119 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6120 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6121 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6122 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6123 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6124 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6125 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6126 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6127 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6128 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6129 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6130 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6131 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6132 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6133 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6134 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6135 | |
| 6136 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6137 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6138 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6139 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6140 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6141 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6142 | rs_ci.pNext = nullptr; |
| 6143 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6144 | VkPipelineColorBlendAttachmentState att = {}; |
| 6145 | att.blendEnable = VK_FALSE; |
| 6146 | att.colorWriteMask = 0xf; |
| 6147 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6148 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6149 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6150 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6151 | cb_ci.attachmentCount = 1; |
| 6152 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6153 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6154 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6155 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6156 | gp_ci.stageCount = 2; |
| 6157 | gp_ci.pStages = shaderStages; |
| 6158 | gp_ci.pVertexInputState = &vi_ci; |
| 6159 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6160 | gp_ci.pViewportState = &vp_state_ci; |
| 6161 | gp_ci.pRasterizationState = &rs_ci; |
| 6162 | gp_ci.pColorBlendState = &cb_ci; |
| 6163 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6164 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6165 | gp_ci.layout = pipeline_layout; |
| 6166 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6167 | |
| 6168 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6170 | |
| 6171 | VkPipeline pipeline; |
| 6172 | VkPipelineCache pipelineCache; |
| 6173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6174 | err = |
| 6175 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6176 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6177 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6178 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6179 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6180 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6181 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6182 | // 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] | 6183 | // First need to successfully create the PSO from above by setting |
| 6184 | // pViewports |
| 6185 | m_errorMonitor->SetDesiredFailureMsg( |
| 6186 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6187 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6188 | "scissorCount is 1. These counts must match."); |
| 6189 | |
| 6190 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6191 | vp_state_ci.pViewports = &vp; |
| 6192 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6193 | &gp_ci, NULL, &pipeline); |
| 6194 | ASSERT_VK_SUCCESS(err); |
| 6195 | BeginCommandBuffer(); |
| 6196 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6197 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6198 | VkRect2D scissors[2] = {}; // don't care about data |
| 6199 | // Count of 2 doesn't match PSO count of 1 |
| 6200 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6201 | Draw(1, 0, 0, 0); |
| 6202 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6203 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6204 | |
| 6205 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6206 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6207 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6208 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6209 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6210 | } |
| 6211 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6212 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6213 | // viewportCount |
| 6214 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6215 | VkResult err; |
| 6216 | |
| 6217 | m_errorMonitor->SetDesiredFailureMsg( |
| 6218 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6219 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6220 | |
| 6221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6222 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6223 | |
| 6224 | VkDescriptorPoolSize ds_type_count = {}; |
| 6225 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6226 | ds_type_count.descriptorCount = 1; |
| 6227 | |
| 6228 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6229 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6230 | ds_pool_ci.maxSets = 1; |
| 6231 | ds_pool_ci.poolSizeCount = 1; |
| 6232 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6233 | |
| 6234 | VkDescriptorPool ds_pool; |
| 6235 | err = |
| 6236 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6237 | ASSERT_VK_SUCCESS(err); |
| 6238 | |
| 6239 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6240 | dsl_binding.binding = 0; |
| 6241 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6242 | dsl_binding.descriptorCount = 1; |
| 6243 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6244 | |
| 6245 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6246 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6247 | ds_layout_ci.bindingCount = 1; |
| 6248 | ds_layout_ci.pBindings = &dsl_binding; |
| 6249 | |
| 6250 | VkDescriptorSetLayout ds_layout; |
| 6251 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6252 | &ds_layout); |
| 6253 | ASSERT_VK_SUCCESS(err); |
| 6254 | |
| 6255 | VkDescriptorSet descriptorSet; |
| 6256 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6257 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6258 | alloc_info.descriptorSetCount = 1; |
| 6259 | alloc_info.descriptorPool = ds_pool; |
| 6260 | alloc_info.pSetLayouts = &ds_layout; |
| 6261 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6262 | &descriptorSet); |
| 6263 | ASSERT_VK_SUCCESS(err); |
| 6264 | |
| 6265 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6266 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6267 | pipeline_layout_ci.setLayoutCount = 1; |
| 6268 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6269 | |
| 6270 | VkPipelineLayout pipeline_layout; |
| 6271 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6272 | &pipeline_layout); |
| 6273 | ASSERT_VK_SUCCESS(err); |
| 6274 | |
| 6275 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6276 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6277 | vp_state_ci.scissorCount = 1; |
| 6278 | vp_state_ci.pScissors = |
| 6279 | NULL; // Null scissor w/ count of 1 should cause error |
| 6280 | vp_state_ci.viewportCount = 1; |
| 6281 | vp_state_ci.pViewports = |
| 6282 | NULL; // vp is dynamic (below) so this won't cause error |
| 6283 | |
| 6284 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6285 | // Set scissor as dynamic to avoid that error |
| 6286 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6287 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6288 | dyn_state_ci.dynamicStateCount = 1; |
| 6289 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6290 | |
| 6291 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6292 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6293 | |
| 6294 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6295 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6296 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6297 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6298 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6299 | // but add it to be able to run on more devices |
| 6300 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6301 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6302 | |
| 6303 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6304 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6305 | vi_ci.pNext = nullptr; |
| 6306 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6307 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6308 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6309 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6310 | |
| 6311 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6312 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6313 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6314 | |
| 6315 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6316 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6317 | rs_ci.pNext = nullptr; |
| 6318 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6319 | VkPipelineColorBlendAttachmentState att = {}; |
| 6320 | att.blendEnable = VK_FALSE; |
| 6321 | att.colorWriteMask = 0xf; |
| 6322 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6323 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6324 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6325 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6326 | cb_ci.attachmentCount = 1; |
| 6327 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6328 | |
| 6329 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6330 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6331 | gp_ci.stageCount = 2; |
| 6332 | gp_ci.pStages = shaderStages; |
| 6333 | gp_ci.pVertexInputState = &vi_ci; |
| 6334 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6335 | gp_ci.pViewportState = &vp_state_ci; |
| 6336 | gp_ci.pRasterizationState = &rs_ci; |
| 6337 | gp_ci.pColorBlendState = &cb_ci; |
| 6338 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6339 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6340 | gp_ci.layout = pipeline_layout; |
| 6341 | gp_ci.renderPass = renderPass(); |
| 6342 | |
| 6343 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6344 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6345 | |
| 6346 | VkPipeline pipeline; |
| 6347 | VkPipelineCache pipelineCache; |
| 6348 | |
| 6349 | err = |
| 6350 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6351 | ASSERT_VK_SUCCESS(err); |
| 6352 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6353 | &gp_ci, NULL, &pipeline); |
| 6354 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6355 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6356 | |
| 6357 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6358 | // First need to successfully create the PSO from above by setting |
| 6359 | // pViewports |
| 6360 | m_errorMonitor->SetDesiredFailureMsg( |
| 6361 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6362 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6363 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6364 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6365 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6366 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6367 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6368 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6369 | ASSERT_VK_SUCCESS(err); |
| 6370 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6371 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6372 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6373 | VkViewport viewports[2] = {}; // don't care about data |
| 6374 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6375 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6376 | Draw(1, 0, 0, 0); |
| 6377 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6378 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6379 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6380 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6381 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6382 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6383 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6384 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6385 | } |
| 6386 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6387 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6388 | VkResult err; |
| 6389 | |
| 6390 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6391 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6392 | |
| 6393 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6394 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6395 | |
| 6396 | VkDescriptorPoolSize ds_type_count = {}; |
| 6397 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6398 | ds_type_count.descriptorCount = 1; |
| 6399 | |
| 6400 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6401 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6402 | ds_pool_ci.maxSets = 1; |
| 6403 | ds_pool_ci.poolSizeCount = 1; |
| 6404 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6405 | |
| 6406 | VkDescriptorPool ds_pool; |
| 6407 | err = |
| 6408 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6409 | ASSERT_VK_SUCCESS(err); |
| 6410 | |
| 6411 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6412 | dsl_binding.binding = 0; |
| 6413 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6414 | dsl_binding.descriptorCount = 1; |
| 6415 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6416 | |
| 6417 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6418 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6419 | ds_layout_ci.bindingCount = 1; |
| 6420 | ds_layout_ci.pBindings = &dsl_binding; |
| 6421 | |
| 6422 | VkDescriptorSetLayout ds_layout; |
| 6423 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6424 | &ds_layout); |
| 6425 | ASSERT_VK_SUCCESS(err); |
| 6426 | |
| 6427 | VkDescriptorSet descriptorSet; |
| 6428 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6429 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6430 | alloc_info.descriptorSetCount = 1; |
| 6431 | alloc_info.descriptorPool = ds_pool; |
| 6432 | alloc_info.pSetLayouts = &ds_layout; |
| 6433 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6434 | &descriptorSet); |
| 6435 | ASSERT_VK_SUCCESS(err); |
| 6436 | |
| 6437 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6438 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6439 | pipeline_layout_ci.setLayoutCount = 1; |
| 6440 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6441 | |
| 6442 | VkPipelineLayout pipeline_layout; |
| 6443 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6444 | &pipeline_layout); |
| 6445 | ASSERT_VK_SUCCESS(err); |
| 6446 | |
| 6447 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6448 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6449 | vp_state_ci.scissorCount = 1; |
| 6450 | vp_state_ci.pScissors = NULL; |
| 6451 | vp_state_ci.viewportCount = 1; |
| 6452 | vp_state_ci.pViewports = NULL; |
| 6453 | |
| 6454 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6455 | VK_DYNAMIC_STATE_SCISSOR, |
| 6456 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6457 | // Set scissor as dynamic to avoid that error |
| 6458 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6459 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6460 | dyn_state_ci.dynamicStateCount = 2; |
| 6461 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6462 | |
| 6463 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6464 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6465 | |
| 6466 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6467 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6468 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6469 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6470 | this); // TODO - We shouldn't need a fragment shader |
| 6471 | // but add it to be able to run on more devices |
| 6472 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6473 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6474 | |
| 6475 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6476 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6477 | vi_ci.pNext = nullptr; |
| 6478 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6479 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6480 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6481 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6482 | |
| 6483 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6484 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6485 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6486 | |
| 6487 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6488 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6489 | rs_ci.pNext = nullptr; |
| 6490 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6491 | // Check too low (line width of -1.0f). |
| 6492 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6493 | |
| 6494 | VkPipelineColorBlendAttachmentState att = {}; |
| 6495 | att.blendEnable = VK_FALSE; |
| 6496 | att.colorWriteMask = 0xf; |
| 6497 | |
| 6498 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6499 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6500 | cb_ci.pNext = nullptr; |
| 6501 | cb_ci.attachmentCount = 1; |
| 6502 | cb_ci.pAttachments = &att; |
| 6503 | |
| 6504 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6505 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6506 | gp_ci.stageCount = 2; |
| 6507 | gp_ci.pStages = shaderStages; |
| 6508 | gp_ci.pVertexInputState = &vi_ci; |
| 6509 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6510 | gp_ci.pViewportState = &vp_state_ci; |
| 6511 | gp_ci.pRasterizationState = &rs_ci; |
| 6512 | gp_ci.pColorBlendState = &cb_ci; |
| 6513 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6514 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6515 | gp_ci.layout = pipeline_layout; |
| 6516 | gp_ci.renderPass = renderPass(); |
| 6517 | |
| 6518 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6519 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6520 | |
| 6521 | VkPipeline pipeline; |
| 6522 | VkPipelineCache pipelineCache; |
| 6523 | |
| 6524 | err = |
| 6525 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6526 | ASSERT_VK_SUCCESS(err); |
| 6527 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6528 | &gp_ci, NULL, &pipeline); |
| 6529 | |
| 6530 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6531 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6532 | |
| 6533 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6534 | "Attempt to set lineWidth to 65536"); |
| 6535 | |
| 6536 | // Check too high (line width of 65536.0f). |
| 6537 | rs_ci.lineWidth = 65536.0f; |
| 6538 | |
| 6539 | err = |
| 6540 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6541 | ASSERT_VK_SUCCESS(err); |
| 6542 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6543 | &gp_ci, NULL, &pipeline); |
| 6544 | |
| 6545 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6546 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6547 | |
| 6548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6549 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6550 | |
| 6551 | dyn_state_ci.dynamicStateCount = 3; |
| 6552 | |
| 6553 | rs_ci.lineWidth = 1.0f; |
| 6554 | |
| 6555 | err = |
| 6556 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6557 | ASSERT_VK_SUCCESS(err); |
| 6558 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6559 | &gp_ci, NULL, &pipeline); |
| 6560 | BeginCommandBuffer(); |
| 6561 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6562 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6563 | |
| 6564 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6565 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6566 | m_errorMonitor->VerifyFound(); |
| 6567 | |
| 6568 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6569 | "Attempt to set lineWidth to 65536"); |
| 6570 | |
| 6571 | // Check too high with dynamic setting. |
| 6572 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6573 | m_errorMonitor->VerifyFound(); |
| 6574 | EndCommandBuffer(); |
| 6575 | |
| 6576 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6577 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6578 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6579 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6580 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6581 | } |
| 6582 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6583 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6584 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | m_errorMonitor->SetDesiredFailureMsg( |
| 6586 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6587 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6588 | |
| 6589 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6590 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6591 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6592 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6594 | // that |
| 6595 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6596 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6597 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6598 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6599 | } |
| 6600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6602 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6603 | m_errorMonitor->SetDesiredFailureMsg( |
| 6604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6605 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6606 | |
| 6607 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6608 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6609 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6610 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6611 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6612 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6613 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6615 | rp_begin.pNext = NULL; |
| 6616 | rp_begin.renderPass = renderPass(); |
| 6617 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6618 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6619 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6620 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6622 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6623 | } |
| 6624 | |
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6625 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
| 6626 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" |
| 6627 | "the number of renderPass attachments that use loadOp" |
| 6628 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); |
| 6629 | |
| 6630 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6631 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6632 | |
| 6633 | // Create a renderPass with a single attachment that uses loadOp CLEAR |
| 6634 | VkAttachmentReference attach = {}; |
| 6635 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6636 | VkSubpassDescription subpass = {}; |
| 6637 | subpass.inputAttachmentCount = 1; |
| 6638 | subpass.pInputAttachments = &attach; |
| 6639 | VkRenderPassCreateInfo rpci = {}; |
| 6640 | rpci.subpassCount = 1; |
| 6641 | rpci.pSubpasses = &subpass; |
| 6642 | rpci.attachmentCount = 1; |
| 6643 | VkAttachmentDescription attach_desc = {}; |
| 6644 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6645 | // Set loadOp to CLEAR |
| 6646 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6647 | rpci.pAttachments = &attach_desc; |
| 6648 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 6649 | VkRenderPass rp; |
| 6650 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6651 | |
| 6652 | VkCommandBufferInheritanceInfo hinfo = {}; |
| 6653 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; |
| 6654 | hinfo.renderPass = VK_NULL_HANDLE; |
| 6655 | hinfo.subpass = 0; |
| 6656 | hinfo.framebuffer = VK_NULL_HANDLE; |
| 6657 | hinfo.occlusionQueryEnable = VK_FALSE; |
| 6658 | hinfo.queryFlags = 0; |
| 6659 | hinfo.pipelineStatistics = 0; |
| 6660 | VkCommandBufferBeginInfo info = {}; |
| 6661 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 6662 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 6663 | info.pInheritanceInfo = &hinfo; |
| 6664 | |
| 6665 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
| 6666 | VkRenderPassBeginInfo rp_begin = {}; |
| 6667 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6668 | rp_begin.pNext = NULL; |
| 6669 | rp_begin.renderPass = renderPass(); |
| 6670 | rp_begin.framebuffer = framebuffer(); |
| 6671 | rp_begin.clearValueCount = 0; // Should be 1 |
| 6672 | |
| 6673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6674 | " has a clearValueCount of 0 but the " |
| 6675 | "actual number of attachments in " |
| 6676 | "renderPass "); |
| 6677 | |
| 6678 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6679 | VK_SUBPASS_CONTENTS_INLINE); |
| 6680 | |
| 6681 | m_errorMonitor->VerifyFound(); |
| 6682 | } |
| 6683 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6684 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6685 | |
| 6686 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6687 | |
| 6688 | m_errorMonitor->SetDesiredFailureMsg( |
| 6689 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6690 | "It is invalid to issue this call inside an active render pass"); |
| 6691 | |
| 6692 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6693 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6694 | |
| 6695 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6696 | BeginCommandBuffer(); |
| 6697 | |
| 6698 | // Call directly into vkEndCommandBuffer instead of the |
| 6699 | // the framework's EndCommandBuffer, which inserts a |
| 6700 | // vkEndRenderPass |
| 6701 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6702 | |
| 6703 | m_errorMonitor->VerifyFound(); |
| 6704 | |
| 6705 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6706 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6707 | } |
| 6708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6710 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6711 | m_errorMonitor->SetDesiredFailureMsg( |
| 6712 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6713 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6714 | |
| 6715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6716 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6717 | |
| 6718 | // Renderpass is started here |
| 6719 | BeginCommandBuffer(); |
| 6720 | |
| 6721 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6722 | vk_testing::Buffer dstBuffer; |
| 6723 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6724 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6725 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6726 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6727 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6728 | } |
| 6729 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6730 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6731 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6732 | m_errorMonitor->SetDesiredFailureMsg( |
| 6733 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6734 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6735 | |
| 6736 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6737 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6738 | |
| 6739 | // Renderpass is started here |
| 6740 | BeginCommandBuffer(); |
| 6741 | |
| 6742 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6743 | vk_testing::Buffer dstBuffer; |
| 6744 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6746 | VkDeviceSize dstOffset = 0; |
| 6747 | VkDeviceSize dataSize = 1024; |
| 6748 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6751 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6752 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6753 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6754 | } |
| 6755 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6756 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6757 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6758 | m_errorMonitor->SetDesiredFailureMsg( |
| 6759 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6760 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6761 | |
| 6762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6763 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6764 | |
| 6765 | // Renderpass is started here |
| 6766 | BeginCommandBuffer(); |
| 6767 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6768 | VkClearColorValue clear_color; |
| 6769 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6770 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6771 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6772 | const int32_t tex_width = 32; |
| 6773 | const int32_t tex_height = 32; |
| 6774 | VkImageCreateInfo image_create_info = {}; |
| 6775 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6776 | image_create_info.pNext = NULL; |
| 6777 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6778 | image_create_info.format = tex_format; |
| 6779 | image_create_info.extent.width = tex_width; |
| 6780 | image_create_info.extent.height = tex_height; |
| 6781 | image_create_info.extent.depth = 1; |
| 6782 | image_create_info.mipLevels = 1; |
| 6783 | image_create_info.arrayLayers = 1; |
| 6784 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6785 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6786 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6787 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6788 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6789 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6790 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6792 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6793 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6795 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6796 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6797 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6798 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6799 | } |
| 6800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6801 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6802 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6803 | m_errorMonitor->SetDesiredFailureMsg( |
| 6804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6805 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6806 | |
| 6807 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6808 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6809 | |
| 6810 | // Renderpass is started here |
| 6811 | BeginCommandBuffer(); |
| 6812 | |
| 6813 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6814 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6815 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6816 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6817 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6818 | image_create_info.extent.width = 64; |
| 6819 | image_create_info.extent.height = 64; |
| 6820 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6821 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6822 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6823 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6825 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6827 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6828 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6829 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | vkCmdClearDepthStencilImage( |
| 6831 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6832 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6833 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6834 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6835 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6836 | } |
| 6837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6838 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6839 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6840 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6841 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6842 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6843 | "vkCmdClearAttachments: This call " |
| 6844 | "must be issued inside an active " |
| 6845 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6846 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6849 | |
| 6850 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6851 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6852 | ASSERT_VK_SUCCESS(err); |
| 6853 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6854 | VkClearAttachment color_attachment; |
| 6855 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6856 | color_attachment.clearValue.color.float32[0] = 0; |
| 6857 | color_attachment.clearValue.color.float32[1] = 0; |
| 6858 | color_attachment.clearValue.color.float32[2] = 0; |
| 6859 | color_attachment.clearValue.color.float32[3] = 0; |
| 6860 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6861 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6862 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6863 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6865 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6866 | } |
| 6867 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6868 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6869 | // Try to add a buffer memory barrier with no buffer. |
| 6870 | m_errorMonitor->SetDesiredFailureMsg( |
| 6871 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6872 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6873 | |
| 6874 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6875 | BeginCommandBuffer(); |
| 6876 | |
| 6877 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6878 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6879 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6880 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6881 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6882 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6883 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6884 | buf_barrier.offset = 0; |
| 6885 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6886 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6887 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6888 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6889 | |
| 6890 | m_errorMonitor->VerifyFound(); |
| 6891 | } |
| 6892 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6893 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6894 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6895 | |
| 6896 | m_errorMonitor->SetDesiredFailureMsg( |
| 6897 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6898 | |
| 6899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6900 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6901 | |
| 6902 | VkMemoryBarrier mem_barrier = {}; |
| 6903 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6904 | mem_barrier.pNext = NULL; |
| 6905 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6906 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6907 | BeginCommandBuffer(); |
| 6908 | // BeginCommandBuffer() starts a render pass |
| 6909 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6910 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6911 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6912 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6913 | m_errorMonitor->VerifyFound(); |
| 6914 | |
| 6915 | m_errorMonitor->SetDesiredFailureMsg( |
| 6916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6917 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6918 | VkImageObj image(m_device); |
| 6919 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6920 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6921 | ASSERT_TRUE(image.initialized()); |
| 6922 | VkImageMemoryBarrier img_barrier = {}; |
| 6923 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6924 | img_barrier.pNext = NULL; |
| 6925 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6926 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6927 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6928 | // New layout can't be UNDEFINED |
| 6929 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6930 | img_barrier.image = image.handle(); |
| 6931 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6932 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6933 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6934 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6935 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6936 | img_barrier.subresourceRange.layerCount = 1; |
| 6937 | img_barrier.subresourceRange.levelCount = 1; |
| 6938 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6939 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6940 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6941 | nullptr, 1, &img_barrier); |
| 6942 | m_errorMonitor->VerifyFound(); |
| 6943 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6944 | |
| 6945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6946 | "Subresource must have the sum of the " |
| 6947 | "baseArrayLayer"); |
| 6948 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6949 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6950 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6951 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6952 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6953 | nullptr, 1, &img_barrier); |
| 6954 | m_errorMonitor->VerifyFound(); |
| 6955 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6956 | |
| 6957 | m_errorMonitor->SetDesiredFailureMsg( |
| 6958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6959 | "Subresource must have the sum of the baseMipLevel"); |
| 6960 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6961 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6962 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6963 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6964 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6965 | nullptr, 1, &img_barrier); |
| 6966 | m_errorMonitor->VerifyFound(); |
| 6967 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6968 | |
| 6969 | m_errorMonitor->SetDesiredFailureMsg( |
| 6970 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6971 | "Buffer Barriers cannot be used during a render pass"); |
| 6972 | vk_testing::Buffer buffer; |
| 6973 | buffer.init(*m_device, 256); |
| 6974 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6975 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6976 | buf_barrier.pNext = NULL; |
| 6977 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6978 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6979 | buf_barrier.buffer = buffer.handle(); |
| 6980 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6981 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6982 | buf_barrier.offset = 0; |
| 6983 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6984 | // Can't send buffer barrier during a render pass |
| 6985 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6986 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6987 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6988 | &buf_barrier, 0, nullptr); |
| 6989 | m_errorMonitor->VerifyFound(); |
| 6990 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6991 | |
| 6992 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6993 | "which is not less than total size"); |
| 6994 | buf_barrier.offset = 257; |
| 6995 | // Offset greater than total size |
| 6996 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6997 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6998 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6999 | &buf_barrier, 0, nullptr); |
| 7000 | m_errorMonitor->VerifyFound(); |
| 7001 | buf_barrier.offset = 0; |
| 7002 | |
| 7003 | m_errorMonitor->SetDesiredFailureMsg( |
| 7004 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 7005 | buf_barrier.size = 257; |
| 7006 | // Size greater than total size |
| 7007 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7008 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7009 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 7010 | &buf_barrier, 0, nullptr); |
| 7011 | m_errorMonitor->VerifyFound(); |
| 7012 | buf_barrier.size = VK_WHOLE_SIZE; |
| 7013 | |
| 7014 | m_errorMonitor->SetDesiredFailureMsg( |
| 7015 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7016 | "Image is a depth and stencil format and thus must " |
| 7017 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 7018 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 7019 | VkDepthStencilObj ds_image(m_device); |
| 7020 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 7021 | ASSERT_TRUE(ds_image.initialized()); |
| 7022 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7023 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 7024 | img_barrier.image = ds_image.handle(); |
| 7025 | // Leave aspectMask at COLOR on purpose |
| 7026 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 7027 | VK_PIPELINE_STAGE_HOST_BIT, |
| 7028 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 7029 | nullptr, 1, &img_barrier); |
| 7030 | m_errorMonitor->VerifyFound(); |
| 7031 | } |
| 7032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7033 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7034 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7035 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7037 | m_errorMonitor->SetDesiredFailureMsg( |
| 7038 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7039 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 7040 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7041 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7042 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7043 | uint32_t qfi = 0; |
| 7044 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7045 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7046 | buffCI.size = 1024; |
| 7047 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7048 | buffCI.queueFamilyIndexCount = 1; |
| 7049 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7050 | |
| 7051 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7052 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7053 | ASSERT_VK_SUCCESS(err); |
| 7054 | |
| 7055 | BeginCommandBuffer(); |
| 7056 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7058 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7059 | // 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] | 7060 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 7061 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7062 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7063 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7065 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7066 | } |
| 7067 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7068 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 7069 | // Create an out-of-range queueFamilyIndex |
| 7070 | m_errorMonitor->SetDesiredFailureMsg( |
| 7071 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7072 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 7073 | "of the indices specified when the device was created, via the " |
| 7074 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7075 | |
| 7076 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7077 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7078 | VkBufferCreateInfo buffCI = {}; |
| 7079 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7080 | buffCI.size = 1024; |
| 7081 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7082 | buffCI.queueFamilyIndexCount = 1; |
| 7083 | // Introduce failure by specifying invalid queue_family_index |
| 7084 | uint32_t qfi = 777; |
| 7085 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7086 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7087 | |
| 7088 | VkBuffer ib; |
| 7089 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7090 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7091 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7092 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7093 | } |
| 7094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7095 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7096 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7097 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7099 | m_errorMonitor->SetDesiredFailureMsg( |
| 7100 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7101 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7102 | |
| 7103 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7104 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7105 | |
| 7106 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7107 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7108 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7109 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7110 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7111 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7112 | } |
| 7113 | |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7114 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
| 7115 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " |
| 7116 | "that do not have correct usage bits sets."); |
| 7117 | VkResult err; |
| 7118 | |
| 7119 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7120 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7121 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7122 | ds_type_count[i].type = VkDescriptorType(i); |
| 7123 | ds_type_count[i].descriptorCount = 1; |
| 7124 | } |
| 7125 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7126 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7127 | ds_pool_ci.pNext = NULL; |
| 7128 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7129 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7130 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 7131 | |
| 7132 | VkDescriptorPool ds_pool; |
| 7133 | err = |
| 7134 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7135 | ASSERT_VK_SUCCESS(err); |
| 7136 | |
| 7137 | // Create 10 layouts where each has a single descriptor of different type |
| 7138 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = |
| 7139 | {}; |
| 7140 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7141 | dsl_binding[i].binding = 0; |
| 7142 | dsl_binding[i].descriptorType = VkDescriptorType(i); |
| 7143 | dsl_binding[i].descriptorCount = 1; |
| 7144 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; |
| 7145 | dsl_binding[i].pImmutableSamplers = NULL; |
| 7146 | } |
| 7147 | |
| 7148 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7149 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7150 | ds_layout_ci.pNext = NULL; |
| 7151 | ds_layout_ci.bindingCount = 1; |
| 7152 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; |
| 7153 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7154 | ds_layout_ci.pBindings = dsl_binding + i; |
| 7155 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, |
| 7156 | NULL, ds_layouts + i); |
| 7157 | ASSERT_VK_SUCCESS(err); |
| 7158 | } |
| 7159 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; |
| 7160 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7161 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7162 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; |
| 7163 | alloc_info.descriptorPool = ds_pool; |
| 7164 | alloc_info.pSetLayouts = ds_layouts; |
| 7165 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7166 | descriptor_sets); |
| 7167 | ASSERT_VK_SUCCESS(err); |
| 7168 | |
| 7169 | // Create a buffer & bufferView to be used for invalid updates |
| 7170 | VkBufferCreateInfo buff_ci = {}; |
| 7171 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7172 | // This usage is not valid for any descriptor type |
| 7173 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; |
| 7174 | buff_ci.size = 256; |
| 7175 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7176 | VkBuffer buffer; |
| 7177 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); |
| 7178 | ASSERT_VK_SUCCESS(err); |
| 7179 | |
| 7180 | VkBufferViewCreateInfo buff_view_ci = {}; |
| 7181 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; |
| 7182 | buff_view_ci.buffer = buffer; |
| 7183 | buff_view_ci.format = VK_FORMAT_R8_UNORM; |
| 7184 | buff_view_ci.range = VK_WHOLE_SIZE; |
| 7185 | VkBufferView buff_view; |
| 7186 | err = |
| 7187 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); |
| 7188 | ASSERT_VK_SUCCESS(err); |
| 7189 | |
| 7190 | // Create an image to be used for invalid updates |
| 7191 | VkImageCreateInfo image_ci = {}; |
| 7192 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7193 | image_ci.imageType = VK_IMAGE_TYPE_2D; |
| 7194 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7195 | image_ci.extent.width = 64; |
| 7196 | image_ci.extent.height = 64; |
| 7197 | image_ci.extent.depth = 1; |
| 7198 | image_ci.mipLevels = 1; |
| 7199 | image_ci.arrayLayers = 1; |
| 7200 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7201 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; |
| 7202 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 7203 | // This usage is not valid for any descriptor type |
| 7204 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7205 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7206 | VkImage image; |
| 7207 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); |
| 7208 | ASSERT_VK_SUCCESS(err); |
| 7209 | // Bind memory to image |
| 7210 | VkMemoryRequirements mem_reqs; |
| 7211 | VkDeviceMemory image_mem; |
| 7212 | bool pass; |
| 7213 | VkMemoryAllocateInfo mem_alloc = {}; |
| 7214 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7215 | mem_alloc.pNext = NULL; |
| 7216 | mem_alloc.allocationSize = 0; |
| 7217 | mem_alloc.memoryTypeIndex = 0; |
| 7218 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 7219 | mem_alloc.allocationSize = mem_reqs.size; |
| 7220 | pass = |
| 7221 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 7222 | ASSERT_TRUE(pass); |
| 7223 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); |
| 7224 | ASSERT_VK_SUCCESS(err); |
| 7225 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); |
| 7226 | ASSERT_VK_SUCCESS(err); |
| 7227 | // Now create view for image |
| 7228 | VkImageViewCreateInfo image_view_ci = {}; |
| 7229 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 7230 | image_view_ci.image = image; |
| 7231 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 7232 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7233 | image_view_ci.subresourceRange.layerCount = 1; |
| 7234 | image_view_ci.subresourceRange.baseArrayLayer = 0; |
| 7235 | image_view_ci.subresourceRange.levelCount = 1; |
| 7236 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7237 | VkImageView image_view; |
| 7238 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, |
| 7239 | &image_view); |
| 7240 | ASSERT_VK_SUCCESS(err); |
| 7241 | |
| 7242 | VkDescriptorBufferInfo buff_info = {}; |
| 7243 | buff_info.buffer = buffer; |
| 7244 | VkDescriptorImageInfo img_info = {}; |
| 7245 | img_info.imageView = image_view; |
| 7246 | VkWriteDescriptorSet descriptor_write = {}; |
| 7247 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 7248 | descriptor_write.dstBinding = 0; |
| 7249 | descriptor_write.descriptorCount = 1; |
| 7250 | descriptor_write.pTexelBufferView = &buff_view; |
| 7251 | descriptor_write.pBufferInfo = &buff_info; |
| 7252 | descriptor_write.pImageInfo = &img_info; |
| 7253 | |
| 7254 | // These error messages align with VkDescriptorType struct |
| 7255 | const char *error_msgs[] = { |
| 7256 | "", // placeholder, no error for SAMPLER descriptor |
| 7257 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7258 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", |
| 7259 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", |
| 7260 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", |
| 7261 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", |
| 7262 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7263 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7264 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", |
| 7265 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", |
| 7266 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; |
| 7267 | // Start loop at 1 as SAMPLER desc type has no usage bit error |
| 7268 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { |
| 7269 | descriptor_write.descriptorType = VkDescriptorType(i); |
| 7270 | descriptor_write.dstSet = descriptor_sets[i]; |
| 7271 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7272 | error_msgs[i]); |
| 7273 | |
| 7274 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, |
| 7275 | NULL); |
| 7276 | |
| 7277 | m_errorMonitor->VerifyFound(); |
| 7278 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); |
| 7279 | } |
| 7280 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); |
| 7281 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7282 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7283 | vkDestroyImageView(m_device->device(), image_view, NULL); |
| 7284 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 7285 | vkDestroyBufferView(m_device->device(), buff_view, NULL); |
| 7286 | vkFreeDescriptorSets(m_device->device(), ds_pool, |
| 7287 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); |
| 7288 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7289 | } |
| 7290 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7291 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7292 | // 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] | 7293 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7294 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7295 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7297 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7298 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7299 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7300 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7301 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7302 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7303 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7304 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7305 | |
| 7306 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7307 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7308 | ds_pool_ci.pNext = NULL; |
| 7309 | ds_pool_ci.maxSets = 1; |
| 7310 | ds_pool_ci.poolSizeCount = 1; |
| 7311 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7312 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7313 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7314 | err = |
| 7315 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7316 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7317 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7318 | dsl_binding.binding = 0; |
| 7319 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7320 | dsl_binding.descriptorCount = 1; |
| 7321 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7322 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7323 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7324 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7325 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7326 | ds_layout_ci.pNext = NULL; |
| 7327 | ds_layout_ci.bindingCount = 1; |
| 7328 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7329 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7330 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7331 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7332 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7333 | ASSERT_VK_SUCCESS(err); |
| 7334 | |
| 7335 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7336 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7337 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7338 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7339 | alloc_info.descriptorPool = ds_pool; |
| 7340 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7341 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7342 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7343 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7344 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7345 | VkSamplerCreateInfo sampler_ci = {}; |
| 7346 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7347 | sampler_ci.pNext = NULL; |
| 7348 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7349 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7350 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7351 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7352 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7353 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7354 | sampler_ci.mipLodBias = 1.0; |
| 7355 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7356 | sampler_ci.maxAnisotropy = 1; |
| 7357 | sampler_ci.compareEnable = VK_FALSE; |
| 7358 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7359 | sampler_ci.minLod = 1.0; |
| 7360 | sampler_ci.maxLod = 1.0; |
| 7361 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7362 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7363 | VkSampler sampler; |
| 7364 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7365 | ASSERT_VK_SUCCESS(err); |
| 7366 | |
| 7367 | VkDescriptorImageInfo info = {}; |
| 7368 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7369 | |
| 7370 | VkWriteDescriptorSet descriptor_write; |
| 7371 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7372 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7373 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7374 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7375 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7376 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7377 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7378 | |
| 7379 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7380 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7381 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7382 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7383 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7384 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7385 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7386 | } |
| 7387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7388 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7389 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7390 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7391 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7392 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7393 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7394 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7395 | "starting at binding offset of 0 combined with update array element " |
| 7396 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7397 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7399 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7400 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7401 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7402 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7403 | |
| 7404 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7405 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7406 | ds_pool_ci.pNext = NULL; |
| 7407 | ds_pool_ci.maxSets = 1; |
| 7408 | ds_pool_ci.poolSizeCount = 1; |
| 7409 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7410 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7411 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7412 | err = |
| 7413 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7414 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7415 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7416 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7417 | dsl_binding.binding = 0; |
| 7418 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7419 | dsl_binding.descriptorCount = 1; |
| 7420 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7421 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7422 | |
| 7423 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7424 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7425 | ds_layout_ci.pNext = NULL; |
| 7426 | ds_layout_ci.bindingCount = 1; |
| 7427 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7428 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7429 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7430 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7431 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7432 | ASSERT_VK_SUCCESS(err); |
| 7433 | |
| 7434 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7435 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7436 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7437 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7438 | alloc_info.descriptorPool = ds_pool; |
| 7439 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7440 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7441 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7442 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7443 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7444 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7445 | VkDescriptorBufferInfo buff_info = {}; |
| 7446 | buff_info.buffer = |
| 7447 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7448 | buff_info.offset = 0; |
| 7449 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7450 | |
| 7451 | VkWriteDescriptorSet descriptor_write; |
| 7452 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7453 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7454 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7455 | descriptor_write.dstArrayElement = |
| 7456 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7457 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7458 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7459 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7460 | |
| 7461 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7463 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7464 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7465 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7466 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7467 | } |
| 7468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7469 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7470 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7471 | // index 2 |
| 7472 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7473 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7474 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7475 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7476 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7477 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7478 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7479 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7480 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7481 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7482 | |
| 7483 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7485 | ds_pool_ci.pNext = NULL; |
| 7486 | ds_pool_ci.maxSets = 1; |
| 7487 | ds_pool_ci.poolSizeCount = 1; |
| 7488 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7489 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7490 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7491 | err = |
| 7492 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7493 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7494 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7495 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7496 | dsl_binding.binding = 0; |
| 7497 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7498 | dsl_binding.descriptorCount = 1; |
| 7499 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7500 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7501 | |
| 7502 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7503 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7504 | ds_layout_ci.pNext = NULL; |
| 7505 | ds_layout_ci.bindingCount = 1; |
| 7506 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7507 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7508 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7509 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7510 | ASSERT_VK_SUCCESS(err); |
| 7511 | |
| 7512 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7513 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7514 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7515 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7516 | alloc_info.descriptorPool = ds_pool; |
| 7517 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7518 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7519 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7520 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7521 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7522 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7523 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7524 | sampler_ci.pNext = NULL; |
| 7525 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7526 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7527 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7528 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7529 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7530 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7531 | sampler_ci.mipLodBias = 1.0; |
| 7532 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7533 | sampler_ci.maxAnisotropy = 1; |
| 7534 | sampler_ci.compareEnable = VK_FALSE; |
| 7535 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7536 | sampler_ci.minLod = 1.0; |
| 7537 | sampler_ci.maxLod = 1.0; |
| 7538 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7539 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7540 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7541 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7542 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7543 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7544 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7545 | VkDescriptorImageInfo info = {}; |
| 7546 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7547 | |
| 7548 | VkWriteDescriptorSet descriptor_write; |
| 7549 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7550 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7551 | descriptor_write.dstSet = descriptorSet; |
| 7552 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7553 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7554 | // 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] | 7555 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7556 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7557 | |
| 7558 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7559 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7560 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7561 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7562 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7563 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7564 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7565 | } |
| 7566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7567 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7568 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7569 | // types |
| 7570 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7571 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7572 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7573 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7574 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7576 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7577 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7578 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7579 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7580 | |
| 7581 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7582 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7583 | ds_pool_ci.pNext = NULL; |
| 7584 | ds_pool_ci.maxSets = 1; |
| 7585 | ds_pool_ci.poolSizeCount = 1; |
| 7586 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7587 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7588 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7589 | err = |
| 7590 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7591 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7592 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7593 | dsl_binding.binding = 0; |
| 7594 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7595 | dsl_binding.descriptorCount = 1; |
| 7596 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7597 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7598 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7599 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7600 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7601 | ds_layout_ci.pNext = NULL; |
| 7602 | ds_layout_ci.bindingCount = 1; |
| 7603 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7604 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7605 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7606 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7607 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7608 | ASSERT_VK_SUCCESS(err); |
| 7609 | |
| 7610 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7611 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7612 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7613 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7614 | alloc_info.descriptorPool = ds_pool; |
| 7615 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7616 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7617 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7618 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7619 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7620 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7621 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7622 | sampler_ci.pNext = NULL; |
| 7623 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7624 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7625 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7626 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7627 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7628 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7629 | sampler_ci.mipLodBias = 1.0; |
| 7630 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7631 | sampler_ci.maxAnisotropy = 1; |
| 7632 | sampler_ci.compareEnable = VK_FALSE; |
| 7633 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7634 | sampler_ci.minLod = 1.0; |
| 7635 | sampler_ci.maxLod = 1.0; |
| 7636 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7637 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7638 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7639 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7640 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7641 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7642 | VkDescriptorImageInfo info = {}; |
| 7643 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7644 | |
| 7645 | VkWriteDescriptorSet descriptor_write; |
| 7646 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7647 | descriptor_write.sType = |
| 7648 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7649 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7650 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7651 | // 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] | 7652 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7653 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7654 | |
| 7655 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7656 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7657 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7658 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7659 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7660 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7661 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7662 | } |
| 7663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7664 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7665 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7666 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7668 | m_errorMonitor->SetDesiredFailureMsg( |
| 7669 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7670 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7671 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7673 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7674 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7675 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7676 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7677 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7678 | |
| 7679 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7680 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7681 | ds_pool_ci.pNext = NULL; |
| 7682 | ds_pool_ci.maxSets = 1; |
| 7683 | ds_pool_ci.poolSizeCount = 1; |
| 7684 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7685 | |
| 7686 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7687 | err = |
| 7688 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7689 | ASSERT_VK_SUCCESS(err); |
| 7690 | |
| 7691 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7692 | dsl_binding.binding = 0; |
| 7693 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7694 | dsl_binding.descriptorCount = 1; |
| 7695 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7696 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7697 | |
| 7698 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7699 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7700 | ds_layout_ci.pNext = NULL; |
| 7701 | ds_layout_ci.bindingCount = 1; |
| 7702 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7703 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7704 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7705 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7706 | ASSERT_VK_SUCCESS(err); |
| 7707 | |
| 7708 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7709 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7710 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7711 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7712 | alloc_info.descriptorPool = ds_pool; |
| 7713 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7714 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7715 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7716 | ASSERT_VK_SUCCESS(err); |
| 7717 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7718 | VkSampler sampler = |
| 7719 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7720 | |
| 7721 | VkDescriptorImageInfo descriptor_info; |
| 7722 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7723 | descriptor_info.sampler = sampler; |
| 7724 | |
| 7725 | VkWriteDescriptorSet descriptor_write; |
| 7726 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7727 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7728 | descriptor_write.dstSet = descriptorSet; |
| 7729 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7730 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7731 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7732 | descriptor_write.pImageInfo = &descriptor_info; |
| 7733 | |
| 7734 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7735 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7736 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7737 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7738 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7739 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7740 | } |
| 7741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7742 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7743 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7744 | // imageView |
| 7745 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7746 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7747 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7748 | "Attempted write update to combined " |
| 7749 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7750 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7751 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7752 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7753 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7754 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7755 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7756 | |
| 7757 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7758 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7759 | ds_pool_ci.pNext = NULL; |
| 7760 | ds_pool_ci.maxSets = 1; |
| 7761 | ds_pool_ci.poolSizeCount = 1; |
| 7762 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7763 | |
| 7764 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7765 | err = |
| 7766 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7767 | ASSERT_VK_SUCCESS(err); |
| 7768 | |
| 7769 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7770 | dsl_binding.binding = 0; |
| 7771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7772 | dsl_binding.descriptorCount = 1; |
| 7773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7774 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7775 | |
| 7776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7778 | ds_layout_ci.pNext = NULL; |
| 7779 | ds_layout_ci.bindingCount = 1; |
| 7780 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7781 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7782 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7783 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7784 | ASSERT_VK_SUCCESS(err); |
| 7785 | |
| 7786 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7787 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7788 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7789 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7790 | alloc_info.descriptorPool = ds_pool; |
| 7791 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7792 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7793 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7794 | ASSERT_VK_SUCCESS(err); |
| 7795 | |
| 7796 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7797 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7798 | sampler_ci.pNext = NULL; |
| 7799 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7800 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7801 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7802 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7803 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7804 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7805 | sampler_ci.mipLodBias = 1.0; |
| 7806 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7807 | sampler_ci.maxAnisotropy = 1; |
| 7808 | sampler_ci.compareEnable = VK_FALSE; |
| 7809 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7810 | sampler_ci.minLod = 1.0; |
| 7811 | sampler_ci.maxLod = 1.0; |
| 7812 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7813 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7814 | |
| 7815 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7816 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7817 | ASSERT_VK_SUCCESS(err); |
| 7818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7819 | VkImageView view = |
| 7820 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7821 | |
| 7822 | VkDescriptorImageInfo descriptor_info; |
| 7823 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7824 | descriptor_info.sampler = sampler; |
| 7825 | descriptor_info.imageView = view; |
| 7826 | |
| 7827 | VkWriteDescriptorSet descriptor_write; |
| 7828 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7829 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7830 | descriptor_write.dstSet = descriptorSet; |
| 7831 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7832 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7833 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7834 | descriptor_write.pImageInfo = &descriptor_info; |
| 7835 | |
| 7836 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7837 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7838 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7839 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7840 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7841 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7842 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7843 | } |
| 7844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7845 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7846 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7847 | // into the other |
| 7848 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7849 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7851 | " binding #1 with type " |
| 7852 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7853 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7854 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7855 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7856 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7857 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7858 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7859 | ds_type_count[0].descriptorCount = 1; |
| 7860 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7861 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7862 | |
| 7863 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7864 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7865 | ds_pool_ci.pNext = NULL; |
| 7866 | ds_pool_ci.maxSets = 1; |
| 7867 | ds_pool_ci.poolSizeCount = 2; |
| 7868 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7869 | |
| 7870 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7871 | err = |
| 7872 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7873 | ASSERT_VK_SUCCESS(err); |
| 7874 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7875 | dsl_binding[0].binding = 0; |
| 7876 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7877 | dsl_binding[0].descriptorCount = 1; |
| 7878 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7879 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7880 | dsl_binding[1].binding = 1; |
| 7881 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7882 | dsl_binding[1].descriptorCount = 1; |
| 7883 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7884 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7885 | |
| 7886 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7887 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7888 | ds_layout_ci.pNext = NULL; |
| 7889 | ds_layout_ci.bindingCount = 2; |
| 7890 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7891 | |
| 7892 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7893 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7894 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7895 | ASSERT_VK_SUCCESS(err); |
| 7896 | |
| 7897 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7898 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7899 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7900 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7901 | alloc_info.descriptorPool = ds_pool; |
| 7902 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7903 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7904 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7905 | ASSERT_VK_SUCCESS(err); |
| 7906 | |
| 7907 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7908 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7909 | sampler_ci.pNext = NULL; |
| 7910 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7911 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7912 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7913 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7914 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7915 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7916 | sampler_ci.mipLodBias = 1.0; |
| 7917 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7918 | sampler_ci.maxAnisotropy = 1; |
| 7919 | sampler_ci.compareEnable = VK_FALSE; |
| 7920 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7921 | sampler_ci.minLod = 1.0; |
| 7922 | sampler_ci.maxLod = 1.0; |
| 7923 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7924 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7925 | |
| 7926 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7927 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7928 | ASSERT_VK_SUCCESS(err); |
| 7929 | |
| 7930 | VkDescriptorImageInfo info = {}; |
| 7931 | info.sampler = sampler; |
| 7932 | |
| 7933 | VkWriteDescriptorSet descriptor_write; |
| 7934 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7935 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7936 | descriptor_write.dstSet = descriptorSet; |
| 7937 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7938 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7939 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7940 | descriptor_write.pImageInfo = &info; |
| 7941 | // This write update should succeed |
| 7942 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7943 | // Now perform a copy update that fails due to type mismatch |
| 7944 | VkCopyDescriptorSet copy_ds_update; |
| 7945 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7946 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7947 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7948 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7949 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7950 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7951 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7952 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7953 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7954 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7955 | // 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] | 7956 | m_errorMonitor->SetDesiredFailureMsg( |
| 7957 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7958 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7959 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7960 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7961 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7962 | copy_ds_update.srcBinding = |
| 7963 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7964 | copy_ds_update.dstSet = descriptorSet; |
| 7965 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7966 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7967 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7968 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7969 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7970 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7971 | // 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] | 7972 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7974 | "update array offset of 0 and update of " |
| 7975 | "5 descriptors oversteps total number " |
| 7976 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7977 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7978 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7979 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7980 | copy_ds_update.srcSet = descriptorSet; |
| 7981 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7982 | copy_ds_update.dstSet = descriptorSet; |
| 7983 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7984 | copy_ds_update.descriptorCount = |
| 7985 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7986 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7987 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7988 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7989 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7990 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7991 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7992 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7993 | } |
| 7994 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7995 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7996 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7997 | // sampleCount |
| 7998 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7999 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8000 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8001 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8002 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8003 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8004 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8005 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8006 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8007 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8008 | |
| 8009 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8010 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8011 | ds_pool_ci.pNext = NULL; |
| 8012 | ds_pool_ci.maxSets = 1; |
| 8013 | ds_pool_ci.poolSizeCount = 1; |
| 8014 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8015 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8016 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | err = |
| 8018 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8019 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8020 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8021 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8022 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8023 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8024 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8025 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8026 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8027 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8028 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8029 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8030 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8031 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8032 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8033 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8034 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8035 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8036 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8037 | ASSERT_VK_SUCCESS(err); |
| 8038 | |
| 8039 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8040 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8041 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8042 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8043 | alloc_info.descriptorPool = ds_pool; |
| 8044 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8045 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8046 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8047 | ASSERT_VK_SUCCESS(err); |
| 8048 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8049 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8050 | pipe_ms_state_ci.sType = |
| 8051 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8052 | pipe_ms_state_ci.pNext = NULL; |
| 8053 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8054 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8055 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8056 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8057 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8058 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8059 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8060 | pipeline_layout_ci.pNext = NULL; |
| 8061 | pipeline_layout_ci.setLayoutCount = 1; |
| 8062 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8063 | |
| 8064 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8065 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8066 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8067 | ASSERT_VK_SUCCESS(err); |
| 8068 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8069 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8070 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8071 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8072 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8073 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8074 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8075 | VkPipelineObj pipe(m_device); |
| 8076 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8077 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8078 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8079 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8080 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8081 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8082 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8083 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8084 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8085 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8086 | // Render triangle (the error should trigger on the attempt to draw). |
| 8087 | Draw(3, 1, 0, 0); |
| 8088 | |
| 8089 | // Finalize recording of the command buffer |
| 8090 | EndCommandBuffer(); |
| 8091 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8092 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8093 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8094 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8095 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8096 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8097 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8098 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8099 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 8100 | // Create Pipeline where the number of blend attachments doesn't match the |
| 8101 | // number of color attachments. In this case, we don't add any color |
| 8102 | // blend attachments even though we have a color attachment. |
| 8103 | VkResult err; |
| 8104 | |
| 8105 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8106 | "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] | 8107 | |
| 8108 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8109 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8110 | VkDescriptorPoolSize ds_type_count = {}; |
| 8111 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8112 | ds_type_count.descriptorCount = 1; |
| 8113 | |
| 8114 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 8115 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8116 | ds_pool_ci.pNext = NULL; |
| 8117 | ds_pool_ci.maxSets = 1; |
| 8118 | ds_pool_ci.poolSizeCount = 1; |
| 8119 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8120 | |
| 8121 | VkDescriptorPool ds_pool; |
| 8122 | err = |
| 8123 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 8124 | ASSERT_VK_SUCCESS(err); |
| 8125 | |
| 8126 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8127 | dsl_binding.binding = 0; |
| 8128 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8129 | dsl_binding.descriptorCount = 1; |
| 8130 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8131 | dsl_binding.pImmutableSamplers = NULL; |
| 8132 | |
| 8133 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 8134 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8135 | ds_layout_ci.pNext = NULL; |
| 8136 | ds_layout_ci.bindingCount = 1; |
| 8137 | ds_layout_ci.pBindings = &dsl_binding; |
| 8138 | |
| 8139 | VkDescriptorSetLayout ds_layout; |
| 8140 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8141 | &ds_layout); |
| 8142 | ASSERT_VK_SUCCESS(err); |
| 8143 | |
| 8144 | VkDescriptorSet descriptorSet; |
| 8145 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 8146 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 8147 | alloc_info.descriptorSetCount = 1; |
| 8148 | alloc_info.descriptorPool = ds_pool; |
| 8149 | alloc_info.pSetLayouts = &ds_layout; |
| 8150 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8151 | &descriptorSet); |
| 8152 | ASSERT_VK_SUCCESS(err); |
| 8153 | |
| 8154 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 8155 | pipe_ms_state_ci.sType = |
| 8156 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8157 | pipe_ms_state_ci.pNext = NULL; |
| 8158 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8159 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8160 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8161 | pipe_ms_state_ci.pSampleMask = NULL; |
| 8162 | |
| 8163 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 8164 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8165 | pipeline_layout_ci.pNext = NULL; |
| 8166 | pipeline_layout_ci.setLayoutCount = 1; |
| 8167 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8168 | |
| 8169 | VkPipelineLayout pipeline_layout; |
| 8170 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8171 | &pipeline_layout); |
| 8172 | ASSERT_VK_SUCCESS(err); |
| 8173 | |
| 8174 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8175 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8176 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8177 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8178 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8179 | // but add it to be able to run on more devices |
| 8180 | VkPipelineObj pipe(m_device); |
| 8181 | pipe.AddShader(&vs); |
| 8182 | pipe.AddShader(&fs); |
| 8183 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8184 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 8185 | |
| 8186 | BeginCommandBuffer(); |
| 8187 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8188 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8189 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8190 | // Render triangle (the error should trigger on the attempt to draw). |
| 8191 | Draw(3, 1, 0, 0); |
| 8192 | |
| 8193 | // Finalize recording of the command buffer |
| 8194 | EndCommandBuffer(); |
| 8195 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8196 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8197 | |
| 8198 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8199 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8200 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 8201 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8203 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 8204 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 8205 | // to issuing a Draw |
| 8206 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8208 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8209 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8210 | "vkCmdClearAttachments() issued on CB object "); |
| 8211 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8212 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8213 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8214 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8215 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8216 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8217 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8218 | |
| 8219 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8220 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8221 | ds_pool_ci.pNext = NULL; |
| 8222 | ds_pool_ci.maxSets = 1; |
| 8223 | ds_pool_ci.poolSizeCount = 1; |
| 8224 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8225 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8226 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8227 | err = |
| 8228 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8229 | ASSERT_VK_SUCCESS(err); |
| 8230 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8231 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8232 | dsl_binding.binding = 0; |
| 8233 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8234 | dsl_binding.descriptorCount = 1; |
| 8235 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8236 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8237 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8238 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8239 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8240 | ds_layout_ci.pNext = NULL; |
| 8241 | ds_layout_ci.bindingCount = 1; |
| 8242 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8243 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8244 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8245 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8246 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8247 | ASSERT_VK_SUCCESS(err); |
| 8248 | |
| 8249 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8250 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8251 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8252 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8253 | alloc_info.descriptorPool = ds_pool; |
| 8254 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8255 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8256 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8257 | ASSERT_VK_SUCCESS(err); |
| 8258 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8259 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | pipe_ms_state_ci.sType = |
| 8261 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8262 | pipe_ms_state_ci.pNext = NULL; |
| 8263 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8264 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8265 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8266 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8267 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8268 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8269 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8270 | pipeline_layout_ci.pNext = NULL; |
| 8271 | pipeline_layout_ci.setLayoutCount = 1; |
| 8272 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8273 | |
| 8274 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8275 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8276 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8277 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8279 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8280 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8281 | // 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] | 8282 | // on more devices |
| 8283 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8284 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8285 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8286 | VkPipelineObj pipe(m_device); |
| 8287 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8288 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8289 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8290 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8291 | |
| 8292 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8294 | // Main thing we care about for this test is that the VkImage obj we're |
| 8295 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8296 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8297 | VkClearAttachment color_attachment; |
| 8298 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8299 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8300 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8301 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8302 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8303 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8304 | VkClearRect clear_rect = { |
| 8305 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8306 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8307 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8308 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8309 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8310 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8311 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8312 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8313 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8314 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8315 | } |
| 8316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8317 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8318 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8319 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8320 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8321 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8322 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8323 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8324 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8325 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8326 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8327 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8328 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8329 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8330 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8331 | |
| 8332 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8333 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8334 | ds_pool_ci.pNext = NULL; |
| 8335 | ds_pool_ci.maxSets = 1; |
| 8336 | ds_pool_ci.poolSizeCount = 1; |
| 8337 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8338 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8339 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8340 | err = |
| 8341 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8342 | ASSERT_VK_SUCCESS(err); |
| 8343 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8344 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8345 | dsl_binding.binding = 0; |
| 8346 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8347 | dsl_binding.descriptorCount = 1; |
| 8348 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8349 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8350 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8351 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8352 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8353 | ds_layout_ci.pNext = NULL; |
| 8354 | ds_layout_ci.bindingCount = 1; |
| 8355 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8356 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8357 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8358 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8359 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8360 | ASSERT_VK_SUCCESS(err); |
| 8361 | |
| 8362 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8363 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8364 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8365 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8366 | alloc_info.descriptorPool = ds_pool; |
| 8367 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8368 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8369 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8370 | ASSERT_VK_SUCCESS(err); |
| 8371 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8372 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8373 | pipe_ms_state_ci.sType = |
| 8374 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8375 | pipe_ms_state_ci.pNext = NULL; |
| 8376 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8377 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8378 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8379 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8380 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8381 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8382 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8383 | pipeline_layout_ci.pNext = NULL; |
| 8384 | pipeline_layout_ci.setLayoutCount = 1; |
| 8385 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8386 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8388 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8389 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8390 | ASSERT_VK_SUCCESS(err); |
| 8391 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8392 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8393 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8394 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8395 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8396 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8397 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8398 | VkPipelineObj pipe(m_device); |
| 8399 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8400 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8401 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8402 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8403 | pipe.SetViewport(m_viewports); |
| 8404 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8405 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8406 | |
| 8407 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8408 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8409 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8410 | // Don't care about actual data, just need to get to draw to flag error |
| 8411 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8412 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8413 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8414 | 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] | 8415 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8416 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8417 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8418 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8419 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8420 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8421 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8422 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8423 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8424 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8425 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8426 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8427 | "images in the wrong layout when they're copied or transitioned."); |
| 8428 | // 3 in ValidateCmdBufImageLayouts |
| 8429 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8430 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8431 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8432 | m_errorMonitor->SetDesiredFailureMsg( |
| 8433 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8434 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8435 | |
| 8436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8437 | // Create src & dst images to use for copy operations |
| 8438 | VkImage src_image; |
| 8439 | VkImage dst_image; |
| 8440 | |
| 8441 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8442 | const int32_t tex_width = 32; |
| 8443 | const int32_t tex_height = 32; |
| 8444 | |
| 8445 | VkImageCreateInfo image_create_info = {}; |
| 8446 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8447 | image_create_info.pNext = NULL; |
| 8448 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8449 | image_create_info.format = tex_format; |
| 8450 | image_create_info.extent.width = tex_width; |
| 8451 | image_create_info.extent.height = tex_height; |
| 8452 | image_create_info.extent.depth = 1; |
| 8453 | image_create_info.mipLevels = 1; |
| 8454 | image_create_info.arrayLayers = 4; |
| 8455 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8456 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8457 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8458 | image_create_info.flags = 0; |
| 8459 | |
| 8460 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8461 | ASSERT_VK_SUCCESS(err); |
| 8462 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8463 | ASSERT_VK_SUCCESS(err); |
| 8464 | |
| 8465 | BeginCommandBuffer(); |
| 8466 | VkImageCopy copyRegion; |
| 8467 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8468 | copyRegion.srcSubresource.mipLevel = 0; |
| 8469 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8470 | copyRegion.srcSubresource.layerCount = 1; |
| 8471 | copyRegion.srcOffset.x = 0; |
| 8472 | copyRegion.srcOffset.y = 0; |
| 8473 | copyRegion.srcOffset.z = 0; |
| 8474 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8475 | copyRegion.dstSubresource.mipLevel = 0; |
| 8476 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8477 | copyRegion.dstSubresource.layerCount = 1; |
| 8478 | copyRegion.dstOffset.x = 0; |
| 8479 | copyRegion.dstOffset.y = 0; |
| 8480 | copyRegion.dstOffset.z = 0; |
| 8481 | copyRegion.extent.width = 1; |
| 8482 | copyRegion.extent.height = 1; |
| 8483 | copyRegion.extent.depth = 1; |
| 8484 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8485 | m_errorMonitor->VerifyFound(); |
| 8486 | // Now cause error due to src image layout changing |
| 8487 | m_errorMonitor->SetDesiredFailureMsg( |
| 8488 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8489 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8490 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8491 | m_errorMonitor->VerifyFound(); |
| 8492 | // Final src error is due to bad layout type |
| 8493 | m_errorMonitor->SetDesiredFailureMsg( |
| 8494 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8495 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8496 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8497 | m_errorMonitor->VerifyFound(); |
| 8498 | // Now verify same checks for dst |
| 8499 | m_errorMonitor->SetDesiredFailureMsg( |
| 8500 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8501 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8502 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8503 | m_errorMonitor->VerifyFound(); |
| 8504 | // Now cause error due to src image layout changing |
| 8505 | m_errorMonitor->SetDesiredFailureMsg( |
| 8506 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8507 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8508 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8509 | m_errorMonitor->VerifyFound(); |
| 8510 | m_errorMonitor->SetDesiredFailureMsg( |
| 8511 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8512 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8513 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8514 | m_errorMonitor->VerifyFound(); |
| 8515 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8516 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8517 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8518 | image_barrier[0].image = src_image; |
| 8519 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8520 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8521 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8522 | m_errorMonitor->SetDesiredFailureMsg( |
| 8523 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8524 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8525 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8526 | m_errorMonitor->VerifyFound(); |
| 8527 | |
| 8528 | // Finally some layout errors at RenderPass create time |
| 8529 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8530 | VkAttachmentReference attach = {}; |
| 8531 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8532 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8533 | VkSubpassDescription subpass = {}; |
| 8534 | subpass.inputAttachmentCount = 1; |
| 8535 | subpass.pInputAttachments = &attach; |
| 8536 | VkRenderPassCreateInfo rpci = {}; |
| 8537 | rpci.subpassCount = 1; |
| 8538 | rpci.pSubpasses = &subpass; |
| 8539 | rpci.attachmentCount = 1; |
| 8540 | VkAttachmentDescription attach_desc = {}; |
| 8541 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8542 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8543 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8544 | VkRenderPass rp; |
| 8545 | m_errorMonitor->SetDesiredFailureMsg( |
| 8546 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8547 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8548 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8549 | m_errorMonitor->VerifyFound(); |
| 8550 | // error w/ non-general layout |
| 8551 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8552 | |
| 8553 | m_errorMonitor->SetDesiredFailureMsg( |
| 8554 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8555 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8556 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8557 | m_errorMonitor->VerifyFound(); |
| 8558 | subpass.inputAttachmentCount = 0; |
| 8559 | subpass.colorAttachmentCount = 1; |
| 8560 | subpass.pColorAttachments = &attach; |
| 8561 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8562 | // perf warning for GENERAL layout on color attachment |
| 8563 | m_errorMonitor->SetDesiredFailureMsg( |
| 8564 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8565 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8566 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8567 | m_errorMonitor->VerifyFound(); |
| 8568 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8569 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8570 | m_errorMonitor->SetDesiredFailureMsg( |
| 8571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8572 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8573 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8574 | m_errorMonitor->VerifyFound(); |
| 8575 | subpass.colorAttachmentCount = 0; |
| 8576 | subpass.pDepthStencilAttachment = &attach; |
| 8577 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8578 | // perf warning for GENERAL layout on DS attachment |
| 8579 | m_errorMonitor->SetDesiredFailureMsg( |
| 8580 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8581 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8582 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8583 | m_errorMonitor->VerifyFound(); |
| 8584 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8585 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8586 | m_errorMonitor->SetDesiredFailureMsg( |
| 8587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8588 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8589 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8590 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8591 | // For this error we need a valid renderpass so create default one |
| 8592 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8593 | attach.attachment = 0; |
| 8594 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8595 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8596 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8597 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8598 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8599 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8600 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8601 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8602 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8603 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8604 | " with invalid first layout " |
| 8605 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8606 | "ONLY_OPTIMAL"); |
| 8607 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8608 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8609 | |
| 8610 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8611 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8612 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8613 | #endif // DRAW_STATE_TESTS |
| 8614 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8615 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8616 | #if GTEST_IS_THREADSAFE |
| 8617 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8618 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8619 | VkEvent event; |
| 8620 | bool bailout; |
| 8621 | }; |
| 8622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8623 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8624 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8626 | for (int i = 0; i < 10000; i++) { |
| 8627 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8628 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8629 | if (data->bailout) { |
| 8630 | break; |
| 8631 | } |
| 8632 | } |
| 8633 | return NULL; |
| 8634 | } |
| 8635 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8636 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8637 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8638 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8639 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8640 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8641 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8642 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8643 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8644 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8645 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8646 | // Calls AllocateCommandBuffers |
| 8647 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8648 | |
| 8649 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8650 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8651 | |
| 8652 | VkEventCreateInfo event_info; |
| 8653 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8654 | VkResult err; |
| 8655 | |
| 8656 | memset(&event_info, 0, sizeof(event_info)); |
| 8657 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8658 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8659 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8660 | ASSERT_VK_SUCCESS(err); |
| 8661 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8662 | err = vkResetEvent(device(), event); |
| 8663 | ASSERT_VK_SUCCESS(err); |
| 8664 | |
| 8665 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8666 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8667 | data.event = event; |
| 8668 | data.bailout = false; |
| 8669 | m_errorMonitor->SetBailout(&data.bailout); |
| 8670 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8671 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8672 | // Add many entries to command buffer from this thread at the same time. |
| 8673 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8674 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8675 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8676 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8677 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8678 | m_errorMonitor->SetBailout(NULL); |
| 8679 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8680 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8681 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8682 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8683 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8684 | #endif // GTEST_IS_THREADSAFE |
| 8685 | #endif // THREADING_TESTS |
| 8686 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8687 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8688 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8689 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8690 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8691 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8692 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8693 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8694 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8695 | VkShaderModule module; |
| 8696 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8697 | struct icd_spv_header spv; |
| 8698 | |
| 8699 | spv.magic = ICD_SPV_MAGIC; |
| 8700 | spv.version = ICD_SPV_VERSION; |
| 8701 | spv.gen_magic = 0; |
| 8702 | |
| 8703 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8704 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8705 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8706 | moduleCreateInfo.codeSize = 4; |
| 8707 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8708 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8709 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8710 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8711 | } |
| 8712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8713 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8714 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8715 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8716 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8719 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8720 | VkShaderModule module; |
| 8721 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8722 | struct icd_spv_header spv; |
| 8723 | |
| 8724 | spv.magic = ~ICD_SPV_MAGIC; |
| 8725 | spv.version = ICD_SPV_VERSION; |
| 8726 | spv.gen_magic = 0; |
| 8727 | |
| 8728 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8729 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8730 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8731 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8732 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8733 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8734 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8735 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8736 | } |
| 8737 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8738 | #if 0 |
| 8739 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8740 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8741 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8742 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8743 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8744 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8745 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8746 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8747 | VkShaderModule module; |
| 8748 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8749 | struct icd_spv_header spv; |
| 8750 | |
| 8751 | spv.magic = ICD_SPV_MAGIC; |
| 8752 | spv.version = ~ICD_SPV_VERSION; |
| 8753 | spv.gen_magic = 0; |
| 8754 | |
| 8755 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8756 | moduleCreateInfo.pNext = NULL; |
| 8757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8758 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8759 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8760 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8761 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8762 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8763 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8764 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8765 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8767 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8768 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8769 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8770 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8771 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8772 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8773 | |
| 8774 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8775 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8776 | "\n" |
| 8777 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8778 | "out gl_PerVertex {\n" |
| 8779 | " vec4 gl_Position;\n" |
| 8780 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8781 | "void main(){\n" |
| 8782 | " gl_Position = vec4(1);\n" |
| 8783 | " x = 0;\n" |
| 8784 | "}\n"; |
| 8785 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8786 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8787 | "\n" |
| 8788 | "layout(location=0) out vec4 color;\n" |
| 8789 | "void main(){\n" |
| 8790 | " color = vec4(1);\n" |
| 8791 | "}\n"; |
| 8792 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8793 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8794 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8795 | |
| 8796 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8797 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8798 | pipe.AddShader(&vs); |
| 8799 | pipe.AddShader(&fs); |
| 8800 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8801 | VkDescriptorSetObj descriptorSet(m_device); |
| 8802 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8803 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8804 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8805 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8806 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8807 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8808 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8809 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8810 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8811 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8812 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8813 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8814 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8815 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8816 | |
| 8817 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8818 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8819 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8820 | "out gl_PerVertex {\n" |
| 8821 | " vec4 gl_Position;\n" |
| 8822 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8823 | "void main(){\n" |
| 8824 | " gl_Position = vec4(1);\n" |
| 8825 | "}\n"; |
| 8826 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8827 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8828 | "\n" |
| 8829 | "layout(location=0) in float x;\n" |
| 8830 | "layout(location=0) out vec4 color;\n" |
| 8831 | "void main(){\n" |
| 8832 | " color = vec4(x);\n" |
| 8833 | "}\n"; |
| 8834 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8835 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8836 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8837 | |
| 8838 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8839 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8840 | pipe.AddShader(&vs); |
| 8841 | pipe.AddShader(&fs); |
| 8842 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8843 | VkDescriptorSetObj descriptorSet(m_device); |
| 8844 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8845 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8846 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8847 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8848 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8849 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8850 | } |
| 8851 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8852 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8853 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8854 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8855 | |
| 8856 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8857 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8858 | |
| 8859 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8860 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8861 | "\n" |
| 8862 | "out gl_PerVertex {\n" |
| 8863 | " vec4 gl_Position;\n" |
| 8864 | "};\n" |
| 8865 | "void main(){\n" |
| 8866 | " gl_Position = vec4(1);\n" |
| 8867 | "}\n"; |
| 8868 | char const *fsSource = |
| 8869 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8870 | "\n" |
| 8871 | "in block { layout(location=0) float x; } ins;\n" |
| 8872 | "layout(location=0) out vec4 color;\n" |
| 8873 | "void main(){\n" |
| 8874 | " color = vec4(ins.x);\n" |
| 8875 | "}\n"; |
| 8876 | |
| 8877 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8878 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8879 | |
| 8880 | VkPipelineObj pipe(m_device); |
| 8881 | pipe.AddColorAttachment(); |
| 8882 | pipe.AddShader(&vs); |
| 8883 | pipe.AddShader(&fs); |
| 8884 | |
| 8885 | VkDescriptorSetObj descriptorSet(m_device); |
| 8886 | descriptorSet.AppendDummy(); |
| 8887 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8888 | |
| 8889 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8890 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8891 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8892 | } |
| 8893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8894 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8895 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8896 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8897 | "output arr[2] of float32' vs 'ptr to " |
| 8898 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8899 | |
| 8900 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8901 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8902 | |
| 8903 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8904 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8905 | "\n" |
| 8906 | "layout(location=0) out float x[2];\n" |
| 8907 | "out gl_PerVertex {\n" |
| 8908 | " vec4 gl_Position;\n" |
| 8909 | "};\n" |
| 8910 | "void main(){\n" |
| 8911 | " x[0] = 0; x[1] = 0;\n" |
| 8912 | " gl_Position = vec4(1);\n" |
| 8913 | "}\n"; |
| 8914 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8915 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8916 | "\n" |
| 8917 | "layout(location=0) in float x[3];\n" |
| 8918 | "layout(location=0) out vec4 color;\n" |
| 8919 | "void main(){\n" |
| 8920 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8921 | "}\n"; |
| 8922 | |
| 8923 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8924 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8925 | |
| 8926 | VkPipelineObj pipe(m_device); |
| 8927 | pipe.AddColorAttachment(); |
| 8928 | pipe.AddShader(&vs); |
| 8929 | pipe.AddShader(&fs); |
| 8930 | |
| 8931 | VkDescriptorSetObj descriptorSet(m_device); |
| 8932 | descriptorSet.AppendDummy(); |
| 8933 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8934 | |
| 8935 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8936 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8937 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8938 | } |
| 8939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8940 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8941 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8942 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8943 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8944 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8945 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8946 | |
| 8947 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8948 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8949 | "\n" |
| 8950 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8951 | "out gl_PerVertex {\n" |
| 8952 | " vec4 gl_Position;\n" |
| 8953 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8954 | "void main(){\n" |
| 8955 | " x = 0;\n" |
| 8956 | " gl_Position = vec4(1);\n" |
| 8957 | "}\n"; |
| 8958 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8959 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8960 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8961 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8962 | "layout(location=0) out vec4 color;\n" |
| 8963 | "void main(){\n" |
| 8964 | " color = vec4(x);\n" |
| 8965 | "}\n"; |
| 8966 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8967 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8968 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8969 | |
| 8970 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8971 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8972 | pipe.AddShader(&vs); |
| 8973 | pipe.AddShader(&fs); |
| 8974 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8975 | VkDescriptorSetObj descriptorSet(m_device); |
| 8976 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8977 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8978 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8979 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8980 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8981 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8982 | } |
| 8983 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8984 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8985 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8986 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8987 | |
| 8988 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8989 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8990 | |
| 8991 | char const *vsSource = |
| 8992 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8993 | "\n" |
| 8994 | "out block { layout(location=0) int x; } outs;\n" |
| 8995 | "out gl_PerVertex {\n" |
| 8996 | " vec4 gl_Position;\n" |
| 8997 | "};\n" |
| 8998 | "void main(){\n" |
| 8999 | " outs.x = 0;\n" |
| 9000 | " gl_Position = vec4(1);\n" |
| 9001 | "}\n"; |
| 9002 | char const *fsSource = |
| 9003 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9004 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9005 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9006 | "layout(location=0) out vec4 color;\n" |
| 9007 | "void main(){\n" |
| 9008 | " color = vec4(ins.x);\n" |
| 9009 | "}\n"; |
| 9010 | |
| 9011 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9012 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9013 | |
| 9014 | VkPipelineObj pipe(m_device); |
| 9015 | pipe.AddColorAttachment(); |
| 9016 | pipe.AddShader(&vs); |
| 9017 | pipe.AddShader(&fs); |
| 9018 | |
| 9019 | VkDescriptorSetObj descriptorSet(m_device); |
| 9020 | descriptorSet.AppendDummy(); |
| 9021 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9022 | |
| 9023 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9024 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9025 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9026 | } |
| 9027 | |
| 9028 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 9029 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9030 | "location 0.0 which is not written by vertex shader"); |
| 9031 | |
| 9032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9033 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9034 | |
| 9035 | char const *vsSource = |
| 9036 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9037 | "\n" |
| 9038 | "out block { layout(location=1) float x; } outs;\n" |
| 9039 | "out gl_PerVertex {\n" |
| 9040 | " vec4 gl_Position;\n" |
| 9041 | "};\n" |
| 9042 | "void main(){\n" |
| 9043 | " outs.x = 0;\n" |
| 9044 | " gl_Position = vec4(1);\n" |
| 9045 | "}\n"; |
| 9046 | char const *fsSource = |
| 9047 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9048 | "\n" |
| 9049 | "in block { layout(location=0) float x; } ins;\n" |
| 9050 | "layout(location=0) out vec4 color;\n" |
| 9051 | "void main(){\n" |
| 9052 | " color = vec4(ins.x);\n" |
| 9053 | "}\n"; |
| 9054 | |
| 9055 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9056 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9057 | |
| 9058 | VkPipelineObj pipe(m_device); |
| 9059 | pipe.AddColorAttachment(); |
| 9060 | pipe.AddShader(&vs); |
| 9061 | pipe.AddShader(&fs); |
| 9062 | |
| 9063 | VkDescriptorSetObj descriptorSet(m_device); |
| 9064 | descriptorSet.AppendDummy(); |
| 9065 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9066 | |
| 9067 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9068 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9069 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9070 | } |
| 9071 | |
| 9072 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 9073 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9074 | "location 0.1 which is not written by vertex shader"); |
| 9075 | |
| 9076 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9077 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9078 | |
| 9079 | char const *vsSource = |
| 9080 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9081 | "\n" |
| 9082 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 9083 | "out gl_PerVertex {\n" |
| 9084 | " vec4 gl_Position;\n" |
| 9085 | "};\n" |
| 9086 | "void main(){\n" |
| 9087 | " outs.x = 0;\n" |
| 9088 | " gl_Position = vec4(1);\n" |
| 9089 | "}\n"; |
| 9090 | char const *fsSource = |
| 9091 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9092 | "\n" |
| 9093 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 9094 | "layout(location=0) out vec4 color;\n" |
| 9095 | "void main(){\n" |
| 9096 | " color = vec4(ins.x);\n" |
| 9097 | "}\n"; |
| 9098 | |
| 9099 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9100 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9101 | |
| 9102 | VkPipelineObj pipe(m_device); |
| 9103 | pipe.AddColorAttachment(); |
| 9104 | pipe.AddShader(&vs); |
| 9105 | pipe.AddShader(&fs); |
| 9106 | |
| 9107 | VkDescriptorSetObj descriptorSet(m_device); |
| 9108 | descriptorSet.AppendDummy(); |
| 9109 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9110 | |
| 9111 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9112 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9113 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9114 | } |
| 9115 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9116 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9117 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9118 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9119 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9121 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9122 | |
| 9123 | VkVertexInputBindingDescription input_binding; |
| 9124 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9125 | |
| 9126 | VkVertexInputAttributeDescription input_attrib; |
| 9127 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9128 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9129 | |
| 9130 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9131 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9132 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9133 | "out gl_PerVertex {\n" |
| 9134 | " vec4 gl_Position;\n" |
| 9135 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9136 | "void main(){\n" |
| 9137 | " gl_Position = vec4(1);\n" |
| 9138 | "}\n"; |
| 9139 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9140 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9141 | "\n" |
| 9142 | "layout(location=0) out vec4 color;\n" |
| 9143 | "void main(){\n" |
| 9144 | " color = vec4(1);\n" |
| 9145 | "}\n"; |
| 9146 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9147 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9148 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9149 | |
| 9150 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9151 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9152 | pipe.AddShader(&vs); |
| 9153 | pipe.AddShader(&fs); |
| 9154 | |
| 9155 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9156 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9157 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9158 | VkDescriptorSetObj descriptorSet(m_device); |
| 9159 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9160 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9161 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9162 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9163 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9164 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9165 | } |
| 9166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9167 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9168 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9169 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9170 | |
| 9171 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9172 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9173 | |
| 9174 | VkVertexInputBindingDescription input_binding; |
| 9175 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9176 | |
| 9177 | VkVertexInputAttributeDescription input_attrib; |
| 9178 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9179 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9180 | |
| 9181 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9182 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9183 | "\n" |
| 9184 | "layout(location=1) in float x;\n" |
| 9185 | "out gl_PerVertex {\n" |
| 9186 | " vec4 gl_Position;\n" |
| 9187 | "};\n" |
| 9188 | "void main(){\n" |
| 9189 | " gl_Position = vec4(x);\n" |
| 9190 | "}\n"; |
| 9191 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9192 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9193 | "\n" |
| 9194 | "layout(location=0) out vec4 color;\n" |
| 9195 | "void main(){\n" |
| 9196 | " color = vec4(1);\n" |
| 9197 | "}\n"; |
| 9198 | |
| 9199 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9200 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9201 | |
| 9202 | VkPipelineObj pipe(m_device); |
| 9203 | pipe.AddColorAttachment(); |
| 9204 | pipe.AddShader(&vs); |
| 9205 | pipe.AddShader(&fs); |
| 9206 | |
| 9207 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9208 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9209 | |
| 9210 | VkDescriptorSetObj descriptorSet(m_device); |
| 9211 | descriptorSet.AppendDummy(); |
| 9212 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9213 | |
| 9214 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9215 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9216 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9217 | } |
| 9218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9219 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 9220 | m_errorMonitor->SetDesiredFailureMsg( |
| 9221 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9222 | "VS consumes input at location 0 but not provided"); |
| 9223 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9224 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9225 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9226 | |
| 9227 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9228 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9229 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9230 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9231 | "out gl_PerVertex {\n" |
| 9232 | " vec4 gl_Position;\n" |
| 9233 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9234 | "void main(){\n" |
| 9235 | " gl_Position = x;\n" |
| 9236 | "}\n"; |
| 9237 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9238 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9239 | "\n" |
| 9240 | "layout(location=0) out vec4 color;\n" |
| 9241 | "void main(){\n" |
| 9242 | " color = vec4(1);\n" |
| 9243 | "}\n"; |
| 9244 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9245 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9246 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9247 | |
| 9248 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9249 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9250 | pipe.AddShader(&vs); |
| 9251 | pipe.AddShader(&fs); |
| 9252 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9253 | VkDescriptorSetObj descriptorSet(m_device); |
| 9254 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9255 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9256 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9257 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9258 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9259 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9260 | } |
| 9261 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9262 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9263 | m_errorMonitor->SetDesiredFailureMsg( |
| 9264 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9265 | "location 0 does not match VS input type"); |
| 9266 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9267 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9268 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9269 | |
| 9270 | VkVertexInputBindingDescription input_binding; |
| 9271 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9272 | |
| 9273 | VkVertexInputAttributeDescription input_attrib; |
| 9274 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9275 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9276 | |
| 9277 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9278 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9279 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9280 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9281 | "out gl_PerVertex {\n" |
| 9282 | " vec4 gl_Position;\n" |
| 9283 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9284 | "void main(){\n" |
| 9285 | " gl_Position = vec4(x);\n" |
| 9286 | "}\n"; |
| 9287 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9288 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9289 | "\n" |
| 9290 | "layout(location=0) out vec4 color;\n" |
| 9291 | "void main(){\n" |
| 9292 | " color = vec4(1);\n" |
| 9293 | "}\n"; |
| 9294 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9295 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9296 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9297 | |
| 9298 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9299 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9300 | pipe.AddShader(&vs); |
| 9301 | pipe.AddShader(&fs); |
| 9302 | |
| 9303 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9304 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9305 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9306 | VkDescriptorSetObj descriptorSet(m_device); |
| 9307 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9308 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9309 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9310 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9311 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9312 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9313 | } |
| 9314 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9315 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9316 | m_errorMonitor->SetDesiredFailureMsg( |
| 9317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9318 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9319 | |
| 9320 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9321 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9322 | |
| 9323 | char const *vsSource = |
| 9324 | "#version 450\n" |
| 9325 | "\n" |
| 9326 | "out gl_PerVertex {\n" |
| 9327 | " vec4 gl_Position;\n" |
| 9328 | "};\n" |
| 9329 | "void main(){\n" |
| 9330 | " gl_Position = vec4(1);\n" |
| 9331 | "}\n"; |
| 9332 | char const *fsSource = |
| 9333 | "#version 450\n" |
| 9334 | "\n" |
| 9335 | "layout(location=0) out vec4 color;\n" |
| 9336 | "void main(){\n" |
| 9337 | " color = vec4(1);\n" |
| 9338 | "}\n"; |
| 9339 | |
| 9340 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9341 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9342 | |
| 9343 | VkPipelineObj pipe(m_device); |
| 9344 | pipe.AddColorAttachment(); |
| 9345 | pipe.AddShader(&vs); |
| 9346 | pipe.AddShader(&vs); |
| 9347 | pipe.AddShader(&fs); |
| 9348 | |
| 9349 | VkDescriptorSetObj descriptorSet(m_device); |
| 9350 | descriptorSet.AppendDummy(); |
| 9351 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9352 | |
| 9353 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9354 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9355 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9356 | } |
| 9357 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9358 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9359 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9360 | |
| 9361 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9362 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9363 | |
| 9364 | VkVertexInputBindingDescription input_binding; |
| 9365 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9366 | |
| 9367 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9368 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9369 | |
| 9370 | for (int i = 0; i < 2; i++) { |
| 9371 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9372 | input_attribs[i].location = i; |
| 9373 | } |
| 9374 | |
| 9375 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9376 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9377 | "\n" |
| 9378 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9379 | "out gl_PerVertex {\n" |
| 9380 | " vec4 gl_Position;\n" |
| 9381 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9382 | "void main(){\n" |
| 9383 | " gl_Position = x[0] + x[1];\n" |
| 9384 | "}\n"; |
| 9385 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9386 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9387 | "\n" |
| 9388 | "layout(location=0) out vec4 color;\n" |
| 9389 | "void main(){\n" |
| 9390 | " color = vec4(1);\n" |
| 9391 | "}\n"; |
| 9392 | |
| 9393 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9394 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9395 | |
| 9396 | VkPipelineObj pipe(m_device); |
| 9397 | pipe.AddColorAttachment(); |
| 9398 | pipe.AddShader(&vs); |
| 9399 | pipe.AddShader(&fs); |
| 9400 | |
| 9401 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9402 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9403 | |
| 9404 | VkDescriptorSetObj descriptorSet(m_device); |
| 9405 | descriptorSet.AppendDummy(); |
| 9406 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9407 | |
| 9408 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9409 | |
| 9410 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9411 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9412 | } |
| 9413 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9414 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9415 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9416 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9417 | |
| 9418 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9419 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9420 | |
| 9421 | VkVertexInputBindingDescription input_binding; |
| 9422 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9423 | |
| 9424 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9425 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9426 | |
| 9427 | for (int i = 0; i < 2; i++) { |
| 9428 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9429 | input_attribs[i].location = i; |
| 9430 | } |
| 9431 | |
| 9432 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9433 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9434 | "\n" |
| 9435 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9436 | "out gl_PerVertex {\n" |
| 9437 | " vec4 gl_Position;\n" |
| 9438 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9439 | "void main(){\n" |
| 9440 | " gl_Position = x[0] + x[1];\n" |
| 9441 | "}\n"; |
| 9442 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9443 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9444 | "\n" |
| 9445 | "layout(location=0) out vec4 color;\n" |
| 9446 | "void main(){\n" |
| 9447 | " color = vec4(1);\n" |
| 9448 | "}\n"; |
| 9449 | |
| 9450 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9451 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9452 | |
| 9453 | VkPipelineObj pipe(m_device); |
| 9454 | pipe.AddColorAttachment(); |
| 9455 | pipe.AddShader(&vs); |
| 9456 | pipe.AddShader(&fs); |
| 9457 | |
| 9458 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9459 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9460 | |
| 9461 | VkDescriptorSetObj descriptorSet(m_device); |
| 9462 | descriptorSet.AppendDummy(); |
| 9463 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9464 | |
| 9465 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9466 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9467 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9468 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9469 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9470 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9471 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9472 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9473 | |
| 9474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9475 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9476 | |
| 9477 | char const *vsSource = |
| 9478 | "#version 450\n" |
| 9479 | "out gl_PerVertex {\n" |
| 9480 | " vec4 gl_Position;\n" |
| 9481 | "};\n" |
| 9482 | "void main(){\n" |
| 9483 | " gl_Position = vec4(0);\n" |
| 9484 | "}\n"; |
| 9485 | char const *fsSource = |
| 9486 | "#version 450\n" |
| 9487 | "\n" |
| 9488 | "layout(location=0) out vec4 color;\n" |
| 9489 | "void main(){\n" |
| 9490 | " color = vec4(1);\n" |
| 9491 | "}\n"; |
| 9492 | |
| 9493 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9494 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9495 | |
| 9496 | VkPipelineObj pipe(m_device); |
| 9497 | pipe.AddColorAttachment(); |
| 9498 | pipe.AddShader(&vs); |
| 9499 | pipe.AddShader(&fs); |
| 9500 | |
| 9501 | VkDescriptorSetObj descriptorSet(m_device); |
| 9502 | descriptorSet.AppendDummy(); |
| 9503 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9504 | |
| 9505 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9506 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9507 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9508 | } |
| 9509 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9510 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9511 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9512 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9513 | |
| 9514 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9515 | |
| 9516 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9517 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9518 | |
| 9519 | char const *vsSource = |
| 9520 | "#version 450\n" |
| 9521 | "out gl_PerVertex {\n" |
| 9522 | " vec4 gl_Position;\n" |
| 9523 | "};\n" |
| 9524 | "layout(location=0) out vec3 x;\n" |
| 9525 | "layout(location=1) out ivec3 y;\n" |
| 9526 | "layout(location=2) out vec3 z;\n" |
| 9527 | "void main(){\n" |
| 9528 | " gl_Position = vec4(0);\n" |
| 9529 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9530 | "}\n"; |
| 9531 | char const *fsSource = |
| 9532 | "#version 450\n" |
| 9533 | "\n" |
| 9534 | "layout(location=0) out vec4 color;\n" |
| 9535 | "layout(location=0) in float x;\n" |
| 9536 | "layout(location=1) flat in int y;\n" |
| 9537 | "layout(location=2) in vec2 z;\n" |
| 9538 | "void main(){\n" |
| 9539 | " color = vec4(1 + x + y + z.x);\n" |
| 9540 | "}\n"; |
| 9541 | |
| 9542 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9543 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9544 | |
| 9545 | VkPipelineObj pipe(m_device); |
| 9546 | pipe.AddColorAttachment(); |
| 9547 | pipe.AddShader(&vs); |
| 9548 | pipe.AddShader(&fs); |
| 9549 | |
| 9550 | VkDescriptorSetObj descriptorSet(m_device); |
| 9551 | descriptorSet.AppendDummy(); |
| 9552 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9553 | |
| 9554 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9555 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9556 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9557 | } |
| 9558 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9559 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9560 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9561 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9562 | |
| 9563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9564 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9565 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9566 | if (!m_device->phy().features().tessellationShader) { |
| 9567 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9568 | return; |
| 9569 | } |
| 9570 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9571 | char const *vsSource = |
| 9572 | "#version 450\n" |
| 9573 | "void main(){}\n"; |
| 9574 | char const *tcsSource = |
| 9575 | "#version 450\n" |
| 9576 | "layout(location=0) out int x[];\n" |
| 9577 | "layout(vertices=3) out;\n" |
| 9578 | "void main(){\n" |
| 9579 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9580 | " gl_TessLevelInner[0] = 1;\n" |
| 9581 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9582 | "}\n"; |
| 9583 | char const *tesSource = |
| 9584 | "#version 450\n" |
| 9585 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9586 | "layout(location=0) in int x[];\n" |
| 9587 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9588 | "void main(){\n" |
| 9589 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9590 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9591 | "}\n"; |
| 9592 | char const *fsSource = |
| 9593 | "#version 450\n" |
| 9594 | "layout(location=0) out vec4 color;\n" |
| 9595 | "void main(){\n" |
| 9596 | " color = vec4(1);\n" |
| 9597 | "}\n"; |
| 9598 | |
| 9599 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9600 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9601 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9602 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9603 | |
| 9604 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9605 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9606 | nullptr, |
| 9607 | 0, |
| 9608 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9609 | VK_FALSE}; |
| 9610 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9611 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9612 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9613 | nullptr, |
| 9614 | 0, |
| 9615 | 3}; |
| 9616 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9617 | VkPipelineObj pipe(m_device); |
| 9618 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9619 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9620 | pipe.AddColorAttachment(); |
| 9621 | pipe.AddShader(&vs); |
| 9622 | pipe.AddShader(&tcs); |
| 9623 | pipe.AddShader(&tes); |
| 9624 | pipe.AddShader(&fs); |
| 9625 | |
| 9626 | VkDescriptorSetObj descriptorSet(m_device); |
| 9627 | descriptorSet.AppendDummy(); |
| 9628 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9629 | |
| 9630 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9631 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9632 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9633 | } |
| 9634 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9635 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9636 | { |
| 9637 | m_errorMonitor->ExpectSuccess(); |
| 9638 | |
| 9639 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9640 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9641 | |
| 9642 | if (!m_device->phy().features().geometryShader) { |
| 9643 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9644 | return; |
| 9645 | } |
| 9646 | |
| 9647 | char const *vsSource = |
| 9648 | "#version 450\n" |
| 9649 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9650 | "void main(){\n" |
| 9651 | " vs_out.x = vec4(1);\n" |
| 9652 | "}\n"; |
| 9653 | char const *gsSource = |
| 9654 | "#version 450\n" |
| 9655 | "layout(triangles) in;\n" |
| 9656 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9657 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9658 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9659 | "void main() {\n" |
| 9660 | " gl_Position = gs_in[0].x;\n" |
| 9661 | " EmitVertex();\n" |
| 9662 | "}\n"; |
| 9663 | char const *fsSource = |
| 9664 | "#version 450\n" |
| 9665 | "layout(location=0) out vec4 color;\n" |
| 9666 | "void main(){\n" |
| 9667 | " color = vec4(1);\n" |
| 9668 | "}\n"; |
| 9669 | |
| 9670 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9671 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9672 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9673 | |
| 9674 | VkPipelineObj pipe(m_device); |
| 9675 | pipe.AddColorAttachment(); |
| 9676 | pipe.AddShader(&vs); |
| 9677 | pipe.AddShader(&gs); |
| 9678 | pipe.AddShader(&fs); |
| 9679 | |
| 9680 | VkDescriptorSetObj descriptorSet(m_device); |
| 9681 | descriptorSet.AppendDummy(); |
| 9682 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9683 | |
| 9684 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9685 | |
| 9686 | m_errorMonitor->VerifyNotFound(); |
| 9687 | } |
| 9688 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9689 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9690 | { |
| 9691 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9692 | "is per-vertex in tessellation control shader stage " |
| 9693 | "but per-patch in tessellation evaluation shader stage"); |
| 9694 | |
| 9695 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9696 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9697 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9698 | if (!m_device->phy().features().tessellationShader) { |
| 9699 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9700 | return; |
| 9701 | } |
| 9702 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9703 | char const *vsSource = |
| 9704 | "#version 450\n" |
| 9705 | "void main(){}\n"; |
| 9706 | char const *tcsSource = |
| 9707 | "#version 450\n" |
| 9708 | "layout(location=0) out int x[];\n" |
| 9709 | "layout(vertices=3) out;\n" |
| 9710 | "void main(){\n" |
| 9711 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9712 | " gl_TessLevelInner[0] = 1;\n" |
| 9713 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9714 | "}\n"; |
| 9715 | char const *tesSource = |
| 9716 | "#version 450\n" |
| 9717 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9718 | "layout(location=0) patch in int x;\n" |
| 9719 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9720 | "void main(){\n" |
| 9721 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9722 | " gl_Position.w = x;\n" |
| 9723 | "}\n"; |
| 9724 | char const *fsSource = |
| 9725 | "#version 450\n" |
| 9726 | "layout(location=0) out vec4 color;\n" |
| 9727 | "void main(){\n" |
| 9728 | " color = vec4(1);\n" |
| 9729 | "}\n"; |
| 9730 | |
| 9731 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9732 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9733 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9734 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9735 | |
| 9736 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9737 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9738 | nullptr, |
| 9739 | 0, |
| 9740 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9741 | VK_FALSE}; |
| 9742 | |
| 9743 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9744 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9745 | nullptr, |
| 9746 | 0, |
| 9747 | 3}; |
| 9748 | |
| 9749 | VkPipelineObj pipe(m_device); |
| 9750 | pipe.SetInputAssembly(&iasci); |
| 9751 | pipe.SetTessellation(&tsci); |
| 9752 | pipe.AddColorAttachment(); |
| 9753 | pipe.AddShader(&vs); |
| 9754 | pipe.AddShader(&tcs); |
| 9755 | pipe.AddShader(&tes); |
| 9756 | pipe.AddShader(&fs); |
| 9757 | |
| 9758 | VkDescriptorSetObj descriptorSet(m_device); |
| 9759 | descriptorSet.AppendDummy(); |
| 9760 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9761 | |
| 9762 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9763 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9764 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9765 | } |
| 9766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9767 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9768 | m_errorMonitor->SetDesiredFailureMsg( |
| 9769 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9770 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9771 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9772 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9773 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9774 | |
| 9775 | /* Two binding descriptions for binding 0 */ |
| 9776 | VkVertexInputBindingDescription input_bindings[2]; |
| 9777 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9778 | |
| 9779 | VkVertexInputAttributeDescription input_attrib; |
| 9780 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9781 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9782 | |
| 9783 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9784 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9785 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9786 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9787 | "out gl_PerVertex {\n" |
| 9788 | " vec4 gl_Position;\n" |
| 9789 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9790 | "void main(){\n" |
| 9791 | " gl_Position = vec4(x);\n" |
| 9792 | "}\n"; |
| 9793 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9794 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9795 | "\n" |
| 9796 | "layout(location=0) out vec4 color;\n" |
| 9797 | "void main(){\n" |
| 9798 | " color = vec4(1);\n" |
| 9799 | "}\n"; |
| 9800 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9801 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9802 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9803 | |
| 9804 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9805 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9806 | pipe.AddShader(&vs); |
| 9807 | pipe.AddShader(&fs); |
| 9808 | |
| 9809 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9810 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9811 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9812 | VkDescriptorSetObj descriptorSet(m_device); |
| 9813 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9814 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9815 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9816 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9817 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9818 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9819 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9820 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9821 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9822 | m_errorMonitor->ExpectSuccess(); |
| 9823 | |
| 9824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9825 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9826 | |
| 9827 | if (!m_device->phy().features().tessellationShader) { |
| 9828 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9829 | return; |
| 9830 | } |
| 9831 | |
| 9832 | VkVertexInputBindingDescription input_bindings[1]; |
| 9833 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9834 | |
| 9835 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9836 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9837 | input_attribs[0].location = 0; |
| 9838 | input_attribs[0].offset = 0; |
| 9839 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9840 | input_attribs[1].location = 2; |
| 9841 | input_attribs[1].offset = 32; |
| 9842 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9843 | input_attribs[2].location = 4; |
| 9844 | input_attribs[2].offset = 64; |
| 9845 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9846 | input_attribs[3].location = 6; |
| 9847 | input_attribs[3].offset = 96; |
| 9848 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9849 | |
| 9850 | char const *vsSource = |
| 9851 | "#version 450\n" |
| 9852 | "\n" |
| 9853 | "layout(location=0) in dmat4 x;\n" |
| 9854 | "out gl_PerVertex {\n" |
| 9855 | " vec4 gl_Position;\n" |
| 9856 | "};\n" |
| 9857 | "void main(){\n" |
| 9858 | " gl_Position = vec4(x[0][0]);\n" |
| 9859 | "}\n"; |
| 9860 | char const *fsSource = |
| 9861 | "#version 450\n" |
| 9862 | "\n" |
| 9863 | "layout(location=0) out vec4 color;\n" |
| 9864 | "void main(){\n" |
| 9865 | " color = vec4(1);\n" |
| 9866 | "}\n"; |
| 9867 | |
| 9868 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9869 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9870 | |
| 9871 | VkPipelineObj pipe(m_device); |
| 9872 | pipe.AddColorAttachment(); |
| 9873 | pipe.AddShader(&vs); |
| 9874 | pipe.AddShader(&fs); |
| 9875 | |
| 9876 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9877 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9878 | |
| 9879 | VkDescriptorSetObj descriptorSet(m_device); |
| 9880 | descriptorSet.AppendDummy(); |
| 9881 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9882 | |
| 9883 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9884 | |
| 9885 | m_errorMonitor->VerifyNotFound(); |
| 9886 | } |
| 9887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9888 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9890 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9891 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9892 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9893 | |
| 9894 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9895 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9896 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9897 | "out gl_PerVertex {\n" |
| 9898 | " vec4 gl_Position;\n" |
| 9899 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9900 | "void main(){\n" |
| 9901 | " gl_Position = vec4(1);\n" |
| 9902 | "}\n"; |
| 9903 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9904 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9905 | "\n" |
| 9906 | "void main(){\n" |
| 9907 | "}\n"; |
| 9908 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9909 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9910 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9911 | |
| 9912 | VkPipelineObj pipe(m_device); |
| 9913 | pipe.AddShader(&vs); |
| 9914 | pipe.AddShader(&fs); |
| 9915 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9916 | /* set up CB 0, not written */ |
| 9917 | pipe.AddColorAttachment(); |
| 9918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9919 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9920 | VkDescriptorSetObj descriptorSet(m_device); |
| 9921 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9922 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9923 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9924 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9925 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9926 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9927 | } |
| 9928 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9929 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9930 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9931 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9932 | "FS writes to output location 1 with no matching attachment"); |
| 9933 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9935 | |
| 9936 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9937 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9938 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9939 | "out gl_PerVertex {\n" |
| 9940 | " vec4 gl_Position;\n" |
| 9941 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9942 | "void main(){\n" |
| 9943 | " gl_Position = vec4(1);\n" |
| 9944 | "}\n"; |
| 9945 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9946 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9947 | "\n" |
| 9948 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9949 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9950 | "void main(){\n" |
| 9951 | " x = vec4(1);\n" |
| 9952 | " y = vec4(1);\n" |
| 9953 | "}\n"; |
| 9954 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9955 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9956 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9957 | |
| 9958 | VkPipelineObj pipe(m_device); |
| 9959 | pipe.AddShader(&vs); |
| 9960 | pipe.AddShader(&fs); |
| 9961 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9962 | /* set up CB 0, not written */ |
| 9963 | pipe.AddColorAttachment(); |
| 9964 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9965 | /* FS writes CB 1, but we don't configure it */ |
| 9966 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9967 | VkDescriptorSetObj descriptorSet(m_device); |
| 9968 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9969 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9970 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9971 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9972 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9973 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9974 | } |
| 9975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9976 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9977 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9978 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9979 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9980 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9981 | |
| 9982 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9983 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9984 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9985 | "out gl_PerVertex {\n" |
| 9986 | " vec4 gl_Position;\n" |
| 9987 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9988 | "void main(){\n" |
| 9989 | " gl_Position = vec4(1);\n" |
| 9990 | "}\n"; |
| 9991 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9992 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9993 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9994 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9995 | "void main(){\n" |
| 9996 | " x = ivec4(1);\n" |
| 9997 | "}\n"; |
| 9998 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9999 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10000 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10001 | |
| 10002 | VkPipelineObj pipe(m_device); |
| 10003 | pipe.AddShader(&vs); |
| 10004 | pipe.AddShader(&fs); |
| 10005 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10006 | /* set up CB 0; type is UNORM by default */ |
| 10007 | pipe.AddColorAttachment(); |
| 10008 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10009 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10010 | VkDescriptorSetObj descriptorSet(m_device); |
| 10011 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10012 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10013 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10014 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10015 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10016 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10017 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10018 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10019 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10020 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10021 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10022 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10023 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10024 | |
| 10025 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10026 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10027 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10028 | "out gl_PerVertex {\n" |
| 10029 | " vec4 gl_Position;\n" |
| 10030 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10031 | "void main(){\n" |
| 10032 | " gl_Position = vec4(1);\n" |
| 10033 | "}\n"; |
| 10034 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10035 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10036 | "\n" |
| 10037 | "layout(location=0) out vec4 x;\n" |
| 10038 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 10039 | "void main(){\n" |
| 10040 | " x = vec4(bar.y);\n" |
| 10041 | "}\n"; |
| 10042 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10043 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10044 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10045 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10046 | VkPipelineObj pipe(m_device); |
| 10047 | pipe.AddShader(&vs); |
| 10048 | pipe.AddShader(&fs); |
| 10049 | |
| 10050 | /* set up CB 0; type is UNORM by default */ |
| 10051 | pipe.AddColorAttachment(); |
| 10052 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10053 | |
| 10054 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10055 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10056 | |
| 10057 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10058 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10059 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10060 | } |
| 10061 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10062 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 10063 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10064 | "not declared in layout"); |
| 10065 | |
| 10066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10067 | |
| 10068 | char const *vsSource = |
| 10069 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10070 | "\n" |
| 10071 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 10072 | "out gl_PerVertex {\n" |
| 10073 | " vec4 gl_Position;\n" |
| 10074 | "};\n" |
| 10075 | "void main(){\n" |
| 10076 | " gl_Position = vec4(consts.x);\n" |
| 10077 | "}\n"; |
| 10078 | char const *fsSource = |
| 10079 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10080 | "\n" |
| 10081 | "layout(location=0) out vec4 x;\n" |
| 10082 | "void main(){\n" |
| 10083 | " x = vec4(1);\n" |
| 10084 | "}\n"; |
| 10085 | |
| 10086 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 10087 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 10088 | |
| 10089 | VkPipelineObj pipe(m_device); |
| 10090 | pipe.AddShader(&vs); |
| 10091 | pipe.AddShader(&fs); |
| 10092 | |
| 10093 | /* set up CB 0; type is UNORM by default */ |
| 10094 | pipe.AddColorAttachment(); |
| 10095 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10096 | |
| 10097 | VkDescriptorSetObj descriptorSet(m_device); |
| 10098 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10099 | |
| 10100 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 10101 | |
| 10102 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10103 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10104 | } |
| 10105 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10106 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 10107 | m_errorMonitor->SetDesiredFailureMsg( |
| 10108 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10109 | "Shader uses descriptor slot 0.0"); |
| 10110 | |
| 10111 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10112 | |
| 10113 | char const *csSource = |
| 10114 | "#version 450\n" |
| 10115 | "\n" |
| 10116 | "layout(local_size_x=1) in;\n" |
| 10117 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10118 | "void main(){\n" |
| 10119 | " x = vec4(1);\n" |
| 10120 | "}\n"; |
| 10121 | |
| 10122 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10123 | |
| 10124 | VkDescriptorSetObj descriptorSet(m_device); |
| 10125 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10126 | |
| 10127 | VkComputePipelineCreateInfo cpci = { |
| 10128 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10129 | nullptr, 0, { |
| 10130 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10131 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10132 | cs.handle(), "main", nullptr |
| 10133 | }, |
| 10134 | descriptorSet.GetPipelineLayout(), |
| 10135 | VK_NULL_HANDLE, -1 |
| 10136 | }; |
| 10137 | |
| 10138 | VkPipeline pipe; |
| 10139 | VkResult err = vkCreateComputePipelines( |
| 10140 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10141 | |
| 10142 | m_errorMonitor->VerifyFound(); |
| 10143 | |
| 10144 | if (err == VK_SUCCESS) { |
| 10145 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10146 | } |
| 10147 | } |
| 10148 | |
| 10149 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 10150 | m_errorMonitor->ExpectSuccess(); |
| 10151 | |
| 10152 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10153 | |
| 10154 | char const *csSource = |
| 10155 | "#version 450\n" |
| 10156 | "\n" |
| 10157 | "layout(local_size_x=1) in;\n" |
| 10158 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 10159 | "void main(){\n" |
| 10160 | " // x is not used.\n" |
| 10161 | "}\n"; |
| 10162 | |
| 10163 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 10164 | |
| 10165 | VkDescriptorSetObj descriptorSet(m_device); |
| 10166 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 10167 | |
| 10168 | VkComputePipelineCreateInfo cpci = { |
| 10169 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 10170 | nullptr, 0, { |
| 10171 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 10172 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 10173 | cs.handle(), "main", nullptr |
| 10174 | }, |
| 10175 | descriptorSet.GetPipelineLayout(), |
| 10176 | VK_NULL_HANDLE, -1 |
| 10177 | }; |
| 10178 | |
| 10179 | VkPipeline pipe; |
| 10180 | VkResult err = vkCreateComputePipelines( |
| 10181 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 10182 | |
| 10183 | m_errorMonitor->VerifyNotFound(); |
| 10184 | |
| 10185 | if (err == VK_SUCCESS) { |
| 10186 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 10187 | } |
| 10188 | } |
| 10189 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10190 | #endif // SHADER_CHECKER_TESTS |
| 10191 | |
| 10192 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10193 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10194 | m_errorMonitor->SetDesiredFailureMsg( |
| 10195 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10196 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10197 | |
| 10198 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10199 | |
| 10200 | // Create an image |
| 10201 | VkImage image; |
| 10202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10203 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10204 | const int32_t tex_width = 32; |
| 10205 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10206 | |
| 10207 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10208 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10209 | image_create_info.pNext = NULL; |
| 10210 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10211 | image_create_info.format = tex_format; |
| 10212 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10213 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10214 | image_create_info.extent.depth = 1; |
| 10215 | image_create_info.mipLevels = 1; |
| 10216 | image_create_info.arrayLayers = 1; |
| 10217 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10218 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10219 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10220 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10221 | |
| 10222 | // Introduce error by sending down a bogus width extent |
| 10223 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10224 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10225 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10226 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10227 | } |
| 10228 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10229 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 10230 | m_errorMonitor->SetDesiredFailureMsg( |
| 10231 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10232 | "CreateImage extents is 0 for at least one required dimension"); |
| 10233 | |
| 10234 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10235 | |
| 10236 | // Create an image |
| 10237 | VkImage image; |
| 10238 | |
| 10239 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10240 | const int32_t tex_width = 32; |
| 10241 | const int32_t tex_height = 32; |
| 10242 | |
| 10243 | VkImageCreateInfo image_create_info = {}; |
| 10244 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10245 | image_create_info.pNext = NULL; |
| 10246 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10247 | image_create_info.format = tex_format; |
| 10248 | image_create_info.extent.width = tex_width; |
| 10249 | image_create_info.extent.height = tex_height; |
| 10250 | image_create_info.extent.depth = 1; |
| 10251 | image_create_info.mipLevels = 1; |
| 10252 | image_create_info.arrayLayers = 1; |
| 10253 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10254 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10255 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10256 | image_create_info.flags = 0; |
| 10257 | |
| 10258 | // Introduce error by sending down a bogus width extent |
| 10259 | image_create_info.extent.width = 0; |
| 10260 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10261 | |
| 10262 | m_errorMonitor->VerifyFound(); |
| 10263 | } |
| 10264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10265 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 10266 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10267 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10268 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10269 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10270 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10271 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10272 | |
| 10273 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10274 | vk_testing::Buffer buffer; |
| 10275 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10276 | |
| 10277 | BeginCommandBuffer(); |
| 10278 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10279 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10280 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10281 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10282 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10283 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10284 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10285 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10286 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10287 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10288 | EndCommandBuffer(); |
| 10289 | } |
| 10290 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10291 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10292 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10293 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10294 | |
| 10295 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10296 | |
| 10297 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10298 | vk_testing::Buffer buffer; |
| 10299 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10300 | |
| 10301 | BeginCommandBuffer(); |
| 10302 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10303 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10304 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10305 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10306 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10307 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10308 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10309 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10310 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10311 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10312 | m_errorMonitor->VerifyFound(); |
| 10313 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10314 | EndCommandBuffer(); |
| 10315 | } |
| 10316 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10317 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10318 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10319 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10320 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10321 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10322 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10323 | m_errorMonitor->SetDesiredFailureMsg( |
| 10324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10325 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10326 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10327 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10328 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10329 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10330 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10331 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10332 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10333 | const int32_t tex_width = 32; |
| 10334 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10335 | |
| 10336 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10337 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10338 | image_create_info.pNext = NULL; |
| 10339 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10340 | image_create_info.format = tex_format; |
| 10341 | image_create_info.extent.width = tex_width; |
| 10342 | image_create_info.extent.height = tex_height; |
| 10343 | image_create_info.extent.depth = 1; |
| 10344 | image_create_info.mipLevels = 1; |
| 10345 | image_create_info.arrayLayers = 1; |
| 10346 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10347 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10348 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10349 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10350 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10351 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10352 | ASSERT_VK_SUCCESS(err); |
| 10353 | |
| 10354 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10355 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10356 | image_view_create_info.image = image; |
| 10357 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10358 | image_view_create_info.format = tex_format; |
| 10359 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10360 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10361 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10362 | image_view_create_info.subresourceRange.aspectMask = |
| 10363 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10364 | |
| 10365 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10366 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10367 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10368 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10369 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10370 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10371 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10372 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10373 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10374 | TEST_DESCRIPTION( |
| 10375 | "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] | 10376 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10377 | "vkCreateImageView: Color image " |
| 10378 | "formats must have ONLY the " |
| 10379 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10380 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10381 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10383 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10384 | VkImageObj image(m_device); |
| 10385 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10386 | VK_IMAGE_TILING_LINEAR, 0); |
| 10387 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10388 | |
| 10389 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10390 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10391 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10392 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10393 | image_view_create_info.format = tex_format; |
| 10394 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10395 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10396 | // Cause an error by setting an invalid image aspect |
| 10397 | image_view_create_info.subresourceRange.aspectMask = |
| 10398 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10399 | |
| 10400 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10401 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10402 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10403 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10404 | } |
| 10405 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10406 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10407 | VkResult err; |
| 10408 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10409 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10410 | m_errorMonitor->SetDesiredFailureMsg( |
| 10411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10412 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10413 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10414 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10415 | |
| 10416 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10417 | VkImage srcImage; |
| 10418 | VkImage dstImage; |
| 10419 | VkDeviceMemory srcMem; |
| 10420 | VkDeviceMemory destMem; |
| 10421 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10422 | |
| 10423 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10424 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10425 | image_create_info.pNext = NULL; |
| 10426 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10427 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10428 | image_create_info.extent.width = 32; |
| 10429 | image_create_info.extent.height = 32; |
| 10430 | image_create_info.extent.depth = 1; |
| 10431 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10432 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10433 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10434 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10435 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10436 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10438 | err = |
| 10439 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10440 | ASSERT_VK_SUCCESS(err); |
| 10441 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10442 | err = |
| 10443 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10444 | ASSERT_VK_SUCCESS(err); |
| 10445 | |
| 10446 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10447 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10448 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10449 | memAlloc.pNext = NULL; |
| 10450 | memAlloc.allocationSize = 0; |
| 10451 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10452 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10453 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10454 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10455 | pass = |
| 10456 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10457 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10458 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10459 | ASSERT_VK_SUCCESS(err); |
| 10460 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10461 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10462 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10463 | pass = |
| 10464 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10465 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10466 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10467 | ASSERT_VK_SUCCESS(err); |
| 10468 | |
| 10469 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10470 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10471 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10472 | ASSERT_VK_SUCCESS(err); |
| 10473 | |
| 10474 | BeginCommandBuffer(); |
| 10475 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10476 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10477 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10478 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10479 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10480 | copyRegion.srcOffset.x = 0; |
| 10481 | copyRegion.srcOffset.y = 0; |
| 10482 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10483 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10484 | copyRegion.dstSubresource.mipLevel = 0; |
| 10485 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10486 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10487 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10488 | copyRegion.dstOffset.x = 0; |
| 10489 | copyRegion.dstOffset.y = 0; |
| 10490 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10491 | copyRegion.extent.width = 1; |
| 10492 | copyRegion.extent.height = 1; |
| 10493 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10494 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10495 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10496 | EndCommandBuffer(); |
| 10497 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10498 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10499 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10500 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10501 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10502 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10503 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10504 | } |
| 10505 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10506 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10507 | |
| 10508 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10509 | |
| 10510 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10511 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10512 | VkImageObj image(m_device); |
| 10513 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10514 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10515 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10516 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10517 | ASSERT_TRUE(image.initialized()); |
| 10518 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10519 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10520 | VkImageCreateInfo image_create_info; |
| 10521 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10522 | image_create_info.pNext = NULL; |
| 10523 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10524 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10525 | image_create_info.extent.width = 32; |
| 10526 | image_create_info.extent.height = 32; |
| 10527 | image_create_info.extent.depth = 1; |
| 10528 | image_create_info.mipLevels = 1; |
| 10529 | image_create_info.arrayLayers = 1; |
| 10530 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10531 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10532 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10533 | image_create_info.flags = 0; |
| 10534 | |
| 10535 | m_errorMonitor->SetDesiredFailureMsg( |
| 10536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10537 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10538 | |
| 10539 | VkImage localImage; |
| 10540 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10541 | m_errorMonitor->VerifyFound(); |
| 10542 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10543 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10544 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10545 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10546 | VkFormat format = static_cast<VkFormat>(f); |
| 10547 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10548 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10549 | fProps.optimalTilingFeatures == 0) { |
| 10550 | unsupported = format; |
| 10551 | break; |
| 10552 | } |
| 10553 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10554 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10555 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10556 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10557 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10558 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10559 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10560 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10561 | m_errorMonitor->VerifyFound(); |
| 10562 | } |
| 10563 | } |
| 10564 | |
| 10565 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10566 | VkResult ret; |
| 10567 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10568 | |
| 10569 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10570 | |
| 10571 | VkImageObj image(m_device); |
| 10572 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10573 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10574 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10575 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10576 | ASSERT_TRUE(image.initialized()); |
| 10577 | |
| 10578 | VkImageView imgView; |
| 10579 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10580 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10581 | imgViewInfo.image = image.handle(); |
| 10582 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10583 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10584 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10585 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10586 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10587 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10588 | |
| 10589 | m_errorMonitor->SetDesiredFailureMsg( |
| 10590 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10591 | "vkCreateImageView called with baseMipLevel"); |
| 10592 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10593 | // VIEW_CREATE_ERROR |
| 10594 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10595 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10596 | m_errorMonitor->VerifyFound(); |
| 10597 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10598 | |
| 10599 | m_errorMonitor->SetDesiredFailureMsg( |
| 10600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10601 | "vkCreateImageView called with baseArrayLayer"); |
| 10602 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10603 | // VIEW_CREATE_ERROR |
| 10604 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10605 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10606 | m_errorMonitor->VerifyFound(); |
| 10607 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10608 | |
| 10609 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10610 | "vkCreateImageView called with 0 in " |
| 10611 | "pCreateInfo->subresourceRange." |
| 10612 | "levelCount"); |
| 10613 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10614 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10615 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10616 | m_errorMonitor->VerifyFound(); |
| 10617 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10618 | |
| 10619 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10620 | "vkCreateImageView called with 0 in " |
| 10621 | "pCreateInfo->subresourceRange." |
| 10622 | "layerCount"); |
| 10623 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10624 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10625 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10626 | m_errorMonitor->VerifyFound(); |
| 10627 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10628 | |
| 10629 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10630 | "but both must be color formats"); |
| 10631 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10632 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10633 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10634 | m_errorMonitor->VerifyFound(); |
| 10635 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10636 | |
| 10637 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10638 | "Formats MUST be IDENTICAL unless " |
| 10639 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10640 | "was set on image creation."); |
| 10641 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10642 | // VIEW_CREATE_ERROR |
| 10643 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10644 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10645 | m_errorMonitor->VerifyFound(); |
| 10646 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10647 | |
| 10648 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10649 | "can support ImageViews with " |
| 10650 | "differing formats but they must be " |
| 10651 | "in the same compatibility class."); |
| 10652 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10653 | // VIEW_CREATE_ERROR |
| 10654 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10655 | VkImage mutImage; |
| 10656 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10657 | assert( |
| 10658 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10659 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10660 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10661 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10662 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10663 | ASSERT_VK_SUCCESS(ret); |
| 10664 | imgViewInfo.image = mutImage; |
| 10665 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10666 | m_errorMonitor->VerifyFound(); |
| 10667 | imgViewInfo.image = image.handle(); |
| 10668 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10669 | } |
| 10670 | |
| 10671 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10672 | |
| 10673 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10674 | |
| 10675 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10676 | |
| 10677 | VkImageObj image(m_device); |
| 10678 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10679 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10680 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10681 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10682 | ASSERT_TRUE(image.initialized()); |
| 10683 | |
| 10684 | m_errorMonitor->SetDesiredFailureMsg( |
| 10685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10686 | "number of layers in image subresource is zero"); |
| 10687 | vk_testing::Buffer buffer; |
| 10688 | VkMemoryPropertyFlags reqs = 0; |
| 10689 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10690 | VkBufferImageCopy region = {}; |
| 10691 | region.bufferRowLength = 128; |
| 10692 | region.bufferImageHeight = 128; |
| 10693 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10694 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10695 | region.imageSubresource.layerCount = 0; |
| 10696 | region.imageExtent.height = 4; |
| 10697 | region.imageExtent.width = 4; |
| 10698 | region.imageExtent.depth = 1; |
| 10699 | m_commandBuffer->BeginCommandBuffer(); |
| 10700 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10701 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10702 | 1, ®ion); |
| 10703 | m_errorMonitor->VerifyFound(); |
| 10704 | region.imageSubresource.layerCount = 1; |
| 10705 | |
| 10706 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10707 | "aspectMasks for each region must " |
| 10708 | "specify only COLOR or DEPTH or " |
| 10709 | "STENCIL"); |
| 10710 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10711 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10712 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10713 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10714 | 1, ®ion); |
| 10715 | m_errorMonitor->VerifyFound(); |
| 10716 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10717 | |
| 10718 | m_errorMonitor->SetDesiredFailureMsg( |
| 10719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10720 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10721 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10722 | // Expect INVALID_FILTER |
| 10723 | VkImageObj intImage1(m_device); |
| 10724 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10725 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10726 | 0); |
| 10727 | VkImageObj intImage2(m_device); |
| 10728 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10729 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10730 | 0); |
| 10731 | VkImageBlit blitRegion = {}; |
| 10732 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10733 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10734 | blitRegion.srcSubresource.layerCount = 1; |
| 10735 | blitRegion.srcSubresource.mipLevel = 0; |
| 10736 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10737 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10738 | blitRegion.dstSubresource.layerCount = 1; |
| 10739 | blitRegion.dstSubresource.mipLevel = 0; |
| 10740 | |
| 10741 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10742 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10743 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10744 | m_errorMonitor->VerifyFound(); |
| 10745 | |
| 10746 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10747 | "called with 0 in ppMemoryBarriers"); |
| 10748 | VkImageMemoryBarrier img_barrier; |
| 10749 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10750 | img_barrier.pNext = NULL; |
| 10751 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10752 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10753 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10754 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10755 | img_barrier.image = image.handle(); |
| 10756 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10757 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10758 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10759 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10760 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10761 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10762 | img_barrier.subresourceRange.layerCount = 0; |
| 10763 | img_barrier.subresourceRange.levelCount = 1; |
| 10764 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10765 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10766 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10767 | nullptr, 1, &img_barrier); |
| 10768 | m_errorMonitor->VerifyFound(); |
| 10769 | img_barrier.subresourceRange.layerCount = 1; |
| 10770 | } |
| 10771 | |
| 10772 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10773 | |
| 10774 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10775 | |
| 10776 | m_errorMonitor->SetDesiredFailureMsg( |
| 10777 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10778 | "CreateImage extents exceed allowable limits for format"); |
| 10779 | VkImageCreateInfo image_create_info = {}; |
| 10780 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10781 | image_create_info.pNext = NULL; |
| 10782 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10783 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10784 | image_create_info.extent.width = 32; |
| 10785 | image_create_info.extent.height = 32; |
| 10786 | image_create_info.extent.depth = 1; |
| 10787 | image_create_info.mipLevels = 1; |
| 10788 | image_create_info.arrayLayers = 1; |
| 10789 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10790 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10791 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10792 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10793 | image_create_info.flags = 0; |
| 10794 | |
| 10795 | VkImage nullImg; |
| 10796 | VkImageFormatProperties imgFmtProps; |
| 10797 | vkGetPhysicalDeviceImageFormatProperties( |
| 10798 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10799 | image_create_info.tiling, image_create_info.usage, |
| 10800 | image_create_info.flags, &imgFmtProps); |
| 10801 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10802 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10803 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10804 | m_errorMonitor->VerifyFound(); |
| 10805 | image_create_info.extent.depth = 1; |
| 10806 | |
| 10807 | m_errorMonitor->SetDesiredFailureMsg( |
| 10808 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10809 | "exceeds allowable maximum supported by format of"); |
| 10810 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10811 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10812 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10813 | m_errorMonitor->VerifyFound(); |
| 10814 | image_create_info.mipLevels = 1; |
| 10815 | |
| 10816 | m_errorMonitor->SetDesiredFailureMsg( |
| 10817 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10818 | "exceeds allowable maximum supported by format of"); |
| 10819 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10820 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10821 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10822 | m_errorMonitor->VerifyFound(); |
| 10823 | image_create_info.arrayLayers = 1; |
| 10824 | |
| 10825 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10826 | "is not supported by format"); |
| 10827 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10828 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10829 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10830 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10831 | m_errorMonitor->VerifyFound(); |
| 10832 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10833 | |
| 10834 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10835 | "pCreateInfo->initialLayout, must be " |
| 10836 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10837 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10838 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10839 | // Expect INVALID_LAYOUT |
| 10840 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10841 | m_errorMonitor->VerifyFound(); |
| 10842 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10843 | } |
| 10844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10845 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10846 | VkResult err; |
| 10847 | bool pass; |
| 10848 | |
| 10849 | // Create color images with different format sizes and try to copy between them |
| 10850 | m_errorMonitor->SetDesiredFailureMsg( |
| 10851 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10852 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10853 | |
| 10854 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10855 | |
| 10856 | // Create two images of different types and try to copy between them |
| 10857 | VkImage srcImage; |
| 10858 | VkImage dstImage; |
| 10859 | VkDeviceMemory srcMem; |
| 10860 | VkDeviceMemory destMem; |
| 10861 | VkMemoryRequirements memReqs; |
| 10862 | |
| 10863 | VkImageCreateInfo image_create_info = {}; |
| 10864 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10865 | image_create_info.pNext = NULL; |
| 10866 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10867 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10868 | image_create_info.extent.width = 32; |
| 10869 | image_create_info.extent.height = 32; |
| 10870 | image_create_info.extent.depth = 1; |
| 10871 | image_create_info.mipLevels = 1; |
| 10872 | image_create_info.arrayLayers = 1; |
| 10873 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10874 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10875 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10876 | image_create_info.flags = 0; |
| 10877 | |
| 10878 | err = |
| 10879 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10880 | ASSERT_VK_SUCCESS(err); |
| 10881 | |
| 10882 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10883 | // Introduce failure by creating second image with a different-sized format. |
| 10884 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10885 | |
| 10886 | err = |
| 10887 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10888 | ASSERT_VK_SUCCESS(err); |
| 10889 | |
| 10890 | // Allocate memory |
| 10891 | VkMemoryAllocateInfo memAlloc = {}; |
| 10892 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10893 | memAlloc.pNext = NULL; |
| 10894 | memAlloc.allocationSize = 0; |
| 10895 | memAlloc.memoryTypeIndex = 0; |
| 10896 | |
| 10897 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10898 | memAlloc.allocationSize = memReqs.size; |
| 10899 | pass = |
| 10900 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10901 | ASSERT_TRUE(pass); |
| 10902 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10903 | ASSERT_VK_SUCCESS(err); |
| 10904 | |
| 10905 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10906 | memAlloc.allocationSize = memReqs.size; |
| 10907 | pass = |
| 10908 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10909 | ASSERT_TRUE(pass); |
| 10910 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10911 | ASSERT_VK_SUCCESS(err); |
| 10912 | |
| 10913 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10914 | ASSERT_VK_SUCCESS(err); |
| 10915 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10916 | ASSERT_VK_SUCCESS(err); |
| 10917 | |
| 10918 | BeginCommandBuffer(); |
| 10919 | VkImageCopy copyRegion; |
| 10920 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10921 | copyRegion.srcSubresource.mipLevel = 0; |
| 10922 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10923 | copyRegion.srcSubresource.layerCount = 0; |
| 10924 | copyRegion.srcOffset.x = 0; |
| 10925 | copyRegion.srcOffset.y = 0; |
| 10926 | copyRegion.srcOffset.z = 0; |
| 10927 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10928 | copyRegion.dstSubresource.mipLevel = 0; |
| 10929 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10930 | copyRegion.dstSubresource.layerCount = 0; |
| 10931 | copyRegion.dstOffset.x = 0; |
| 10932 | copyRegion.dstOffset.y = 0; |
| 10933 | copyRegion.dstOffset.z = 0; |
| 10934 | copyRegion.extent.width = 1; |
| 10935 | copyRegion.extent.height = 1; |
| 10936 | copyRegion.extent.depth = 1; |
| 10937 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10938 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10939 | EndCommandBuffer(); |
| 10940 | |
| 10941 | m_errorMonitor->VerifyFound(); |
| 10942 | |
| 10943 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10944 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10945 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10946 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10947 | } |
| 10948 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10949 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10950 | VkResult err; |
| 10951 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10952 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10953 | // 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] | 10954 | m_errorMonitor->SetDesiredFailureMsg( |
| 10955 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10956 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10957 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10958 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10959 | |
| 10960 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10961 | VkImage srcImage; |
| 10962 | VkImage dstImage; |
| 10963 | VkDeviceMemory srcMem; |
| 10964 | VkDeviceMemory destMem; |
| 10965 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10966 | |
| 10967 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10968 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10969 | image_create_info.pNext = NULL; |
| 10970 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10971 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10972 | image_create_info.extent.width = 32; |
| 10973 | image_create_info.extent.height = 32; |
| 10974 | image_create_info.extent.depth = 1; |
| 10975 | image_create_info.mipLevels = 1; |
| 10976 | image_create_info.arrayLayers = 1; |
| 10977 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10978 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10979 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10980 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10981 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10982 | err = |
| 10983 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10984 | ASSERT_VK_SUCCESS(err); |
| 10985 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10986 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10987 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10988 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10989 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10990 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10991 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10992 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10993 | err = |
| 10994 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10995 | ASSERT_VK_SUCCESS(err); |
| 10996 | |
| 10997 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10998 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10999 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11000 | memAlloc.pNext = NULL; |
| 11001 | memAlloc.allocationSize = 0; |
| 11002 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11003 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11004 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11005 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11006 | pass = |
| 11007 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11008 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11009 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11010 | ASSERT_VK_SUCCESS(err); |
| 11011 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11012 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11013 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11014 | pass = |
| 11015 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11016 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11017 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11018 | ASSERT_VK_SUCCESS(err); |
| 11019 | |
| 11020 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11021 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11022 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11023 | ASSERT_VK_SUCCESS(err); |
| 11024 | |
| 11025 | BeginCommandBuffer(); |
| 11026 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11027 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11028 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11029 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11030 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11031 | copyRegion.srcOffset.x = 0; |
| 11032 | copyRegion.srcOffset.y = 0; |
| 11033 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11034 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11035 | copyRegion.dstSubresource.mipLevel = 0; |
| 11036 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 11037 | copyRegion.dstSubresource.layerCount = 0; |
| 11038 | copyRegion.dstOffset.x = 0; |
| 11039 | copyRegion.dstOffset.y = 0; |
| 11040 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11041 | copyRegion.extent.width = 1; |
| 11042 | copyRegion.extent.height = 1; |
| 11043 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11044 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11045 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11046 | EndCommandBuffer(); |
| 11047 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11048 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11049 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11050 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11051 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11052 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11053 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11054 | } |
| 11055 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11056 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 11057 | VkResult err; |
| 11058 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11059 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11060 | m_errorMonitor->SetDesiredFailureMsg( |
| 11061 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11062 | "vkCmdResolveImage called with source sample count less than 2."); |
| 11063 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11064 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11065 | |
| 11066 | // 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] | 11067 | VkImage srcImage; |
| 11068 | VkImage dstImage; |
| 11069 | VkDeviceMemory srcMem; |
| 11070 | VkDeviceMemory destMem; |
| 11071 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11072 | |
| 11073 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11074 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11075 | image_create_info.pNext = NULL; |
| 11076 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11077 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11078 | image_create_info.extent.width = 32; |
| 11079 | image_create_info.extent.height = 1; |
| 11080 | image_create_info.extent.depth = 1; |
| 11081 | image_create_info.mipLevels = 1; |
| 11082 | image_create_info.arrayLayers = 1; |
| 11083 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11084 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11085 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11086 | image_create_info.flags = 0; |
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, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11090 | ASSERT_VK_SUCCESS(err); |
| 11091 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11092 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11094 | err = |
| 11095 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11096 | ASSERT_VK_SUCCESS(err); |
| 11097 | |
| 11098 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11099 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11100 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11101 | memAlloc.pNext = NULL; |
| 11102 | memAlloc.allocationSize = 0; |
| 11103 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11104 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11105 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11106 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11107 | pass = |
| 11108 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11109 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11110 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11111 | ASSERT_VK_SUCCESS(err); |
| 11112 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11113 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11114 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11115 | pass = |
| 11116 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11117 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11118 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11119 | ASSERT_VK_SUCCESS(err); |
| 11120 | |
| 11121 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11122 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11123 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11124 | ASSERT_VK_SUCCESS(err); |
| 11125 | |
| 11126 | BeginCommandBuffer(); |
| 11127 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11128 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11129 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11130 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11131 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11132 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11133 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11134 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11135 | resolveRegion.srcOffset.x = 0; |
| 11136 | resolveRegion.srcOffset.y = 0; |
| 11137 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11138 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11139 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11140 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11141 | resolveRegion.dstSubresource.layerCount = 0; |
| 11142 | resolveRegion.dstOffset.x = 0; |
| 11143 | resolveRegion.dstOffset.y = 0; |
| 11144 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11145 | resolveRegion.extent.width = 1; |
| 11146 | resolveRegion.extent.height = 1; |
| 11147 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11148 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11149 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11150 | EndCommandBuffer(); |
| 11151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11152 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11153 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11154 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11155 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11156 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11157 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11158 | } |
| 11159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11160 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 11161 | VkResult err; |
| 11162 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11164 | m_errorMonitor->SetDesiredFailureMsg( |
| 11165 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11166 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 11167 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11168 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11169 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11170 | // 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] | 11171 | VkImage srcImage; |
| 11172 | VkImage dstImage; |
| 11173 | VkDeviceMemory srcMem; |
| 11174 | VkDeviceMemory destMem; |
| 11175 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11176 | |
| 11177 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11178 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11179 | image_create_info.pNext = NULL; |
| 11180 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11181 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11182 | image_create_info.extent.width = 32; |
| 11183 | image_create_info.extent.height = 1; |
| 11184 | image_create_info.extent.depth = 1; |
| 11185 | image_create_info.mipLevels = 1; |
| 11186 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11187 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11188 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11189 | // Note: Some implementations expect color attachment usage for any |
| 11190 | // multisample surface |
| 11191 | image_create_info.usage = |
| 11192 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11193 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11195 | err = |
| 11196 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11197 | ASSERT_VK_SUCCESS(err); |
| 11198 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11199 | // Note: Some implementations expect color attachment usage for any |
| 11200 | // multisample surface |
| 11201 | image_create_info.usage = |
| 11202 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11203 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11204 | err = |
| 11205 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11206 | ASSERT_VK_SUCCESS(err); |
| 11207 | |
| 11208 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11209 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11210 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11211 | memAlloc.pNext = NULL; |
| 11212 | memAlloc.allocationSize = 0; |
| 11213 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11214 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11215 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11216 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11217 | pass = |
| 11218 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11219 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11220 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11221 | ASSERT_VK_SUCCESS(err); |
| 11222 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11223 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11224 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11225 | pass = |
| 11226 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11227 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11228 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11229 | ASSERT_VK_SUCCESS(err); |
| 11230 | |
| 11231 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11232 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11233 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11234 | ASSERT_VK_SUCCESS(err); |
| 11235 | |
| 11236 | BeginCommandBuffer(); |
| 11237 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11238 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11239 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11240 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11241 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11242 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11243 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11244 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11245 | resolveRegion.srcOffset.x = 0; |
| 11246 | resolveRegion.srcOffset.y = 0; |
| 11247 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11248 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11249 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11250 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11251 | resolveRegion.dstSubresource.layerCount = 0; |
| 11252 | resolveRegion.dstOffset.x = 0; |
| 11253 | resolveRegion.dstOffset.y = 0; |
| 11254 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11255 | resolveRegion.extent.width = 1; |
| 11256 | resolveRegion.extent.height = 1; |
| 11257 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11258 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11259 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11260 | EndCommandBuffer(); |
| 11261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11262 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11263 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11264 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11265 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11266 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11267 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11268 | } |
| 11269 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11270 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11271 | VkResult err; |
| 11272 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11273 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11274 | m_errorMonitor->SetDesiredFailureMsg( |
| 11275 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11276 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11277 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11278 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11279 | |
| 11280 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11281 | VkImage srcImage; |
| 11282 | VkImage dstImage; |
| 11283 | VkDeviceMemory srcMem; |
| 11284 | VkDeviceMemory destMem; |
| 11285 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11286 | |
| 11287 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11288 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11289 | image_create_info.pNext = NULL; |
| 11290 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11291 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11292 | image_create_info.extent.width = 32; |
| 11293 | image_create_info.extent.height = 1; |
| 11294 | image_create_info.extent.depth = 1; |
| 11295 | image_create_info.mipLevels = 1; |
| 11296 | image_create_info.arrayLayers = 1; |
| 11297 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11298 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11299 | // Note: Some implementations expect color attachment usage for any |
| 11300 | // multisample surface |
| 11301 | image_create_info.usage = |
| 11302 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11303 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11304 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11305 | err = |
| 11306 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11307 | ASSERT_VK_SUCCESS(err); |
| 11308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11309 | // Set format to something other than source image |
| 11310 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11311 | // Note: Some implementations expect color attachment usage for any |
| 11312 | // multisample surface |
| 11313 | image_create_info.usage = |
| 11314 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11315 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11317 | err = |
| 11318 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11319 | ASSERT_VK_SUCCESS(err); |
| 11320 | |
| 11321 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11322 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11323 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11324 | memAlloc.pNext = NULL; |
| 11325 | memAlloc.allocationSize = 0; |
| 11326 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11327 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11328 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11329 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11330 | pass = |
| 11331 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11332 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11333 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11334 | ASSERT_VK_SUCCESS(err); |
| 11335 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11336 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11337 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11338 | pass = |
| 11339 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11340 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11341 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11342 | ASSERT_VK_SUCCESS(err); |
| 11343 | |
| 11344 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11345 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11346 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11347 | ASSERT_VK_SUCCESS(err); |
| 11348 | |
| 11349 | BeginCommandBuffer(); |
| 11350 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11351 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11352 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11353 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11354 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11355 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11356 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11357 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11358 | resolveRegion.srcOffset.x = 0; |
| 11359 | resolveRegion.srcOffset.y = 0; |
| 11360 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11361 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11362 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11363 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11364 | resolveRegion.dstSubresource.layerCount = 0; |
| 11365 | resolveRegion.dstOffset.x = 0; |
| 11366 | resolveRegion.dstOffset.y = 0; |
| 11367 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11368 | resolveRegion.extent.width = 1; |
| 11369 | resolveRegion.extent.height = 1; |
| 11370 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11371 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11372 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11373 | EndCommandBuffer(); |
| 11374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11375 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11376 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11377 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11378 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11379 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11380 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11381 | } |
| 11382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11383 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11384 | VkResult err; |
| 11385 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11387 | m_errorMonitor->SetDesiredFailureMsg( |
| 11388 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11389 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11390 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11392 | |
| 11393 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11394 | VkImage srcImage; |
| 11395 | VkImage dstImage; |
| 11396 | VkDeviceMemory srcMem; |
| 11397 | VkDeviceMemory destMem; |
| 11398 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11399 | |
| 11400 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11401 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11402 | image_create_info.pNext = NULL; |
| 11403 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11404 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11405 | image_create_info.extent.width = 32; |
| 11406 | image_create_info.extent.height = 1; |
| 11407 | image_create_info.extent.depth = 1; |
| 11408 | image_create_info.mipLevels = 1; |
| 11409 | image_create_info.arrayLayers = 1; |
| 11410 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11411 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11412 | // Note: Some implementations expect color attachment usage for any |
| 11413 | // multisample surface |
| 11414 | image_create_info.usage = |
| 11415 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11416 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11418 | err = |
| 11419 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11420 | ASSERT_VK_SUCCESS(err); |
| 11421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11422 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11423 | // Note: Some implementations expect color attachment usage for any |
| 11424 | // multisample surface |
| 11425 | image_create_info.usage = |
| 11426 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11427 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11429 | err = |
| 11430 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11431 | ASSERT_VK_SUCCESS(err); |
| 11432 | |
| 11433 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11434 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11435 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11436 | memAlloc.pNext = NULL; |
| 11437 | memAlloc.allocationSize = 0; |
| 11438 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11439 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11440 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11441 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11442 | pass = |
| 11443 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11444 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11445 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11446 | ASSERT_VK_SUCCESS(err); |
| 11447 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11448 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11449 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11450 | pass = |
| 11451 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11452 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11453 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11454 | ASSERT_VK_SUCCESS(err); |
| 11455 | |
| 11456 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11457 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11458 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11459 | ASSERT_VK_SUCCESS(err); |
| 11460 | |
| 11461 | BeginCommandBuffer(); |
| 11462 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11463 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11464 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11465 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11466 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11467 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11468 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11469 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11470 | resolveRegion.srcOffset.x = 0; |
| 11471 | resolveRegion.srcOffset.y = 0; |
| 11472 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11473 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11474 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11475 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11476 | resolveRegion.dstSubresource.layerCount = 0; |
| 11477 | resolveRegion.dstOffset.x = 0; |
| 11478 | resolveRegion.dstOffset.y = 0; |
| 11479 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11480 | resolveRegion.extent.width = 1; |
| 11481 | resolveRegion.extent.height = 1; |
| 11482 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11483 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11484 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11485 | EndCommandBuffer(); |
| 11486 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11487 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11488 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11489 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11490 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11491 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11492 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11493 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11494 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11495 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11496 | // 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] | 11497 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11498 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11499 | // The image format check comes 2nd in validation so we trigger it first, |
| 11500 | // 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] | 11501 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11502 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11503 | m_errorMonitor->SetDesiredFailureMsg( |
| 11504 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11505 | "Combination depth/stencil image formats can have only the "); |
| 11506 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11507 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11508 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11509 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11510 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11511 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11512 | |
| 11513 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11514 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11515 | ds_pool_ci.pNext = NULL; |
| 11516 | ds_pool_ci.maxSets = 1; |
| 11517 | ds_pool_ci.poolSizeCount = 1; |
| 11518 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11519 | |
| 11520 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11521 | err = |
| 11522 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11523 | ASSERT_VK_SUCCESS(err); |
| 11524 | |
| 11525 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11526 | dsl_binding.binding = 0; |
| 11527 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11528 | dsl_binding.descriptorCount = 1; |
| 11529 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11530 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11531 | |
| 11532 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11533 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11534 | ds_layout_ci.pNext = NULL; |
| 11535 | ds_layout_ci.bindingCount = 1; |
| 11536 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11537 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11538 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11539 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11540 | ASSERT_VK_SUCCESS(err); |
| 11541 | |
| 11542 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11543 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11544 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11545 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11546 | alloc_info.descriptorPool = ds_pool; |
| 11547 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11548 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11549 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11550 | ASSERT_VK_SUCCESS(err); |
| 11551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11552 | VkImage image_bad; |
| 11553 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11554 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11555 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11556 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11557 | const int32_t tex_width = 32; |
| 11558 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11559 | |
| 11560 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11561 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11562 | image_create_info.pNext = NULL; |
| 11563 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11564 | image_create_info.format = tex_format_bad; |
| 11565 | image_create_info.extent.width = tex_width; |
| 11566 | image_create_info.extent.height = tex_height; |
| 11567 | image_create_info.extent.depth = 1; |
| 11568 | image_create_info.mipLevels = 1; |
| 11569 | image_create_info.arrayLayers = 1; |
| 11570 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11571 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11572 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11573 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11574 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11575 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11576 | err = |
| 11577 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11578 | ASSERT_VK_SUCCESS(err); |
| 11579 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11580 | image_create_info.usage = |
| 11581 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11582 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11583 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11584 | ASSERT_VK_SUCCESS(err); |
| 11585 | |
| 11586 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11587 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11588 | image_view_create_info.image = image_bad; |
| 11589 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11590 | image_view_create_info.format = tex_format_bad; |
| 11591 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11592 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11593 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11594 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11595 | image_view_create_info.subresourceRange.aspectMask = |
| 11596 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11597 | |
| 11598 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11599 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11600 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11601 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11602 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11603 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11604 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11605 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11606 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11607 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11608 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11609 | |
| 11610 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11611 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11612 | "ClearDepthStencilImage with a color image."); |
| 11613 | |
| 11614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11615 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11616 | |
| 11617 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11618 | BeginCommandBuffer(); |
| 11619 | m_commandBuffer->EndRenderPass(); |
| 11620 | |
| 11621 | // Color image |
| 11622 | VkClearColorValue clear_color; |
| 11623 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11624 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11625 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11626 | const int32_t img_width = 32; |
| 11627 | const int32_t img_height = 32; |
| 11628 | VkImageCreateInfo image_create_info = {}; |
| 11629 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11630 | image_create_info.pNext = NULL; |
| 11631 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11632 | image_create_info.format = color_format; |
| 11633 | image_create_info.extent.width = img_width; |
| 11634 | image_create_info.extent.height = img_height; |
| 11635 | image_create_info.extent.depth = 1; |
| 11636 | image_create_info.mipLevels = 1; |
| 11637 | image_create_info.arrayLayers = 1; |
| 11638 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11639 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11640 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11641 | |
| 11642 | vk_testing::Image color_image; |
| 11643 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11644 | reqs); |
| 11645 | |
| 11646 | const VkImageSubresourceRange color_range = |
| 11647 | vk_testing::Image::subresource_range(image_create_info, |
| 11648 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11649 | |
| 11650 | // Depth/Stencil image |
| 11651 | VkClearDepthStencilValue clear_value = {0}; |
| 11652 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11653 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11654 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11655 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11656 | ds_image_create_info.extent.width = 64; |
| 11657 | ds_image_create_info.extent.height = 64; |
| 11658 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11659 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11660 | |
| 11661 | vk_testing::Image ds_image; |
| 11662 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11663 | reqs); |
| 11664 | |
| 11665 | const VkImageSubresourceRange ds_range = |
| 11666 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11667 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11668 | |
| 11669 | m_errorMonitor->SetDesiredFailureMsg( |
| 11670 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11671 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11672 | |
| 11673 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11674 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11675 | &color_range); |
| 11676 | |
| 11677 | m_errorMonitor->VerifyFound(); |
| 11678 | |
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame^] | 11679 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11680 | "vkCmdClearColorImage called with " |
| 11681 | "image created without " |
| 11682 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 11683 | |
| 11684 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11685 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11686 | &color_range); |
| 11687 | |
| 11688 | m_errorMonitor->VerifyFound(); |
| 11689 | |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11690 | // Call CmdClearDepthStencilImage with color image |
| 11691 | m_errorMonitor->SetDesiredFailureMsg( |
| 11692 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11693 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11694 | |
| 11695 | vkCmdClearDepthStencilImage( |
| 11696 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11697 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11698 | &ds_range); |
| 11699 | |
| 11700 | m_errorMonitor->VerifyFound(); |
| 11701 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11702 | #endif // IMAGE_TESTS |
| 11703 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11704 | int main(int argc, char **argv) { |
| 11705 | int result; |
| 11706 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11707 | #ifdef ANDROID |
| 11708 | int vulkanSupport = InitVulkan(); |
| 11709 | if (vulkanSupport == 0) |
| 11710 | return 1; |
| 11711 | #endif |
| 11712 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11713 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11714 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11715 | |
| 11716 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11717 | |
| 11718 | result = RUN_ALL_TESTS(); |
| 11719 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11720 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11721 | return result; |
| 11722 | } |